# All playlists go here except the target one
# Each child of json object is a playlist
{
{
"id": [1,2, ... xSongs],
"duration_ms": [1,2, ... xSongs],
"danceability": [1,2, ... xSongs],
...
},
{
"id": [1,2, ... ySongs],
"duration_ms": [1,2, ... ySongs],
"danceability": [1,2, ... ySongs],
...
}
}
decision_tree_classifier = tree.DecisionTreeClassifier()
...
# the 3 lines of magic
decision_tree_classifier.fit(songs_not_in_unsorted_playlist, playlists_for_sorted_songs)
incorrectly_sorted_songs = incorrectly_sorted_set.data
playlists_for_unsorted_songs = decision_tree_classifier.predict(incorrectly_sorted_songs)
# what is going on?
[song_id1, song_id2 ... song_idn] -> [playlist_id1, playlist_id2]