rasmodev commited on
Commit
69437bd
·
1 Parent(s): 6a82180

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -19
app.py CHANGED
@@ -118,25 +118,24 @@ if st.button("Predict"):
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")
 
 
 
 
 
 
 
 
118
 
119
 
120
  # Send a POST request to the FastAPI server
121
+ response = requests.post("http://localhost:8000/predict/", json=user_input) # Use the correct URL
122
 
 
123
  # Check if the request was successful
124
+ if response.status_code == 200:
125
+ prediction_data = response.json()
126
+
127
+ # Display prediction result to the user
128
+ st.subheader("Prediction Result")
129
+
130
+ # Determine income prediction and format message
131
+ if prediction_data['income_prediction'] == "Income over $50K":
132
+ st.success("This individual is predicted to have an income of over $50K.")
 
 
 
 
 
 
 
133
  else:
134
+ st.error("This individual is predicted to have an income of under $50K")
135
+
136
+ # Display prediction probability
137
+ st.subheader("Prediction Probability")
138
+ probability = prediction_data['prediction_probability']
139
+ st.write(f"The probability of the individual having an income over $50K is: {probability:.2f}")
140
+ else:
141
+ st.error("Error: Unable to get prediction")