greencatted commited on
Commit
0218ad1
·
2 Parent(s): 724a5e6 fdc1aa7

Merge branch 'main' of https://huggingface.co/spaces/greencatted/EMS-Call-Classifier

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py CHANGED
@@ -80,6 +80,34 @@ if 'selected' not in st.session_state or st.session_state.selected != selected:
80
  st.session_state.selected = selected
81
 
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  st.header("Results")
84
  st.markdown(
85
  """
 
80
  st.session_state.selected = selected
81
 
82
 
83
+ # CUSTOM PREDICTIONS SECTION
84
+
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
+ # Encode user input
100
+ user_data = encode(pd.DataFrame(feature_inputs, index=[0]))
101
+
102
+ if st.button("Predict"):
103
+ t1 = time.time() * 1000
104
+ predicted_label = predict(user_data)
105
+ t2 = time.time() * 1000
106
+
107
+ st.write("Predicted Call Type:", predicted_label)
108
+ st.write(f"Prediction Time: {t2-t1:.2f}ms")
109
+
110
+
111
  st.header("Results")
112
  st.markdown(
113
  """