Spaces:
Runtime error
Runtime error
Update app.py
Browse files17 unmodified lines181920212223244 unmodified lines2930313233343513 unmodified lines49505152535455565758596017 unmodified lines}# Define the function for making predictionsdef salarybracket(age, workclass, education, marital_status, occupation, relationship, race, gender, native_country):# Get the value associated with the selected labelworkclass_value = next((v for k, v in mapping['workclass'].items() if k == workclass), None)education_value = next((v for k, v in mapping['education'].items() if k == education), None)4 unmodified linesgender_value = next((v for k, v in mapping['gender'].items() if k == gender), None)native_country_value = next((v for k, v in mapping['native_country'].items() if k == native_country), None)inputs = np.array([[age, workclass_value, education_value, marital_status_value, occupation_value, relationship_value, race_value, gender_value, native_country_value]])prediction = model.predict(inputs)prediction_value = prediction[0][0] # Assuming the prediction is a scalarresult = "Income_bracket lesser than or equal to 50K ⬇️" if prediction_value <= 0.5 else "Income_bracket greater than 50K ⬆️"13 unmodified linesgr.Slider(17, 90, label="Age"),gr.Dropdown(dropdown_options['workclass'], label="Workclass"),gr.Dropdown(dropdown_options['education'], label="Education"),gr.Dropdown(dropdown_options['marital_status'], label="Marital Status"),gr.Dropdown(dropdown_options['occupation'], label="Occupation"),gr.Dropdown(dropdown_options['relationship'], label="Relationship"),gr.Dropdown(dropdown_options['race'], label="Race"),gr.Dropdown(dropdown_options['gender'], label="Gender"),gr.Dropdown(dropdown_options['native_country'], label="Native Country")],outputs="text",title="Salary Bracket Prediction",17 unmodified lines181920212223244 unmodified lines2930313233343513 unmodified lines4950515253545556575859606162636417 unmodified lines}# Define the function for making predictionsdef salarybracket(age, workclass, education, education_num, marital_status, occupation, relationship, race, gender, capital_gain, capital_loss, hours_per_week, native_country):# Get the value associated with the selected labelworkclass_value = next((v for k, v in mapping['workclass'].items() if k == workclass), None)education_value = next((v for k, v in mapping['education'].items() if k == education), None)4 unmodified linesgender_value = next((v for k, v in mapping['gender'].items() if k == gender), None)native_country_value = next((v for k, v in mapping['native_country'].items() if k == native_country), None)inputs = np.array([[age, workclass_value, education_value, education_num, marital_status_value, occupation_value, relationship_value, race_value, gender_value, capital_gain, capital_loss, hours_per_week, native_country_value]])prediction = model.predict(inputs)prediction_value = prediction[0][0] # Assuming the prediction is a scalarresult = "Income_bracket lesser than or equal to 50K ⬇️" if prediction_value <= 0.5 else "Income_bracket greater than 50K ⬆️"13 unmodified linesgr.Slider(17, 90, label="Age"),gr.Dropdown(dropdown_options['workclass'], label="Workclass"),gr.Dropdown(dropdown_options['education'], label="Education"),gr.Number(1, 16, label="Education Num [1 to 16]"),gr.Dropdown(dropdown_options['marital_status'], label="Marital Status"),gr.Dropdown(dropdown_options['occupation'], label="Occupation"),gr.Dropdown(dropdown_options['relationship'], label="Relationship"),gr.Dropdown(dropdown_options['race'], label="Race"),gr.Dropdown(dropdown_options['gender'], label="Gender"),gr.Number(0, 99999, label="Capital Gain [0 to 99999]"),gr.Number(0, 4356, label="Capital Loss [0 to 4356]"),gr.Number(1, 99, label="Hours per Week [1 to 99]"),gr.Dropdown(dropdown_options['native_country'], label="Native Country")],outputs="text",title="Salary Bracket Prediction",
app.py+7-3