Spotify uses a metric called valence to measure the happiness of a track. The metric itself, however, was not developed by Spotify. It was originally developed by Echo Nest, a company that was bought by Spotify in 2014. We don't know exactly how valence is calculated. Some details are given by a blog post, which you can find here:
Our task is to untangle the mystery behind valence and propose how this is derived.
Spotify offers the following information, relevant to our task:
Since spotify doesn't allow to share information downloaded through the API, the .cvs files need to be downloaded manually, if replication of the project is needed.