kedarnathdev commited on
Commit
a2ff92c
1 Parent(s): 268170c

Upload 6 files

Browse files
Files changed (6) hide show
  1. lasso.pkl +3 -0
  2. linear.pkl +3 -0
  3. main.py +95 -0
  4. randomforest.pkl +3 -0
  5. requirements.txt +0 -0
  6. svm.pkl +3 -0
lasso.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:758eee28caf0451b5771db86a5215b18fc6430919cc92063d9478a5d3543616c
3
+ size 5195
linear.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0ece41d276cae7e4f82d7f87a3176aac112169d4914978d7075602d4b37616ce
3
+ size 857
main.py ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import pickle
4
+
5
+
6
+ st.set_page_config(
7
+ page_title="Air Quality Index prediction",
8
+ layout= "wide",
9
+ menu_items= {
10
+ "Get Help" : "https://github.com/kedarnathdev/AQIprediction",
11
+ "Report a bug" : "https://github.com/kedarnathdev/AQIprediction/issues",
12
+ "About": None,
13
+ # "About" : "Made by [@kedarnathdev](https://www.gitub.com/kedarnathdev)"
14
+ }
15
+ )
16
+
17
+
18
+ hide_streamlit_style = """
19
+ <style>
20
+
21
+ footer {visibility: hidden;}
22
+ </style>
23
+ """
24
+ st.markdown(hide_streamlit_style, unsafe_allow_html=True)
25
+
26
+
27
+
28
+ models = {
29
+ 'Random Forest': 'randomforest.pkl',
30
+ 'SVM model': 'svm.pkl',
31
+ 'Linear Regression': 'linear.pkl',
32
+ 'Lasso Regression': 'lasso.pkl'
33
+ }
34
+
35
+
36
+ def load_model(filename):
37
+ with open(filename, 'rb') as model_file:
38
+ model = pickle.load(model_file)
39
+ return model
40
+
41
+ st.header('Air Quality Index Predictor')
42
+ st.subheader('Enter the following values:')
43
+ T = st.number_input('Average Temperature')
44
+ TM = st.number_input('Maximum Temperature')
45
+ Tm = st.number_input('Minimum Temperature')
46
+ SLP = st.number_input('Atmospheric pressure at sea level')
47
+ H = st.number_input('Average Relative Humidity')
48
+ VV = st.number_input('Average Visibility')
49
+ V = st.number_input('Average Wind Speed')
50
+ VM = st.number_input('Maximum Sustained Wind Speed')
51
+
52
+ selected_model = st.selectbox('Select a model', list(models.keys()))
53
+
54
+ if st.button('Predict'):
55
+ if not (T and TM and Tm and SLP and H and VV and V and VM):
56
+ st.error('Please fill all the fields.')
57
+ else:
58
+ model_file = models[selected_model]
59
+ model = load_model(model_file)
60
+
61
+ input_df = pd.DataFrame({
62
+ 'T': T,
63
+ 'TM': TM,
64
+ 'Tm': Tm,
65
+ 'SLP': SLP,
66
+ 'H': H,
67
+ 'VV': VV,
68
+ 'V': V,
69
+ 'VM': VM
70
+ }, index=[0])
71
+
72
+ prediction = model.predict(input_df)[0]
73
+
74
+ if prediction <= 50:
75
+ color = 'green'
76
+ description = 'Good: Air quality is satisfactory, and air pollution poses little or no risk.'
77
+ elif prediction <= 100:
78
+ color = 'yellow'
79
+ description = 'Moderate: Air quality is acceptable. However, there may be a risk for some people, particularly those who are unusually sensitive to air pollution.'
80
+ elif prediction <= 150:
81
+ color = 'orange'
82
+ description = 'Unhealthy for Sensitive Groups: Members of sensitive groups may experience health effects. The general public is less likely to be affected.'
83
+ elif prediction <= 200:
84
+ color = 'red'
85
+ description = 'Unhealthy: Some members of the general public may experience health effects members of sensitive groups may experience more serious health effects.'
86
+ elif prediction <= 300:
87
+ color = 'purple'
88
+ description = 'Very Unhealthy: Health alert, The risk of health effects is increased for everyone.'
89
+ else:
90
+ color = 'maroon'
91
+ description = 'Hazardous: Health warning of emergency conditions: everyone is more likely to be affected.'
92
+
93
+
94
+ st.markdown(f'<h1 style="color:{color};">AQI: {prediction}</h1>', unsafe_allow_html=True)
95
+ st.write(description)
randomforest.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bac8cf4cfe26e180705f8f693f035c9b7f2593015234f5e3a0f6b3c5927aa276
3
+ size 2513079
requirements.txt ADDED
Binary file (2.05 kB). View file
 
svm.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:79c131cfab25eaa0adcb7c449e69e56551508c0414707faa5d2c64fb5f2cce1e
3
+ size 35583