DavidHosp commited on
Commit
09f6d5c
1 Parent(s): 868ad0f

upload app.py

Browse files
Files changed (1) hide show
  1. app.py +62 -0
app.py ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """Untitled34.ipynb
3
+
4
+ Automatically generated by Colaboratory.
5
+
6
+ Original file is located at
7
+ https://colab.research.google.com/drive/10XoO4F_D0n2dxdvDhQvdQWEzJKTEoQYF
8
+ """
9
+
10
+ !pip install gradio
11
+
12
+ import matplotlib.pyplot as plt
13
+ import io
14
+ from PIL import Image
15
+ import pickle
16
+ import pandas as pd
17
+ import gradio as gr
18
+
19
+ import gradio as gr
20
+ import pandas as pd
21
+ import joblib
22
+
23
+ # Cargar el modelo de pron贸stico
24
+ model = joblib.load('/content/modelo_rf.pkl')
25
+
26
+ # Definir las opciones para 'Borough' y 'Tipo_de_taxi'
27
+ borough_options = ['Bronx', 'Brooklyn', 'Manhattan', 'Staten Island']
28
+ taxi_options = ['yellow', 'green']
29
+
30
+ # Funci贸n para realizar las predicciones
31
+ def make_predictions(borough, taxi, years):
32
+ # Crear un DataFrame con las caracter铆sticas de entrada
33
+ df = pd.DataFrame({'borough': [borough], 'Tipo_de_taxi': [taxi]})
34
+
35
+ # Generar los a帽os de pron贸stico
36
+ years_range = pd.date_range(start='today', periods=years, freq='Y').year
37
+
38
+ # Realizar las predicciones para cada a帽o de pron贸stico
39
+ predictions = []
40
+ for year in years_range:
41
+ df['Date'] = pd.to_datetime(year, format='%Y')
42
+ prediction = model.predict(df)
43
+ predictions.append(prediction)
44
+
45
+ # Crear un DataFrame con los a帽os y las predicciones
46
+ result_df = pd.DataFrame({'Year': years_range, 'Prediction': predictions})
47
+
48
+ return result_df
49
+
50
+ # Interfaz de Gradio
51
+ iface = gr.Interface(
52
+ fn=make_predictions,
53
+ inputs=[
54
+ gr.inputs.Dropdown(choices=borough_options, label='Borough'),
55
+ gr.inputs.Dropdown(choices=taxi_options, label='Tipo_de_taxi'),
56
+ gr.inputs.Slider(minimum=1, maximum=10, default=5, label='Years')
57
+ ],
58
+ outputs=gr.outputs.Dataframe(headers=['Year', 'Prediction'])
59
+ )
60
+
61
+ # Ejecutar la interfaz de Gradio
62
+ iface.launch()