File size: 736 Bytes
f315597
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from batch import run

def predict_duration(year, month):
    try:
        year = int(year)
        month = int(month)
        output_file, mean_duration = run(year, month)
        return f" Done! Output saved to: {output_file}\n Mean predicted duration: {mean_duration:.2f} minutes"
    except Exception as e:
        return f" Error: {str(e)}"

iface = gr.Interface(
    fn=predict_duration,
    inputs=[
        gr.Textbox(label="Year (e.g. 2023)"),
        gr.Textbox(label="Month (e.g. 4 for April)")
    ],
    outputs="text",
    title="NYC Taxi Duration Predictor",
    description="Enter a year and month to predict ride durations using a trained ML model."
)

if __name__ == "__main__":
    iface.launch()