Spaces:
Sleeping
Sleeping
Update app.py (#3)
Browse files- Update app.py (129d049b83d88cb2cc84b81f3254faeea05d92d1)
Co-authored-by: Aaleia <Aaleia@users.noreply.huggingface.co>
app.py
CHANGED
@@ -85,18 +85,17 @@ if 'selected' not in st.session_state or st.session_state.selected != selected:
|
|
85 |
st.header("Custom Prediction")
|
86 |
st.write("Enter your own values for prediction:")
|
87 |
|
88 |
-
selected_features = ["INITIAL_CALL_TYPE", "INITIAL_SEVERITY_LEVEL_CODE", "INCIDENT_DATETIME", "ZIPCODE", "POLICEPRECINCT"]
|
89 |
feature_inputs = {}
|
90 |
for feature in selected_features:
|
91 |
-
if feature not in ["FINAL_CALL_TYPE"]:
|
92 |
-
|
93 |
if feature in ['INITIAL_CALL_TYPE', 'DAY_OF_WEEK', 'POLICEPRECINCT', 'ZIPCODE']: # categorical
|
94 |
options = list(sample_data[feature].unique())
|
95 |
else: # numerical
|
96 |
options = [str(x) for x in sample_data[feature].unique()]
|
97 |
feature_inputs[feature] = st.selectbox(feature, options=options)
|
98 |
|
99 |
-
#
|
100 |
user_data = encode(pd.DataFrame(feature_inputs, index=[0]))
|
101 |
|
102 |
if st.button("Predict"):
|
|
|
85 |
st.header("Custom Prediction")
|
86 |
st.write("Enter your own values for prediction:")
|
87 |
|
88 |
+
selected_features = ["INITIAL_CALL_TYPE", "INITIAL_SEVERITY_LEVEL_CODE", "INCIDENT_DATETIME", "INCIDENT_CLOSE_DATETIME", "ZIPCODE", "POLICEPRECINCT", "FINAL_CALL_TYPE"]
|
89 |
feature_inputs = {}
|
90 |
for feature in selected_features:
|
91 |
+
if feature not in ["FINAL_CALL_TYPE"]: # ensure final not included
|
|
|
92 |
if feature in ['INITIAL_CALL_TYPE', 'DAY_OF_WEEK', 'POLICEPRECINCT', 'ZIPCODE']: # categorical
|
93 |
options = list(sample_data[feature].unique())
|
94 |
else: # numerical
|
95 |
options = [str(x) for x in sample_data[feature].unique()]
|
96 |
feature_inputs[feature] = st.selectbox(feature, options=options)
|
97 |
|
98 |
+
# encode user input
|
99 |
user_data = encode(pd.DataFrame(feature_inputs, index=[0]))
|
100 |
|
101 |
if st.button("Predict"):
|