| import streamlit as st |
| import joblib |
| import pandas as pd |
|
|
| |
| model = joblib.load("src/final_model.pkl") |
| features = joblib.load("src/model_features.pkl") |
|
|
| st.set_page_config(page_title="Rainfall Prediction", layout="centered") |
|
|
| st.title("🌧️ Rainfall Prediction App") |
| st.write("Predict whether it will rain based on meteorological data.") |
|
|
| |
| user_input = {} |
| for feature in features: |
| user_input[feature] = st.number_input(f"{feature}", value=0.0) |
|
|
| input_df = pd.DataFrame([user_input]) |
|
|
| if st.button("Predict"): |
| prediction = model.predict(input_df)[0] |
| probability = model.predict_proba(input_df)[0][1] |
|
|
| if prediction == 1: |
| st.error(f"🌧️ Rain Expected (Probability: {probability:.2f})") |
| else: |
| st.success(f"☀️ No Rain Expected (Probability: {probability:.2f})") |