Spaces:
Runtime error
Runtime error
From Metacritic score to positive reviews
Browse files
app.py
CHANGED
|
@@ -93,7 +93,7 @@ def get_recommendations(game_name, data, feature_vectors):
|
|
| 93 |
|
| 94 |
|
| 95 |
# Gradio interface function
|
| 96 |
-
def recommend_games(game_name, max_age, max_price,
|
| 97 |
data = load_data()
|
| 98 |
if data is None:
|
| 99 |
return "Failed to load data. Please check the data file."
|
|
@@ -102,7 +102,7 @@ def recommend_games(game_name, max_age, max_price, min_metacritic):
|
|
| 102 |
data = data[
|
| 103 |
(data['required_age'] <= max_age) &
|
| 104 |
(data['price'] <= max_price) &
|
| 105 |
-
(
|
| 106 |
].reset_index(drop=True)
|
| 107 |
|
| 108 |
if data.empty:
|
|
@@ -112,6 +112,7 @@ def recommend_games(game_name, max_age, max_price, min_metacritic):
|
|
| 112 |
recommendations_html = get_recommendations(game_name, data, feature_vectors)
|
| 113 |
|
| 114 |
return recommendations_html
|
|
|
|
| 115 |
|
| 116 |
# Format the output for Gradio
|
| 117 |
result_texts = []
|
|
@@ -135,7 +136,7 @@ def recommend_games(game_name, max_age, max_price, min_metacritic):
|
|
| 135 |
# Create the Gradio interface
|
| 136 |
with gr.Blocks(title="Steam Game Recommender") as demo:
|
| 137 |
gr.Markdown("#Steam Game Recommender")
|
| 138 |
-
gr.Markdown("Enter a game you like and
|
| 139 |
|
| 140 |
with gr.Row():
|
| 141 |
input_text = gr.Textbox(label="Favorite Game")
|
|
@@ -143,7 +144,7 @@ with gr.Blocks(title="Steam Game Recommender") as demo:
|
|
| 143 |
with gr.Row():
|
| 144 |
max_age_slider = gr.Slider(0, 21, value=17, label="Max Age Rating (Avoid Adult Games)")
|
| 145 |
max_price_slider = gr.Slider(0.0, 100.0, value=60.0, step=0.5, label="Maximum Price ($)")
|
| 146 |
-
|
| 147 |
|
| 148 |
with gr.Row():
|
| 149 |
submit_btn = gr.Button("Get Recommendations")
|
|
@@ -153,12 +154,13 @@ with gr.Blocks(title="Steam Game Recommender") as demo:
|
|
| 153 |
|
| 154 |
submit_btn.click(
|
| 155 |
fn=recommend_games,
|
| 156 |
-
inputs=[input_text, max_age_slider, max_price_slider,
|
| 157 |
outputs=output_text
|
| 158 |
)
|
| 159 |
|
| 160 |
|
| 161 |
|
|
|
|
| 162 |
# Launch the app
|
| 163 |
if __name__ == "__main__":
|
| 164 |
demo.launch()
|
|
|
|
| 93 |
|
| 94 |
|
| 95 |
# Gradio interface function
|
| 96 |
+
def recommend_games(game_name, max_age, max_price, min_positive_reviews):
|
| 97 |
data = load_data()
|
| 98 |
if data is None:
|
| 99 |
return "Failed to load data. Please check the data file."
|
|
|
|
| 102 |
data = data[
|
| 103 |
(data['required_age'] <= max_age) &
|
| 104 |
(data['price'] <= max_price) &
|
| 105 |
+
(data['positive'].fillna(0) >= min_positive_reviews)
|
| 106 |
].reset_index(drop=True)
|
| 107 |
|
| 108 |
if data.empty:
|
|
|
|
| 112 |
recommendations_html = get_recommendations(game_name, data, feature_vectors)
|
| 113 |
|
| 114 |
return recommendations_html
|
| 115 |
+
|
| 116 |
|
| 117 |
# Format the output for Gradio
|
| 118 |
result_texts = []
|
|
|
|
| 136 |
# Create the Gradio interface
|
| 137 |
with gr.Blocks(title="Steam Game Recommender") as demo:
|
| 138 |
gr.Markdown("#Steam Game Recommender")
|
| 139 |
+
gr.Markdown("Enter a game you like and set filters to improve suggestions.")
|
| 140 |
|
| 141 |
with gr.Row():
|
| 142 |
input_text = gr.Textbox(label="Favorite Game")
|
|
|
|
| 144 |
with gr.Row():
|
| 145 |
max_age_slider = gr.Slider(0, 21, value=17, label="Max Age Rating (Avoid Adult Games)")
|
| 146 |
max_price_slider = gr.Slider(0.0, 100.0, value=60.0, step=0.5, label="Maximum Price ($)")
|
| 147 |
+
min_positive_slider = gr.Slider(0, 100000, value=500, step=100, label="Minimum Positive Reviews")
|
| 148 |
|
| 149 |
with gr.Row():
|
| 150 |
submit_btn = gr.Button("Get Recommendations")
|
|
|
|
| 154 |
|
| 155 |
submit_btn.click(
|
| 156 |
fn=recommend_games,
|
| 157 |
+
inputs=[input_text, max_age_slider, max_price_slider, min_positive_slider],
|
| 158 |
outputs=output_text
|
| 159 |
)
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
+
|
| 164 |
# Launch the app
|
| 165 |
if __name__ == "__main__":
|
| 166 |
demo.launch()
|