-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
47 lines (40 loc) · 1.48 KB
/
Copy pathapp.py
File metadata and controls
47 lines (40 loc) · 1.48 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.utils import resample
from sklearn.model_selection import train_test_split, GridSearchCV, cross_val_score
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import classification_report, confusion_matrix, accuracy_score
import joblib
import streamlit as st
# Title
st.title("🌦️ Rainfall Prediction App")
st.write("Enter weather details to predict rain.")
# Load model using joblib
model = joblib.load("rainfall_prediction_model.pkl")
# User Inputs
pressure = st.number_input("Pressure (hPa)", value=1010.0)
dewpoint = st.number_input("Dew Point (°C)", value=14.0)
humidity = st.number_input("Humidity (%)", value=70)
cloud = st.number_input("Cloud Cover (%)", value=50)
sunshine = st.number_input("Sunshine (hours)", value=5.0)
winddirection = st.number_input("Wind Direction (°)", value=180.0)
windspeed = st.number_input("Wind Speed (km/h)", value=10.0)
# Make dataframe
input_df = pd.DataFrame([{
"pressure": pressure,
"dewpoint": dewpoint,
"humidity": humidity,
"cloud": cloud,
"sunshine": sunshine,
"winddirection": winddirection,
"windspeed": windspeed
}])
# Predict button
if st.button("Predict ☁️"):
prediction = model.predict(input_df)
if prediction[0] == 1:
st.error("🌧️ Rain is expected today.")
else:
st.success("☀️ No rain expected today.")