File size: 957 Bytes
5d0c63b
 
 
d97480c
5d0c63b
37c134b
5d0c63b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import pickle
import numpy as np
import joblib
# Load the trained model
model = joblib.load("random_forest_model.pkl")

# Prediction function
def predict_rainfall(temperature, humidity, cloud, sunshine, wind_direction):
    features = np.array([[temperature, humidity, cloud, sunshine, wind_direction]])
    prediction = model.predict(features)
    message = "yes Rain is Possibble" if prediction[0] == 1 else "No Rain is not Possibble"
    return message

# Gradio Interface
interface = gr.Interface(
    fn=predict_rainfall,
    inputs=[
        gr.Number(label="Temperature (°C)"),
        gr.Number(label="Humidity (%)"),
        gr.Number(label="Cloud (%)"),
        gr.Number(label="Sunshine (hours)"),
        gr.Number(label="Wind Direction (°)")
    ],
    outputs=gr.Text(label="Rain Prediction"),
    title="Rainfall Prediction App",
    description="Enter weather data to predict if rain is possible"
)

interface.launch()