RoTesla commited on
Commit
5e7ffb1
1 Parent(s): 57c9bce

adding gradio py

Browse files
Files changed (1) hide show
  1. mi_archivo_gradio.py +28 -0
mi_archivo_gradio.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pickle
3
+
4
+ # Cargar el modelo desde un archivo
5
+ with open('modelo_recomendacion.pkl', 'rb') as archivo:
6
+ model = pickle.load(archivo)
7
+
8
+ def get_predictions(userId, id):
9
+ predictions = model.predict(userId, id)
10
+
11
+ if predictions.est >= 4:
12
+ mensaje = "Muy recomendada"
13
+ elif predictions.est >= 3 and predictions.est < 4:
14
+ mensaje = "Recomendada"
15
+ else:
16
+ mensaje = f"No te la recomiendo ({predictions.est:.2f})"
17
+
18
+ return mensaje
19
+
20
+ inputs = [
21
+ gr.inputs.Textbox(label="User ID"),
22
+ gr.inputs.Textbox(label="ID"),
23
+ ]
24
+
25
+ output = gr.outputs.Textbox(label="Predicción")
26
+
27
+ iface = gr.Interface(fn=get_predictions, inputs=inputs, outputs=output, title="Predicción de recomendación de películas")
28
+ iface.launch(share=True)