rasmodev commited on
Commit
6a82180
·
1 Parent(s): 35909db

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -2
app.py CHANGED
@@ -115,7 +115,28 @@ if st.button("Predict"):
115
  "country_of_birth_own": country_of_birth_own,
116
  "importance_of_record": float(importance_of_record)
117
  }
 
 
118
  # Send a POST request to the FastAPI server
119
  response = requests.post("https://rasmodev-income-prediction-fastapi.hf.space/predict", json=user_input)
120
- prediction = response.text
121
- st.success(f"This individual is predicted to have an income of:{prediction}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  "country_of_birth_own": country_of_birth_own,
116
  "importance_of_record": float(importance_of_record)
117
  }
118
+
119
+
120
  # Send a POST request to the FastAPI server
121
  response = requests.post("https://rasmodev-income-prediction-fastapi.hf.space/predict", json=user_input)
122
+
123
+
124
+ # Check if the request was successful
125
+ if response.status_code == 200:
126
+ prediction_data = response.json()
127
+
128
+ # Display prediction result to the user
129
+ st.subheader("Prediction Result")
130
+
131
+ # Determine income prediction and format message
132
+ if prediction_data['income_prediction'] == "Income over $50K":
133
+ st.success("This individual is predicted to have an income of over $50K.")
134
+ else:
135
+ st.error("This individual is predicted to have an income of under $50K")
136
+
137
+ # Display prediction probability
138
+ st.subheader("Prediction Probability")
139
+ probability = prediction_data['prediction_probability']
140
+ st.write(f"The probability of the individual having an income over $50K is: {probability:.2f}")
141
+ else:
142
+ st.error("Error: Unable to get prediction")