project / app.py
KKKKrissy's picture
Upload 2 files
11bfa43 verified
import gradio as gr
import pandas as pd
import joblib
model = joblib.load("random_forest_regressor_model.pkl")
def predict_air_quality(pm25, pm10, so2, no2, co, o3, day_weather_condition, night_weather_condition):
input_data = pd.DataFrame([[pm25, pm10, so2, no2, co, o3, day_weather_condition, night_weather_condition]],
columns=['pm25', 'pm10', 'so2', 'no2', 'co', 'o3', 'day_weather_condition', 'night_weather_condition'])
prediction = model.predict(input_data)
return prediction[0]
iface = gr.Interface(
fn=predict_air_quality,
inputs=[
gr.Number(label="PM2.5"),
gr.Number(label="PM10"),
gr.Number(label="SO2"),
gr.Number(label="NO2"),
gr.Number(label="CO"),
gr.Number(label="O3"),
gr.Dropdown(choices=[1, 2, 3, 4, 5, 6, 7], label="Day Weather Condition"),
gr.Dropdown(choices=[1, 2, 3, 4, 5, 6, 7], label="Night Weather Condition")
],
outputs="number",
title="Air Quality Prediction",
description="Predict the air quality level based on the input parameters."
)
iface.launch()