Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import pickle
|
3 |
+
import numpy as np
|
4 |
+
|
5 |
+
# Load the trained model
|
6 |
+
with open("random_forest_model.pkl", "rb") as file:
|
7 |
+
model = pickle.load(file)
|
8 |
+
|
9 |
+
# Prediction function
|
10 |
+
def predict_rainfall(temperature, humidity, cloud, sunshine, wind_direction):
|
11 |
+
features = np.array([[temperature, humidity, cloud, sunshine, wind_direction]])
|
12 |
+
prediction = model.predict(features)
|
13 |
+
message = "yes Rain is Possibble" if prediction[0] == 1 else "No Rain is not Possibble"
|
14 |
+
return message
|
15 |
+
|
16 |
+
# Gradio Interface
|
17 |
+
interface = gr.Interface(
|
18 |
+
fn=predict_rainfall,
|
19 |
+
inputs=[
|
20 |
+
gr.Number(label="Temperature (°C)"),
|
21 |
+
gr.Number(label="Humidity (%)"),
|
22 |
+
gr.Number(label="Cloud (%)"),
|
23 |
+
gr.Number(label="Sunshine (hours)"),
|
24 |
+
gr.Number(label="Wind Direction (°)")
|
25 |
+
],
|
26 |
+
outputs=gr.Text(label="Rain Prediction"),
|
27 |
+
title="Rainfall Prediction App",
|
28 |
+
description="Enter weather data to predict if rain is possible"
|
29 |
+
)
|
30 |
+
|
31 |
+
interface.launch()
|