Update app.py
Browse files
app.py
CHANGED
|
@@ -75,7 +75,7 @@ def recommend_tracks_ui(query_label: str, k: int):
|
|
| 75 |
})
|
| 76 |
|
| 77 |
if not rows:
|
| 78 |
-
return pd.DataFrame({"info": ["No
|
| 79 |
|
| 80 |
return pd.DataFrame(rows)
|
| 81 |
|
|
@@ -91,7 +91,7 @@ def evaluate_mean_similarity_ui(k: int, n_samples: int):
|
|
| 91 |
n_samples = int(n_samples)
|
| 92 |
n = features.shape[0]
|
| 93 |
if n == 0:
|
| 94 |
-
return "No tracks
|
| 95 |
|
| 96 |
n_samples = min(n_samples, n)
|
| 97 |
|
|
@@ -120,7 +120,7 @@ def evaluate_mean_similarity_ui(k: int, n_samples: int):
|
|
| 120 |
all_means.append(similarities.mean())
|
| 121 |
|
| 122 |
if not all_means:
|
| 123 |
-
return "
|
| 124 |
|
| 125 |
all_means = np.array(all_means)
|
| 126 |
mean_sim = float(all_means.mean())
|
|
@@ -132,10 +132,10 @@ def evaluate_mean_similarity_ui(k: int, n_samples: int):
|
|
| 132 |
)
|
| 133 |
|
| 134 |
with gr.Blocks(title="Spotify Content-Based Recommender (Subset)") as demo:
|
| 135 |
-
gr.Markdown("#
|
| 136 |
gr.Markdown(
|
| 137 |
-
f"
|
| 138 |
-
"to
|
| 139 |
)
|
| 140 |
|
| 141 |
with gr.Tab("Recommender"):
|
|
@@ -148,11 +148,11 @@ with gr.Blocks(title="Spotify Content-Based Recommender (Subset)") as demo:
|
|
| 148 |
maximum=10,
|
| 149 |
value=5,
|
| 150 |
step=1,
|
| 151 |
-
label="Number of recommendations
|
| 152 |
)
|
| 153 |
-
recommend_button = gr.Button("
|
| 154 |
rec_output = gr.Dataframe(
|
| 155 |
-
label="Recommended Tracks",
|
| 156 |
interactive=False
|
| 157 |
)
|
| 158 |
|
|
@@ -164,7 +164,7 @@ with gr.Blocks(title="Spotify Content-Based Recommender (Subset)") as demo:
|
|
| 164 |
|
| 165 |
with gr.Tab("Evaluation"):
|
| 166 |
gr.Markdown(
|
| 167 |
-
"
|
| 168 |
"between query tracks and their top-k neighbors."
|
| 169 |
)
|
| 170 |
k_eval = gr.Slider(1, 10, value=5, step=1, label="k (top-k neighbors)")
|
|
|
|
| 75 |
})
|
| 76 |
|
| 77 |
if not rows:
|
| 78 |
+
return pd.DataFrame({"info": ["No matches, either no matches or you have an unique taste my friend"]})
|
| 79 |
|
| 80 |
return pd.DataFrame(rows)
|
| 81 |
|
|
|
|
| 91 |
n_samples = int(n_samples)
|
| 92 |
n = features.shape[0]
|
| 93 |
if n == 0:
|
| 94 |
+
return "No tracks found"
|
| 95 |
|
| 96 |
n_samples = min(n_samples, n)
|
| 97 |
|
|
|
|
| 120 |
all_means.append(similarities.mean())
|
| 121 |
|
| 122 |
if not all_means:
|
| 123 |
+
return "evaluation failed, try again my friend"
|
| 124 |
|
| 125 |
all_means = np.array(all_means)
|
| 126 |
mean_sim = float(all_means.mean())
|
|
|
|
| 132 |
)
|
| 133 |
|
| 134 |
with gr.Blocks(title="Spotify Content-Based Recommender (Subset)") as demo:
|
| 135 |
+
gr.Markdown("# Music Recommender - now that what i call music")
|
| 136 |
gr.Markdown(
|
| 137 |
+
f"It only uses **{n_used}** tracks from the full dataset "
|
| 138 |
+
"to make sure all PC can handle it"
|
| 139 |
)
|
| 140 |
|
| 141 |
with gr.Tab("Recommender"):
|
|
|
|
| 148 |
maximum=10,
|
| 149 |
value=5,
|
| 150 |
step=1,
|
| 151 |
+
label="Number of recommendations",
|
| 152 |
)
|
| 153 |
+
recommend_button = gr.Button("Find recommends - find more music you grove")
|
| 154 |
rec_output = gr.Dataframe(
|
| 155 |
+
label="Recommended Tracks - that match your grove",
|
| 156 |
interactive=False
|
| 157 |
)
|
| 158 |
|
|
|
|
| 164 |
|
| 165 |
with gr.Tab("Evaluation"):
|
| 166 |
gr.Markdown(
|
| 167 |
+
"The recommender evaluates this subset using **mean cosine similarity** "
|
| 168 |
"between query tracks and their top-k neighbors."
|
| 169 |
)
|
| 170 |
k_eval = gr.Slider(1, 10, value=5, step=1, label="k (top-k neighbors)")
|