Spaces:
Sleeping
Sleeping
Commit
·
4d482a6
1
Parent(s):
bdb2363
added more models
Browse files- classification_report.png → DTCclassification_report.png +0 -0
- weather_model.pkl → DTCweather_model.pkl +0 -0
- DTCweather_predictions.png +0 -0
- KNNclassification_report.png +0 -0
- KNNweather_model.pkl +3 -0
- KNNweather_predictions.png +0 -0
- RFCclassification_report.png +0 -0
- RFCweather_model.pkl +3 -0
- RFCweather_predictions.png +0 -0
- app.py +58 -26
- main.ipynb +0 -0
- weather_predictions.png +0 -0
classification_report.png → DTCclassification_report.png
RENAMED
File without changes
|
weather_model.pkl → DTCweather_model.pkl
RENAMED
File without changes
|
DTCweather_predictions.png
ADDED
![]() |
KNNclassification_report.png
ADDED
![]() |
KNNweather_model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:27f26cb908527f8403b1b9f70e4bceb9f9d2f6f598346d26a8bfaea87bab5414
|
3 |
+
size 100934
|
KNNweather_predictions.png
ADDED
![]() |
RFCclassification_report.png
ADDED
![]() |
RFCweather_model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a6f7ead76bce26373973a749b634eaa30b31d088e8e117f1e92205b89f01186f
|
3 |
+
size 4201905
|
RFCweather_predictions.png
ADDED
![]() |
app.py
CHANGED
@@ -1,58 +1,90 @@
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
-
import joblib
|
4 |
-
|
5 |
-
# LOAD THE MODEL
|
6 |
-
model = joblib.load("weather_model.pkl") # Ensure the model is saved as 'weather_model.pkl'
|
7 |
|
8 |
# MAPPING THE CLASSES
|
9 |
weather_mapping = {"rain": 0, "sun": 1, "fog": 2, "drizzle": 3, "snow": 4}
|
10 |
reverse_mapping = {v: k for k, v in weather_mapping.items()} # Reverse mapping
|
11 |
|
12 |
-
#
|
13 |
feature_columns = ["precipitation", "temp_max", "temp_min", "wind"]
|
14 |
|
15 |
# STREAMLIT UI
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
app, model_eval = st.tabs(["Application", "Model Evaluation"])
|
17 |
-
|
|
|
18 |
with app:
|
19 |
st.title("🌦️ Weather Prediction App")
|
20 |
-
st.write("
|
21 |
|
22 |
-
# User
|
23 |
precipitation = st.number_input("Precipitation (mm)", min_value=0.0, max_value=100.0, step=0.1)
|
24 |
-
temp_max = st.number_input("Max Temperature (°C)", min_value=-
|
25 |
-
temp_min = st.number_input("Min Temperature (°C)", min_value=-
|
26 |
wind = st.number_input("Wind Speed (km/h)", min_value=0.0, max_value=100.0, step=0.1)
|
27 |
|
28 |
if st.button("Predict Weather"):
|
29 |
input_data = pd.DataFrame([[precipitation, temp_max, temp_min, wind]], columns=feature_columns)
|
30 |
|
31 |
-
|
32 |
-
prediction_num = model.predict(input_data)[0]
|
33 |
-
|
34 |
prediction_label = reverse_mapping.get(prediction_num, "Unknown")
|
35 |
|
36 |
st.success(f"🌤️ Predicted Weather: **{prediction_label.capitalize()}**")
|
37 |
|
|
|
38 |
with model_eval:
|
|
|
|
|
|
|
39 |
|
40 |
-
st.header("Model Evaluation")
|
41 |
-
st.write("The Weather Prediction model was trained in order to determine the type of weather based on weather conditions. The dataset was taken from kaggle.")
|
42 |
-
st.write("dataset by Dataset by dataset by ANANTH R. Link to the dataset: https://www.kaggle.com/datasets/ananthr1/weather-prediction")
|
43 |
-
|
44 |
# CORRELATION MATRIX
|
45 |
-
st.
|
46 |
-
st.write("
|
47 |
st.image("correlation_matrix.png")
|
48 |
|
49 |
# WEATHER PREDICTION
|
50 |
-
st.
|
51 |
-
st.write("
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
-
|
56 |
-
st.
|
57 |
-
st.write("The image below represents the Accuracy, F1 score and the classification report of the model")
|
58 |
-
st.image("classification_report.png")
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
+
import joblib
|
|
|
|
|
|
|
4 |
|
5 |
# MAPPING THE CLASSES
|
6 |
weather_mapping = {"rain": 0, "sun": 1, "fog": 2, "drizzle": 3, "snow": 4}
|
7 |
reverse_mapping = {v: k for k, v in weather_mapping.items()} # Reverse mapping
|
8 |
|
9 |
+
# FEATURE COLUMNS
|
10 |
feature_columns = ["precipitation", "temp_max", "temp_min", "wind"]
|
11 |
|
12 |
# STREAMLIT UI
|
13 |
+
st.sidebar.title("🔍 Select Model")
|
14 |
+
model_choice = st.sidebar.radio("Choose a model:",
|
15 |
+
["Decision Tree (DTC)", "K-Nearest Neighbors (KNN)", "Random Forest (RFC)"])
|
16 |
+
|
17 |
+
# Load the chosen model
|
18 |
+
model_filename = {
|
19 |
+
"Decision Tree (DTC)": "DTCweather_model.pkl",
|
20 |
+
"K-Nearest Neighbors (KNN)": "KNNweather_model.pkl",
|
21 |
+
"Random Forest (RFC)": "RFCweather_model.pkl"
|
22 |
+
}
|
23 |
+
|
24 |
+
model = joblib.load(model_filename[model_choice])
|
25 |
+
|
26 |
+
# STREAMLIT TABS
|
27 |
app, model_eval = st.tabs(["Application", "Model Evaluation"])
|
28 |
+
|
29 |
+
# STREAMLIT APP - TAB 1
|
30 |
with app:
|
31 |
st.title("🌦️ Weather Prediction App")
|
32 |
+
st.write(f"Using **{model_choice}**, enter weather conditions, and the model will predict the weather category!")
|
33 |
|
34 |
+
# User Inputs
|
35 |
precipitation = st.number_input("Precipitation (mm)", min_value=0.0, max_value=100.0, step=0.1)
|
36 |
+
temp_max = st.number_input("Max Temperature (°C)", min_value=-20.0, max_value=50.0, step=0.1)
|
37 |
+
temp_min = st.number_input("Min Temperature (°C)", min_value=-20.0, max_value=50.0, step=0.1)
|
38 |
wind = st.number_input("Wind Speed (km/h)", min_value=0.0, max_value=100.0, step=0.1)
|
39 |
|
40 |
if st.button("Predict Weather"):
|
41 |
input_data = pd.DataFrame([[precipitation, temp_max, temp_min, wind]], columns=feature_columns)
|
42 |
|
43 |
+
# Predict
|
44 |
+
prediction_num = model.predict(input_data)[0]
|
|
|
45 |
prediction_label = reverse_mapping.get(prediction_num, "Unknown")
|
46 |
|
47 |
st.success(f"🌤️ Predicted Weather: **{prediction_label.capitalize()}**")
|
48 |
|
49 |
+
# MODEL EVALUATION - TAB 2
|
50 |
with model_eval:
|
51 |
+
st.header("📊 Model Evaluation")
|
52 |
+
st.write("The Weather Prediction models were trained to classify weather types based on conditions. The dataset was sourced from Kaggle.")
|
53 |
+
st.write("Dataset by **ANANTH R**. [Link to dataset](https://www.kaggle.com/datasets/ananthr1/weather-prediction)")
|
54 |
|
|
|
|
|
|
|
|
|
55 |
# CORRELATION MATRIX
|
56 |
+
st.subheader("📌 Correlation Matrix")
|
57 |
+
st.write("This matrix shows the relationships between features.")
|
58 |
st.image("correlation_matrix.png")
|
59 |
|
60 |
# WEATHER PREDICTION
|
61 |
+
st.subheader("📌 Weather Prediction Results")
|
62 |
+
st.write("Comparison of actual vs predicted weather conditions.")
|
63 |
+
|
64 |
+
st.header("Decision Tree Classifier Weather Predictions")
|
65 |
+
st.image("DTCweather_predictions.png")
|
66 |
+
|
67 |
+
st.header("K Nearest Neighbor Weather Predictions")
|
68 |
+
st.image("KNNweather_predictions.png")
|
69 |
+
|
70 |
+
st.header("Random Forest Classifier Weather Predictions")
|
71 |
+
st.image("RFCweather_predictions.png")
|
72 |
|
73 |
+
# EVALUATION METRICS
|
74 |
+
st.subheader("📌 Evaluation Metrics")
|
75 |
+
st.write("Accuracy, F1 score, and the classification report of the models.")
|
76 |
+
|
77 |
+
st.header("Decision Tree Classifier Evaluation Metrics")
|
78 |
+
st.write("The image below represents the **Accuracy, F1 score, and classification report** of the Decision Tree Classifier model.")
|
79 |
+
st.image("DTCclassification_report.png")
|
80 |
+
|
81 |
+
st.header("K Nearest Neighbor Evaluation Metrics")
|
82 |
+
st.write("The image below represents the **Accuracy, F1 score, and classification report** of the K Nearest Neighbor model.")
|
83 |
+
st.image("KNNclassification_report.png")
|
84 |
+
|
85 |
+
st.header("Random Forest Classifier Metrics")
|
86 |
+
st.write("The image below represents the **Accuracy, F1 score, and classification report** of the Random Forest Classifier model.")
|
87 |
+
st.image("RFCclassification_report.png")
|
88 |
|
89 |
+
st.header("Comparison")
|
90 |
+
st.write("Based on the evaluation metrics, we can assume that out of the three classification algorithms chosen, Ramdom Forest Classifier performs the best using this dataset")
|
|
|
|
main.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
weather_predictions.png
DELETED
Binary file (28.4 kB)
|
|