CoolFace
Apppublic

PongsakornSET/Testset

sourceHugging Facecc-by-4.0updated 4y agoView on Hugging Face
0likes
app.py66 linesDownload Raw Back to root
1import joblib2import pandas as pd3 4 5EDU_DICT = {'Preschool': 1,6            '1st-4th': 2,7            '5th-6th': 3,8            '7th-8th': 4,9            '9th': 5,10            '10th': 6,11            '11th': 7,12            '12th': 8,13            'HS-grad': 9, 14            'Some-college': 10,15            'Assoc-voc': 11,16            'Assoc-acdm': 12,17            'Bachelors': 13,18            'Masters': 14,19            'Prof-school': 15,20            'Doctorate': 1621            }22 23model = #24unique_values = #25    26unique_class =  unique_values["workclass"]27unique_education =  unique_values["education"]28unique_marital_status =  unique_values["marital.status"]29unique_relationship =  unique_values["relationship"]30unique_occupation =  unique_values["occupation"]31unique_sex =  unique_values["sex"]32unique_race = unique_values["race"]33unique_country =  unique_values["native.country"]34 35def main():36    st.title("Adult Income")37 38    with st.form("questionaire"):39        age = # user's input40        workclass = # user's input41        education = # user's input42        Marital_Status = # user's input43        occupation = # user's input44        relationship = # user's input45        race = # user's input46        sex = # user's input47        hours_per_week = # user's input48        native_country = # user's input49 50        # clicked==True only when the button is clicked51        clicked = st.form_submit_button("Predict income")52        if clicked:53            result=model.predict(pd.DataFrame({"age": [age],54                                               "workclass": [workclass],55                                               "education": [EDU_DICT[education]],56                                               "marital.status": [Marital_Status],57                                               "occupation": [occupation],58                                               "relationship": [relationship],59                                               "race": [race],60                                               "sex": [sex],61                                               "hours.per.week": [hours_per_week],62                                               "native.country": [native_country]}))63            # Show prediction64 65# Run main()66