Parker Moesta commited on
Commit
8042424
·
1 Parent(s): b5bf431

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import random
3
+ import json
4
+
5
+ # Load precomputed results
6
+ with open("precomputed_results_recsys_steam.json", "r") as f:
7
+ precomputed_results = json.load(f)
8
+
9
+ def gradio_wrapper():
10
+ # Randomly select a user ID from precomputed results
11
+ random_user_id = random.choice(list(precomputed_results.keys()))
12
+ actual_games = precomputed_results[random_user_id]['actual_games']
13
+ predicted_games = precomputed_results[random_user_id]['predicted_games']
14
+
15
+ return random_user_id, ", ".join(actual_games), ", ".join(predicted_games)
16
+
17
+ # Create custom output components with labels
18
+ output1 = gr.outputs.Textbox(label="Making Predictions for Random User:")
19
+ output2 = gr.outputs.Textbox(label="Actual Top 10 games:")
20
+ output3 = gr.outputs.Textbox(label="Predicted / Recommended Top 10 Games:")
21
+
22
+ # Gradio interface
23
+ iface = gr.Interface(
24
+ fn=gradio_wrapper,
25
+ inputs=[], # No inputs in this case
26
+ outputs=[output1, output2, output3] # Custom output components
27
+ )
28
+
29
+ iface.launch()