Update driverpospredictionfinal.py
Browse files- driverpospredictionfinal.py +6 -57
driverpospredictionfinal.py
CHANGED
@@ -184,69 +184,18 @@ tuned_model_3 = hyper_paramter_tuning(model_3,xtrain,ytrain,**parameter_grid)
|
|
184 |
y_pred= predict(tuned_model_3,xtest,ytest)
|
185 |
|
186 |
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
|
192 |
|
193 |
-
predicted_position = ask_user(tuned_model_3, xtest)
|
194 |
-
|
195 |
-
#pickle.dump(tuned_model_3.open('model.pkl','mb'))
|
196 |
-
|
197 |
-
!pip install streamlit
|
198 |
-
import streamlit as st
|
199 |
-
import pickle
|
200 |
-
import numpy as np
|
201 |
|
202 |
-
|
203 |
-
|
204 |
-
def predictPos(TLaps,Laptime,Pit,Prev,AvgSpeed,AirTemp,TrackTemp,Humid,Wind):
|
205 |
-
input = np.array([ [TLaps,Laptime,Pit,Prev,AvgSpeed,AirTemp,TrackTemp,Humid,Wind]]).astype(np.float64)
|
206 |
-
prediction=model.predict(input)
|
207 |
-
return prediction[0]
|
208 |
-
|
209 |
-
def main():
|
210 |
-
st.title("title")
|
211 |
-
html_temp="""
|
212 |
-
<div style = "background-color:#025244; padding :10px">
|
213 |
-
<h2 style = "color:white; text-align:center;"> Driver Position Prediction </h2>
|
214 |
-
</div>
|
215 |
-
"""
|
216 |
-
st.markdown(html_temp, unsafe_allow_html=True)
|
217 |
-
TLaps = st.text_input("Enter the number of total laps in race: ","Type Here")
|
218 |
-
Laptime = st.text_input("Avg lap time from prev year (or estimate 98): ","Type Here")
|
219 |
-
Pit = st.text_input("Enter pit stop time (0 if no pit stop): ","Type Here")
|
220 |
-
Prev= st.text_input("Enter avg lap time differece (0-2) (0 if first lap): ","Type Here")
|
221 |
-
|
222 |
-
|
223 |
-
AvgSpeed = st.text_input("Enter average speed in km/h from prev year: ","Type Here")
|
224 |
-
AirTemp= st.text_input("estimate air temperature in Celsius on race day: ","Type Here")
|
225 |
-
TrackTemp = st.text_input("estimate track temperature in Celsius on race day: ","Type Here")
|
226 |
-
Humid = st.text_input("estimate the humidity percentage (0-100) on race day: ","Type Here")
|
227 |
-
Wind = st.text_input("estimate wind speed in km/h: ","Type Here")
|
228 |
-
safe_html="""
|
229 |
-
<div style="background-color:#F4D03F;padding:10px >
|
230 |
-
<h2 style="color:white;text-align:center;"> Your forest is safe</h2>
|
231 |
-
</div>
|
232 |
-
"""
|
233 |
-
danger_html="""
|
234 |
-
<div style="background-color:#F08080;padding:10px >
|
235 |
-
<h2 style="color:black ;text-align:center;"> Your forest is in danger</h2>
|
236 |
-
</div>
|
237 |
-
"""
|
238 |
|
239 |
-
if st.button("Predict"):
|
240 |
-
output=predictPos(TLaps,Laptime,Pit,Prev,AvgSpeed,AirTemp,TrackTemp,Humid,Wind)
|
241 |
-
st.success('The postion of driver is {}'.format(output))
|
242 |
|
243 |
-
# if output > 0.5:
|
244 |
-
# st.markdown(danger_html,unsafe_allow_html=True)
|
245 |
-
# else:
|
246 |
-
# st.markdown(safe_html,unsafe_allow_html=True)
|
247 |
|
248 |
-
if __name__=='__main__':
|
249 |
-
main()
|
250 |
|
|
|
251 |
|
|
|
252 |
|
|
|
184 |
y_pred= predict(tuned_model_3,xtest,ytest)
|
185 |
|
186 |
|
187 |
+
with open('model.pkl', 'wb') as file:
|
188 |
+
pickle.dump(tuned_model_3, file)
|
|
|
|
|
189 |
|
190 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
|
192 |
+
# Ask user for input and predict position
|
193 |
+
#predicted_position = ask_user(tuned_model_3, x_columns)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
|
|
|
|
|
|
|
195 |
|
|
|
|
|
|
|
|
|
196 |
|
|
|
|
|
197 |
|
198 |
+
#predicted_position = ask_user(tuned_model_3, xtest)
|
199 |
|
200 |
+
#pickle.dump(tuned_model_3.open('model.pkl','mb'))
|
201 |
|