rockonrover commited on
Commit
c5dae3a
·
verified ·
1 Parent(s): 193ed9b

initial commit

Browse files
Files changed (3) hide show
  1. app.py +43 -0
  2. classification_model.pkl +3 -0
  3. regression_model.pkl +3 -0
app.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pickle
2
+ import streamlit as st
3
+ import numpy as np
4
+ import os
5
+
6
+ # Load the regression model
7
+ with open("regression_model.pkl", "rb") as f:
8
+ regression_model = pickle.load(f)
9
+
10
+ print("Regression model loaded successfully!")
11
+
12
+ # Load the classification model
13
+ with open("classification_model.pkl", "rb") as f:
14
+ classification_model = pickle.load(f)
15
+
16
+ print("Model loaded successfully!")
17
+
18
+ # Streamlit UI
19
+ st.title("🌍 Air Pollution Prediction System")
20
+
21
+ st.sidebar.header("Enter Environmental Factors:")
22
+ temperature = st.sidebar.number_input("Temperature (°C)", min_value=-10.0, max_value=50.0, value=25.0)
23
+ humidity = st.sidebar.number_input("Humidity (%)", min_value=0.0, max_value=100.0, value=50.0)
24
+ pm10 = st.sidebar.number_input("PM10 Level", min_value=0.0, max_value=500.0, value=20.0)
25
+ no2 = st.sidebar.number_input("NO2 Level", min_value=0.0, max_value=500.0, value=15.0)
26
+ so2 = st.sidebar.number_input("SO2 Level", min_value=0.0, max_value=500.0, value=10.0)
27
+ co = st.sidebar.number_input("CO Level", min_value=0.0, max_value=10.0, value=1.0)
28
+ industrial_proximity = st.sidebar.slider("Proximity to Industrial Areas", 0.0, 10.0, 5.0)
29
+ population_density = st.sidebar.number_input("Population Density", min_value=0, max_value=10000, value=500)
30
+
31
+ # Collect input into an array
32
+ features = np.array([[temperature, humidity, pm10, no2, so2, co, industrial_proximity, population_density]])
33
+
34
+ # Predict PM2.5 Level (Regression)
35
+ if st.sidebar.button("Predict PM2.5 Level"):
36
+ pm25_pred = regression_model.predict(features)
37
+ st.write(f"**Predicted PM2.5 Level:** {pm25_pred[0]:.2f}")
38
+
39
+ # Predict Air Quality (Classification)
40
+ if st.sidebar.button("Predict Air Quality Level"):
41
+ air_quality_pred = classification_model.predict(features)
42
+ quality_map = {0: "Good", 1: "Moderate", 2: "Unhealthy", 3: "Hazardous"}
43
+ st.write(f"**Predicted Air Quality Level:** {quality_map[air_quality_pred[0]]}")
classification_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4bd899d04440ab2fe1be4ebd1f2d8fa5267e4a7b858834e86841b29ce2b76931
3
+ size 4628134
regression_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8a94f357d7debc4269eabd0f7d91630f159b3d170756f8599a78d28af669323e
3
+ size 720