Skip to main content

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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spotifymoods-0.0.5-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file spotifymoods-0.0.5.tar.gz.

File metadata

  • Download URL: spotifymoods-0.0.5.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for spotifymoods-0.0.5.tar.gz
Algorithm Hash digest
SHA256 6adb26dc748918489ac63df26688adc129e4f68aed601c4c1bfd724acea9fb1d
MD5 8682ce5a0d536a40e059655f3d205a35
BLAKE2b-256 809875a9e37093d0c8e7b4ad54e18c6bd05a22f311fca1c06e71eb5ea7a4ac02

See more details on using hashes here.

File details

Details for the file spotifymoods-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: spotifymoods-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for spotifymoods-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a0a0300f7c448edca88e2d5f2e3237dd26d95f6fcd6d83ede72223dd48fefaf8
MD5 591db7378c6e9069adee1a06ae03563c
BLAKE2b-256 6904ac3286bdc2387f4ec58938d5a9a71d87dd6c8821d5f52abe44c83bba5c4b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page