File size: 840 Bytes
8f07d0e
491c0e0
f50f99c
 
df04160
 
f50f99c
 
df04160
f50f99c
df04160
 
491c0e0
f50f99c
df04160
f50f99c
df04160
e6cf2c9
df04160
f1a5823
f50f99c
df04160
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import streamlit as st
import joblib
import pandas as pd

# Load model and features
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.")

# Input form
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})")