MonaHamid commited on
Commit
f315597
·
verified ·
1 Parent(s): a158a6a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from batch import run
3
+
4
+ def predict_duration(year, month):
5
+ try:
6
+ year = int(year)
7
+ month = int(month)
8
+ output_file, mean_duration = run(year, month)
9
+ return f" Done! Output saved to: {output_file}\n Mean predicted duration: {mean_duration:.2f} minutes"
10
+ except Exception as e:
11
+ return f" Error: {str(e)}"
12
+
13
+ iface = gr.Interface(
14
+ fn=predict_duration,
15
+ inputs=[
16
+ gr.Textbox(label="Year (e.g. 2023)"),
17
+ gr.Textbox(label="Month (e.g. 4 for April)")
18
+ ],
19
+ outputs="text",
20
+ title="NYC Taxi Duration Predictor",
21
+ description="Enter a year and month to predict ride durations using a trained ML model."
22
+ )
23
+
24
+ if __name__ == "__main__":
25
+ iface.launch()