Vlytz commited on
Commit
f4c82c4
·
verified ·
1 Parent(s): 55f912f

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +75 -0
  2. regression_model.joblib +3 -0
  3. requiremets.txt +5 -0
app.py ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import joblib
3
+ import pandas as pd
4
+ import numpy as np
5
+
6
+ # Carga el modelo
7
+ model = joblib.load("regression_model.joblib")
8
+
9
+ def predecir(
10
+ vehicle_type,
11
+ pickup_location,
12
+ drop_location,
13
+ avg_vtat,
14
+ avg_ctat,
15
+ booking_value,
16
+ ride_distance,
17
+ driver_ratings,
18
+ customer_rating,
19
+ payment_method,
20
+ datetime,
21
+ hour_of_day,
22
+ day_of_week,
23
+ is_weekend,
24
+ is_rush_hour
25
+ ):
26
+ data = pd.DataFrame([{
27
+ "Vehicle Type": vehicle_type,
28
+ "Pickup Location": pickup_location,
29
+ "Drop Location": drop_location,
30
+ "Avg VTAT": avg_vtat,
31
+ "Avg CTAT": avg_ctat,
32
+ 'Booking Value': booking_value,
33
+ "Ride Distance": ride_distance,
34
+ "Driver Ratings": driver_ratings,
35
+ "Customer Rating": customer_rating,
36
+ "Payment Method": payment_method,
37
+ "Datetime": datetime,
38
+ "Hour_of_Day": hour_of_day,
39
+ "Day_of_Week": day_of_week,
40
+ "Is_Weekend": is_weekend,
41
+ "Is_Rush_Hour": is_rush_hour,
42
+ }])
43
+ pred = model.predict(data)[0]
44
+ return "🚫 Viaje Cancelado" if pred == 1 else "✅ Viaje Completado"
45
+
46
+ inputs = [
47
+ gr.Textbox(label="Vehicle Type"),
48
+ gr.Textbox(label="Pickup Location"),
49
+ gr.Textbox(label="Drop Location"),
50
+ gr.Number(label="Avg VTAT"),
51
+ gr.Number(label="Avg CTAT"),
52
+ gr.Number(label="Booking Value"),
53
+ gr.Number(label="Ride Distance"),
54
+ gr.Number(label="Driver Ratings"),
55
+ gr.Number(label="Customer Rating"),
56
+ gr.Textbox(label="Payment Method"),
57
+ gr.Textbox(label="Datetime (YYYY-MM-DD HH:MM:SS)"),
58
+ gr.Number(label="Hour_of_Day"),
59
+ gr.Textbox(label="Day_of_Week"),
60
+ gr.Checkbox(label="Is_Weekend"),
61
+ gr.Checkbox(label="Is_Rush_Hour")
62
+ ]
63
+
64
+ outputs = gr.Textbox(label="Resultado del modelo")
65
+
66
+ app = gr.Interface(
67
+ fn=predecir,
68
+ inputs=inputs,
69
+ outputs=outputs,
70
+ title="📊 Predicción de Viaje Cancelado",
71
+ description="Completa los datos para obtener la predicción del modelo.",
72
+ flagging_mode="never"
73
+ )
74
+
75
+ app.launch()
regression_model.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:261e8ee246a730debd4a6f95322f081ba9f2bb7c06f4c581b15427f0808e8af5
3
+ size 223109
requiremets.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ gradio
2
+ pandas
3
+ numpy
4
+ scikit-learn
5
+ joblib