Spaces:
Sleeping
Sleeping
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() |