Last active
August 22, 2016 01:42
-
-
Save sjstebbins/fbffc23418a135e012c115bcc023e848 to your computer and use it in GitHub Desktop.
Muse-get seed_distances from phantom_average_track
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get seed_distances from phantom_average_track | |
seed_distances = [phantom_average_track.values()] + playlist_tracks_attributes | |
dist = DistanceMetric.get_metric('euclidean') | |
distances = dist.pairwise(seed_distances)[0] | |
seed_data['distances'] = distances[1:len(distances)] | |
# get attributes of the 5 closest tracks to the phantom_average_track | |
seed_indexes = seed_data['distances'].argsort()[:5] | |
seed_songs = [seed_data['song_ids'][i] for i in seed_indexes] | |
seed_artists = [seed_data['artist_ids'][i] for i in seed_indexes] | |
# get target attributes from phantom_average_track (roudn to two decimals) | |
target_energy = str(round(phantom_average_track['energy'],2)) | |
target_liveness = str(round(phantom_average_track['liveness'],2)) | |
target_tempo = str(round(phantom_average_track['tempo'],2)) | |
target_speechiness = str(round(phantom_average_track['speechiness'],2)) | |
target_acousticness = str(round(phantom_average_track['acousticness'],2)) | |
target_instrumentalness = str(round(phantom_average_track['instrumentalness'],2)) | |
target_danceability = str(round(phantom_average_track['danceability'],2)) | |
target_loudness = str(round(phantom_average_track['loudness'],2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment