Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -34,13 +34,17 @@ def hybrid_recommendation(song_index):
|
|
34 |
predicted_emotion = emotion_model.predict(padded_sequence).flatten()
|
35 |
|
36 |
# Preprocess for KNN
|
37 |
-
audio_features_knn =
|
38 |
'acousticness', 'instrumentalness', 'liveness', 'valence', 'tempo',
|
39 |
'duration_ms', 'time_signature']].values.reshape(1, -1)
|
40 |
-
mood_cats =
|
41 |
mood_cats_df = pd.DataFrame(mood_cats)
|
42 |
audio_features_scaled_knn = scaler_knn.fit_transform(audio_features_knn)
|
43 |
-
|
|
|
|
|
|
|
|
|
44 |
|
45 |
# Predict using the KNN model
|
46 |
knn_recommendations = knn_model.kneighbors(combined_features, n_neighbors=5, return_distance=False)[0]
|
|
|
34 |
predicted_emotion = emotion_model.predict(padded_sequence).flatten()
|
35 |
|
36 |
# Preprocess for KNN
|
37 |
+
audio_features_knn = df[['danceability', 'energy', 'key', 'loudness', 'mode', 'speechiness',
|
38 |
'acousticness', 'instrumentalness', 'liveness', 'valence', 'tempo',
|
39 |
'duration_ms', 'time_signature']].values.reshape(1, -1)
|
40 |
+
mood_cats = df[['mood_cats']]
|
41 |
mood_cats_df = pd.DataFrame(mood_cats)
|
42 |
audio_features_scaled_knn = scaler_knn.fit_transform(audio_features_knn)
|
43 |
+
|
44 |
+
audio_features_df = pd.DataFrame(audio_features_scaled_knn, columns=audio_features_knn.columns)
|
45 |
+
# Combine mood and audio features
|
46 |
+
combined_features = pd.concat([mood_cats_df, audio_features_df], axis=1)
|
47 |
+
#combined_features = pd.concat([mood_cats_df, pd.DataFrame(audio_features_scaled_knn, columns=audio_features_knn.columns)], axis=1)
|
48 |
|
49 |
# Predict using the KNN model
|
50 |
knn_recommendations = knn_model.kneighbors(combined_features, n_neighbors=5, return_distance=False)[0]
|