Spaces:
Sleeping
Sleeping
Added custom predictions section (test)
Browse files
app.py
CHANGED
@@ -73,6 +73,34 @@ if 'selected' not in st.session_state or st.session_state.selected != selected:
|
|
73 |
st.session_state.selected = selected
|
74 |
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
st.header("Results")
|
77 |
st.markdown(
|
78 |
"""
|
|
|
73 |
st.session_state.selected = selected
|
74 |
|
75 |
|
76 |
+
# CUSTOM PREDICTIONS SECTION
|
77 |
+
|
78 |
+
st.header("Custom Prediction")
|
79 |
+
st.write("Enter your own values for prediction:")
|
80 |
+
|
81 |
+
selected_features = ["INITIAL_CALL_TYPE", "INITIAL_SEVERITY_LEVEL_CODE", "INCIDENT_DATETIME", "ZIPCODE", "POLICEPRECINCT"]
|
82 |
+
feature_inputs = {}
|
83 |
+
for feature in selected_features:
|
84 |
+
if feature not in ["FINAL_CALL_TYPE"]:
|
85 |
+
|
86 |
+
if feature in ['INITIAL_CALL_TYPE', 'DAY_OF_WEEK', 'POLICEPRECINCT', 'ZIPCODE']: # categorical
|
87 |
+
options = list(sample_data[feature].unique())
|
88 |
+
else: # numerical
|
89 |
+
options = [str(x) for x in sample_data[feature].unique()]
|
90 |
+
feature_inputs[feature] = st.selectbox(feature, options=options)
|
91 |
+
|
92 |
+
# Encode user input
|
93 |
+
user_data = encode(pd.DataFrame(feature_inputs, index=[0]))
|
94 |
+
|
95 |
+
if st.button("Predict"):
|
96 |
+
t1 = time.time() * 1000
|
97 |
+
predicted_label = predict(user_data)
|
98 |
+
t2 = time.time() * 1000
|
99 |
+
|
100 |
+
st.write("Predicted Call Type:", predicted_label)
|
101 |
+
st.write(f"Prediction Time: {t2-t1:.2f}ms")
|
102 |
+
|
103 |
+
|
104 |
st.header("Results")
|
105 |
st.markdown(
|
106 |
"""
|