leannebriffa commited on
Commit
df9eb80
·
1 Parent(s): 87eddb4

Fixed syntax errors in app.py #2

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -29,10 +29,10 @@ num_cols = ['Driver City', 'Make', 'Number Of Offences', 'Stop Hour', 'Stop Year
29
  # Configuration section END
30
 
31
 
32
- make_prediction(alcohol, arrest_type, belts, contributed_to_accident, disobedience, driver_city, gender,
33
- invalid_documentation, make, mobile_phone, negligent_driving, number_of_offences, personal_injury,
34
- property_damage, race, road_signs_and_markings, search_outcome, speeding, stop_hour, stop_year,
35
- subagency, vehicle_safety_and_standards, vehicletype, year):
36
  """
37
  Function to predict the 'Violation Type' of an individual sample of traffic stop:
38
  :param alcohol: boolean
@@ -109,26 +109,26 @@ arrest_types = ['A - Marked Patrol', 'G - Marked Moving Radar (Stationary)',
109
 
110
  iface = gr.Interface(fn=make_prediction,
111
  inputs=[gr.components.Checkbox(label='Was the driver under the influence of alcohol?'),
112
- gr.components.Dropdown(label='Choose the arrest type', choices=arrest_types, value='A - Marked Patrol')
113
  gr.components.Checkbox(label='Were seatbelts used appropriately?'),
114
  gr.components.Checkbox(label='Did the driver actions contribute to an accident?'),
115
  gr.components.Checkbox(label='Was the driver disobedient? (such as failing to display documentation upon request)?'),
116
- gr.components.Dropdown(label='Choose the arrest type', choices=tf['OrdinalEncoder_VeryHighCardinality'].categories_, value='SILVER SPRING')
117
- gr.components.Dropdown(label='Driver Gender', choices=['M', 'F', 'N'], value='M')
118
  gr.components.Checkbox(label='Was the driver driving with Invalid Documentation (such as suspended registration, suspended license, expired registration plates and validation tabs or expired license plate)?'),
119
- gr.components.Dropdown(label='Vehicle Make', choices=tf['OrdinalEncoder_HighCardinality'].categories_[0], value='TOYOTA')
120
  gr.components.Checkbox(label='Was the driver using a mobile phone while driving?'),
121
  gr.components.Checkbox(label='Was the driver caught driving with negligence (example switching lanes in an unsafe manner)?'),
122
  gr.components.Slider(minimum=1, step=1, label='Number of offences committed'),
123
  gr.components.Checkbox(label='Did the violation involve any personal injury?'),
124
  gr.components.Checkbox(label='Did the violation involve any property damage?'),
125
- gr.components.Dropdown(label='Choose the race of the driver', choices=tf['OneHotEncoder'].transformers_[0][1].categories_[2], value='WHITE')
126
  gr.components.Checkbox(label='Did the driver fail to obey signs and markings (such as traffic control device instructions, stop lights, red signal and stop sign lines)?'),
127
- gr.components.Dropdown(label='Choose the race of the driver', choices=tf['OneHotEncoder'].transformers_[0][1].categories_[3], value='NO SEARCH CONDUCTED')
128
  gr.components.Checkbox(label='Was the driver caught speeding?'),
129
  gr.components.Slider(maximum=23, step=1, label='Time HOUR when stop occurred in 24-hour format'),
130
  gr.components.Slider(minimum=2012, maximum=2024, step=1, label='Year when stop occurred'),
131
- gr.components.Dropdown(label='What is the name of the subagency that conducted the traffic stop?', choices=tf['OneHotEncoder'].transformers_[0][1].categories_[1], value='4th District, Wheaton')
132
  gr.components.Checkbox(label='Was the vehicle safe and up to standards (lights properly switched, registration plates attached etc.)?'),
133
  gr.components.Slider(minimum=1970, maximum=2023, step=1, label='Year of manufacture of the vehicle:')],
134
  outputs=["text"])
 
29
  # Configuration section END
30
 
31
 
32
+ def make_prediction(alcohol, arrest_type, belts, contributed_to_accident, disobedience, driver_city, gender,
33
+ invalid_documentation, make, mobile_phone, negligent_driving, number_of_offences, personal_injury,
34
+ property_damage, race, road_signs_and_markings, search_outcome, speeding, stop_hour, stop_year,
35
+ subagency, vehicle_safety_and_standards, vehicletype, year):
36
  """
37
  Function to predict the 'Violation Type' of an individual sample of traffic stop:
38
  :param alcohol: boolean
 
109
 
110
  iface = gr.Interface(fn=make_prediction,
111
  inputs=[gr.components.Checkbox(label='Was the driver under the influence of alcohol?'),
112
+ gr.components.Dropdown(label='Choose the arrest type', choices=arrest_types, value='A - Marked Patrol'),
113
  gr.components.Checkbox(label='Were seatbelts used appropriately?'),
114
  gr.components.Checkbox(label='Did the driver actions contribute to an accident?'),
115
  gr.components.Checkbox(label='Was the driver disobedient? (such as failing to display documentation upon request)?'),
116
+ gr.components.Dropdown(label='Choose the arrest type', choices=tf['OrdinalEncoder_VeryHighCardinality'].categories_, value='SILVER SPRING'),
117
+ gr.components.Dropdown(label='Driver Gender', choices=['M', 'F', 'N'], value='M'),
118
  gr.components.Checkbox(label='Was the driver driving with Invalid Documentation (such as suspended registration, suspended license, expired registration plates and validation tabs or expired license plate)?'),
119
+ gr.components.Dropdown(label='Vehicle Make', choices=tf['OrdinalEncoder_HighCardinality'].categories_[0], value='TOYOTA'),
120
  gr.components.Checkbox(label='Was the driver using a mobile phone while driving?'),
121
  gr.components.Checkbox(label='Was the driver caught driving with negligence (example switching lanes in an unsafe manner)?'),
122
  gr.components.Slider(minimum=1, step=1, label='Number of offences committed'),
123
  gr.components.Checkbox(label='Did the violation involve any personal injury?'),
124
  gr.components.Checkbox(label='Did the violation involve any property damage?'),
125
+ gr.components.Dropdown(label='Choose the race of the driver', choices=tf['OneHotEncoder'].transformers_[0][1].categories_[2], value='WHITE'),
126
  gr.components.Checkbox(label='Did the driver fail to obey signs and markings (such as traffic control device instructions, stop lights, red signal and stop sign lines)?'),
127
+ gr.components.Dropdown(label='Choose the race of the driver', choices=tf['OneHotEncoder'].transformers_[0][1].categories_[3], value='NO SEARCH CONDUCTED'),
128
  gr.components.Checkbox(label='Was the driver caught speeding?'),
129
  gr.components.Slider(maximum=23, step=1, label='Time HOUR when stop occurred in 24-hour format'),
130
  gr.components.Slider(minimum=2012, maximum=2024, step=1, label='Year when stop occurred'),
131
+ gr.components.Dropdown(label='What is the name of the subagency that conducted the traffic stop?', choices=tf['OneHotEncoder'].transformers_[0][1].categories_[1], value='4th District, Wheaton'),
132
  gr.components.Checkbox(label='Was the vehicle safe and up to standards (lights properly switched, registration plates attached etc.)?'),
133
  gr.components.Slider(minimum=1970, maximum=2023, step=1, label='Year of manufacture of the vehicle:')],
134
  outputs=["text"])