Spaces:
Runtime error
Runtime error
Update app.py
Browse files18 unmodified lines1920212222232425262728293031323334354 unmodified lines404142334344454615 unmodified lines626364556518 unmodified lines
# Define the function for making predictionsdef salarybracket(age, workclass, education, marital_status, occupation, relationship, race, gender, native_country): inputs = np.array([[age, workclass, education, marital_status, occupation, relationship, race, gender, native_country]]) # Get the value associated with the selected label workclass_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) marital_status_value = next((v for k, v in mapping['marital_status'].items() if k == marital_status), None) occupation_value = next((v for k, v in mapping['occupation'].items() if k == occupation), None) relationship_value = next((v for k, v in mapping['relationship'].items() if k == relationship), None) race_value = next((v for k, v in mapping['race'].items() if k == race), None) gender_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 scalar result = "Income_bracket lesser than or equal to 50K ⬇️" if prediction_value <= 0.5 else "Income_bracket greater than 50K ⬆️"4 unmodified linesfor column, values in mapping.items(): options = [] for label, value in values.items(): options.append({label}) options.append(label) dropdown_options[column] = options
# Create the Gradio interface15 unmodified lines theme='dark' )
salarybracket_ga.launch(share=True, debug=True)salarybracket_ga.launch(share=True, debug=True)app.py+13-3