Closed sophryu99 closed 3 years ago
Features to train with
# Get Track info API
track_id = models.IntegerField(default=0)
artist_id = models.IntegerField(default=0)
year = models.IntegerField(default=0)
popularity = models.IntegerField(default=0)
release_date = models.IntegerField(default=0)
# Get audio_features API
acousticness = models.FloatField(default=0)
danceability = models.FloatField(default=0)
duration_ms = models.FloatField(default=0)
energy = models.FloatField(default=0)
instrumentalness = models.FloatField(default=0)
liveness = models.FloatField(default=0)
loudness = models.FloatField(default=0)
valence = models.FloatField(default=0)
speechiness = models.FloatField(default=0)
tempo = models.FloatField(default=0)
key = models.IntegerField(default=0)
mode = models.IntegerField(default=0)
Training Metrics
from sklearn.cluster import KMeans
from sklearn.preprocessing import StandardScaler
from sklearn.pipeline import Pipeline
from sklearn.decomposition import PCA
1. Get the average vector of the audio features for each tracks
Cosine distance function for two vectors u and v
# find the distance between two pairs of collections of points
from scipy.spatial.distance import cdist
2. Find the n-closest data points in the dataset to this average vector 3. Take these n-points and recommend the songs corresponding to them
Content-based recommendation algorithm
Input Data format