Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,52 +1,42 @@
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
-
import pickle
|
| 3 |
-
import numpy as np
|
| 4 |
import pandas as pd
|
| 5 |
-
import
|
| 6 |
-
|
| 7 |
-
with open("weather_classification_model.pkl", "rb") as model_file:
|
| 8 |
-
model = pickle.load(model_file)
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
with open("label_encoder.pkl", "rb") as encoder_file:
|
| 12 |
-
label_encoder = pickle.load(encoder_file)
|
| 13 |
-
|
| 14 |
-
|
| 15 |
|
|
|
|
|
|
|
|
|
|
| 16 |
|
|
|
|
| 17 |
st.title("🌦️ Weather Prediction App")
|
| 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 |
-
prediction_numeric = model.predict(input_data_scaled)[0]
|
| 49 |
-
predicted_label = label_encoder.inverse_transform([prediction_numeric])[0]
|
| 50 |
-
|
| 51 |
-
st.success(f"🌤️ Predicted Weather Type: **{predicted_label}**")
|
| 52 |
-
|
|
|
|
| 1 |
+
!pip install streamlit
|
| 2 |
+
|
| 3 |
import streamlit as st
|
|
|
|
|
|
|
| 4 |
import pandas as pd
|
| 5 |
+
import pickle
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
# Load the saved model
|
| 8 |
+
with open('weather_classifier_model.pkl', 'rb') as file:
|
| 9 |
+
loaded_model = pickle.load(file)
|
| 10 |
|
| 11 |
+
# Streamlit app
|
| 12 |
st.title("🌦️ Weather Prediction App")
|
| 13 |
|
| 14 |
+
# Input features
|
| 15 |
+
temperature = st.number_input("Temperature (°C)")
|
| 16 |
+
humidity = st.number_input("Humidity (%)")
|
| 17 |
+
wind_speed = st.number_input("Wind Speed (km/h)")
|
| 18 |
+
cloud_cover = st.selectbox("Cloud Cover", ["Clear", "Scattered Clouds", "Partly Cloudy", "Mostly Cloudy", "Overcast"])
|
| 19 |
+
precipitation = st.number_input("Precipitation (%)")
|
| 20 |
+
uv_index = st.number_input("UV Index")
|
| 21 |
+
visibility = st.number_input("Visibility (km)")
|
| 22 |
+
season = st.selectbox("Season", ["Spring", "Summer", "Autumn", "Winter"])
|
| 23 |
+
location = st.selectbox("Location", ["Sydney", "Melbourne", "Brisbane", "Perth", "Adelaide", "Canberra", "Darwin", "Hobart"]) # Update with your locations
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
# Create input DataFrame
|
| 27 |
+
input_data = pd.DataFrame({
|
| 28 |
+
"Temperature": [temperature],
|
| 29 |
+
"Humidity": [humidity],
|
| 30 |
+
"Wind Speed": [wind_speed],
|
| 31 |
+
"Cloud Cover": [cloud_cover],
|
| 32 |
+
"Precipitation (%)": [precipitation],
|
| 33 |
+
"UV Index": [uv_index],
|
| 34 |
+
"Visibility (km)": [visibility],
|
| 35 |
+
"Season": [season],
|
| 36 |
+
"Location": [location]
|
| 37 |
+
})
|
| 38 |
+
|
| 39 |
+
# Make prediction
|
| 40 |
+
if st.button("Predict"):
|
| 41 |
+
prediction = loaded_model.predict(input_data)[0]
|
| 42 |
+
st.success(f"Predicted Weather Type: {prediction}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|