rasmodev commited on
Commit
e47898e
·
1 Parent(s): e6521a0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -2
app.py CHANGED
@@ -16,7 +16,7 @@ dt_model = components["model"]
16
  unique_values = components["unique_values"]
17
 
18
 
19
- st.image("https://pbs.twimg.com/media/DywhyJiXgAIUZej?format=jpg&name=medium")
20
  st.title("Income Prediction App")
21
 
22
  # Sidebar with input field descriptions
@@ -133,4 +133,40 @@ if st.button("Predict"):
133
 
134
  # Show prediction probability
135
  st.subheader("Prediction Probability")
136
- st.write(f"The probability of the individual having an income over $50K is: {prediction_proba[0][1]:.2f}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  unique_values = components["unique_values"]
17
 
18
 
19
+ st.image("https://i.ytimg.com/vi/WULwst0vW8g/maxresdefault.jpg")
20
  st.title("Income Prediction App")
21
 
22
  # Sidebar with input field descriptions
 
133
 
134
  # Show prediction probability
135
  st.subheader("Prediction Probability")
136
+ st.write(f"The probability of the individual having an income over $50K is: {prediction_proba[0][1]:.2f}")
137
+
138
+
139
+
140
+ import streamlit as st
141
+ import requests
142
+
143
+ # Streamlit UI for user input
144
+ st.title("Income Prediction App")
145
+ st.sidebar.header("Enter User Information")
146
+
147
+ # Create input fields for user input
148
+ age = st.number_input("Age", min_value=0)
149
+ gender = st.selectbox("Gender", ["Male", "Female"])
150
+ # Include other input fields...
151
+
152
+ # Button to trigger prediction
153
+ if st.button("Predict"):
154
+ # Create a dictionary of user input
155
+ user_input = {
156
+ "age": age,
157
+ "gender": gender,
158
+ # Include other input fields...
159
+ }
160
+
161
+ # Send a POST request to the FastAPI server
162
+ response = requests.post("http://fastapi-server:8000/predict/", json=user_input)
163
+
164
+ # Check if the request was successful
165
+ if response.status_code == 200:
166
+ prediction_data = response.json()
167
+ # Display prediction result to the user
168
+ st.subheader("Prediction Result")
169
+ st.write(f"Income: {prediction_data['income_prediction']}")
170
+ st.write(f"Prediction Probability: {prediction_data['prediction_probability']:.2f}")
171
+ else:
172
+ st.error("Error: Unable to get prediction")