IbraahimLab's picture
Update app.py
d97480c verified
raw
history blame contribute delete
957 Bytes
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()