Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import pandas as pd | |
| import pickle | |
| # Load the saved model | |
| with open('weather_classifier_model.pkl', 'rb') as file: | |
| loaded_model = pickle.load(file) | |
| # Streamlit app | |
| st.title(":red[🌦️ Weather Prediction App]") | |
| # Input features | |
| temperature = st.number_input("Temperature (°C)", min_value=-50.0, max_value=50.0, step=0.1) | |
| humidity = st.number_input("Humidity (%)", min_value=0.0, max_value=100.0, step=0.1) | |
| wind_speed = st.number_input("Wind Speed (km/h)",min_value=0, max_value=150, value=10) | |
| cloud_cover = st.selectbox("Cloud Cover", ['partly cloudy', 'clear', 'overcast', 'cloudy']) | |
| precipitation = st.number_input("Precipitation (%)",min_value=0, max_value=100, value=10) | |
| uv_index = st.number_input("UV Index", min_value=0, max_value=15, value=5) | |
| visibility = st.number_input("Visibility (km)",min_value=0, max_value=50, value=10) | |
| season = st.selectbox("Season", ['Winter', 'Spring', 'Summer', 'Autumn']) # Updated season options | |
| location = st.selectbox("Location", ["inland", "mountain", "coastal"]) | |
| # Create input DataFrame | |
| input_data = pd.DataFrame({ | |
| "Temperature": [temperature], | |
| "Humidity": [humidity], | |
| "Wind Speed": [wind_speed], | |
| "Cloud Cover": [cloud_cover], | |
| "Precipitation (%)": [precipitation], | |
| "UV Index": [uv_index], | |
| "Visibility (km)": [visibility], | |
| "Season": [season], | |
| "Location": [location] | |
| }) | |
| # Make prediction | |
| if st.button(":blue[Predict]"): | |
| prediction = loaded_model.predict(input_data)[0] | |
| st.success(f"Predicted Weather Type: {prediction}") |