A simple ML model to classify Spotify tracks using audio features.
Project description
spotifymoods
A simple ML model to classify Spotify tracks using audio features.
Installation
pip install spotifymoods
Usage
Train the model
import pandas as pd
from spotifymoods import train
# create a Pandas DataFrame from the file 'training_data.csv'
train_data = pd.read_csv('training_data.csv')
# save the trained model to the files 'trained_model.pkl' & 'scaled.pkl'
train(data=train_data, trained_output='trained.pkl', scaled_output='scaled.pkl')
Predict moods
import pandas as pd
from spotifymoods import predict
# create a Pandas DataFrame from the file 'test_data.csv'
test_data = pd.read_csv('test_data.csv')
# use the trained model from the files 'trained.pkl' & 'scaled.pkl', and return the results as DataFrame
result = predict(data=test_data, trained_path='trained.pkl', scaled_path='scaled.pkl')
# output the results to a .csv file
result.to_csv('result.csv', index=False)
CSV data examples
training_data.csv
energy,liveness,tempo,speechiness,acousticness,instrumentalness,danceability,duration_ms,loudness,valence,id,mood
0.549,0.22,130.749,0.0698,0.000798,0.00485,0.357,244573,-7.843,0.531,3kdMzXOcrDIdSWLdONHNK5,Energetic
0.975,0.16,129.022,0.0618,5.13e-05,0.713,0.594,205760,-3.21,0.899,3rFEKOClXOdNFO6fQGuQ9j,Energetic
test_data.csv
energy,liveness,tempo,speechiness,acousticness,instrumentalness,danceability,duration_ms,loudness,valence,id
0.549,0.22,130.749,0.0698,0.000798,0.00485,0.357,244573,-7.843,0.531,3kdMzXOcrDIdSWLdONHNK5
0.975,0.16,129.022,0.0618,5.13e-05,0.713,0.594,205760,-3.21,0.899,3rFEKOClXOdNFO6fQGuQ9j
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
spotifymoods-0.0.5.tar.gz
(3.3 kB
view hashes)
Built Distribution
Close
Hashes for spotifymoods-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0a0300f7c448edca88e2d5f2e3237dd26d95f6fcd6d83ede72223dd48fefaf8 |
|
MD5 | 591db7378c6e9069adee1a06ae03563c |
|
BLAKE2b-256 | 6904ac3286bdc2387f4ec58938d5a9a71d87dd6c8821d5f52abe44c83bba5c4b |