File size: 1,158 Bytes
11bfa43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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()