File size: 776 Bytes
5e7ffb1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
27
28
29
import gradio as gr
import pickle

# Cargar el modelo desde un archivo
with open('modelo_recomendacion.pkl', 'rb') as archivo:
    model = pickle.load(archivo)

def get_predictions(userId, id):
    predictions = model.predict(userId, id)

    if predictions.est >= 4:
        mensaje = "Muy recomendada"
    elif predictions.est >= 3 and predictions.est < 4:
        mensaje = "Recomendada"
    else:
        mensaje = f"No te la recomiendo ({predictions.est:.2f})"

    return mensaje

inputs = [
    gr.inputs.Textbox(label="User ID"),
    gr.inputs.Textbox(label="ID"),
]

output = gr.outputs.Textbox(label="Predicci贸n")

iface = gr.Interface(fn=get_predictions, inputs=inputs, outputs=output, title="Predicci贸n de recomendaci贸n de pel铆culas")
iface.launch(share=True)