Iueleflaekkefar commited on
Commit
85c0cc5
·
verified ·
1 Parent(s): 395b05b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
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 neighbors found. Try a different k."]})
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 in feature matrix."
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 "Could not compute evaluation (no valid neighbors)."
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("# 🎧 Spotify Content-Based Recommender")
136
  gr.Markdown(
137
- f"This demo uses a subset of **{n_used}** tracks from the full dataset "
138
- "to keep the app responsive on free CPU."
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 (k)",
152
  )
153
- recommend_button = gr.Button("Recommend")
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
- "We evaluate the recommender on 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)")
 
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)")