Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

webapp.py 1.7 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
  1. import streamlit as st
  2. import pandas as pd
  3. import pickle
  4. import numpy as np
  5. import math
  6. with open('preprocess.pkl', 'rb') as f:
  7. pre = pickle.load(f)
  8. with open('xg.pkl','rb') as file:
  9. model = pickle.load(file)
  10. st.header('App for user predictions for Scooter Rental platform')
  11. def user_input_features():
  12. hr = st.sidebar.slider('Hour of Day', 0, 24, 12)
  13. weather = st.sidebar.radio('Weather', ['clear', 'cloudy', 'light snow/rain'])
  14. temperature = st.sidebar.slider("Temp", 30, 140, 60)
  15. relative_humidity = st.sidebar.slider('Humidity', 0, 100, 30)
  16. windspeed = st.sidebar.slider('Windspeed', 0, 70, 10)
  17. year = st.sidebar.slider('Year', 2011, 2012)
  18. month = st.sidebar.selectbox('Month', ['January', 'February', 'March','April','May','June',
  19. 'July','August','September','October','November','December'])
  20. dayofweek = st.sidebar.selectbox('Day', ['Monday', 'Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'])
  21. data = {'hr': hr, 'weather': weather, 'temperature': temperature, 'relative-humidity': relative_humidity,
  22. 'windspeed': windspeed, 'year': year, 'month': month, 'dayofweek': dayofweek}
  23. features = pd.DataFrame(data, index=[0])
  24. return features
  25. df = user_input_features()
  26. # st.write(df)
  27. df_tf = pre.transform(df)
  28. log_prediction = model.predict(df_tf)
  29. result = int(2.71828**log_prediction)
  30. if st.checkbox('Show dataset'):
  31. st.write('### Scooter rental dataset')
  32. if st.checkbox('Show transformed dataset'):
  33. st.write(df_tf)
  34. elif st.checkbox('Show original dataset'):
  35. st.write(df)
  36. st.subheader('Users Prediction')
  37. st.write(result)
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...