File size: 1,000 Bytes
8042424
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 random
import json

# Load precomputed results
with open("precomputed_results_recsys_steam.json", "r") as f:
    precomputed_results = json.load(f)

def gradio_wrapper():
    # Randomly select a user ID from precomputed results
    random_user_id = random.choice(list(precomputed_results.keys()))
    actual_games = precomputed_results[random_user_id]['actual_games']
    predicted_games = precomputed_results[random_user_id]['predicted_games']

    return random_user_id, ", ".join(actual_games), ", ".join(predicted_games)

# Create custom output components with labels
output1 = gr.outputs.Textbox(label="Making Predictions for Random User:")
output2 = gr.outputs.Textbox(label="Actual Top 10 games:")
output3 = gr.outputs.Textbox(label="Predicted / Recommended Top 10 Games:")

# Gradio interface
iface = gr.Interface(
    fn=gradio_wrapper, 
    inputs=[],  # No inputs in this case
    outputs=[output1, output2, output3]  # Custom output components
)

iface.launch()