rasmodev commited on
Commit
6225082
1 Parent(s): d433390

Update app.py

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