Popular 'Dance/House' or 'Salsa' Partyplaylist by RobLuk
  • AI Chat
  • Code
  • Report
  • Beta
    Spinner

    Which songs are most suitable for a dancing party?

    šŸ“– Background

    It's that vibrant time of year again - Summer has arrived (for those of us in the Northern Hemisphere at least)! There's an energy in the air that inspires us to get up and move. In sync with this exuberance, your company has decided to host a dance party to celebrate. And you, with your unique blend of creativity and analytical expertise, have been entrusted with the crucial task of curating a dance-themed playlist that will set the perfect mood for this electrifying night. The question then arises - How can you identify the songs that would make the attendees dance their hearts out? This is where your coding skills come into play.

    Executive Summary:

    Methodology:

    Data Exploration: The playlist curation process began with a thorough exploration of a diverse dataset containing over 125 genres of Spotify music tracks. Summary statistics were used to gain insights into audio features such as danceability, energy, loudness, tempo, and valence.

    Data Cleaning: Data quality was ensured by addressing issues like missing values and duplicates. Explicit content tracks were removed to make the playlist suitable for diverse audiences.

    Feature Selection: Key audio features like popularity, energy, loudness, tempo, and valence were selected for their potential influence on danceability.

    Machine Learning Model: A Linear Regression model was chosen to predict danceability, and it was trained, evaluated, and interpreted. Mean Squared Error (MSE) was used as the performance metric.

    Data Visualization: Various data visualizations, including scatterplots and countplots, were utilized to explore feature relationships and genre distributions.

    Playlist Curation: Playlists were curated for "Dance/House" and "Salsa" genres using specific criteria related to energy, tempo, valence, and more. Ethical considerations led to the removal of explicit content tracks.

    Conclusion: The process resulted in curated playlists tailored to the summer party's dance theme, ensuring an energetic and diverse selection of tracks.

    Future Recommendations: To enhance personalization, consider user surveys, real-time feedback, and collaborative playlist features. Diversify genres, use live DJs, and introduce themed sets and visual elements for an engaging experience. Incorporate crowdsourced playlists, showcase local talent, and gather post-event feedback for continuous improvement. This comprehensive approach balances data-driven insights with ethical considerations, ensuring an inclusive and enjoyable musical experience for diverse party attendees. The final playlist may vary based on individual preferences and party requirements.

    šŸ’¾ The Data

    You have assembled information on more than 125 genres of Spotify music tracks in a file called spotify.csv, with each genre containing approximately 1000 tracks. All tracks, from all time, have been taken into account without any time period limitations. However, the data collection was concluded in October 2022. Each row represents a track that has some audio features associated with it.

    ColumnDescription
    track_idThe Spotify ID number of the track.
    artistsNames of the artists who performed the track, separated by a ; if there's more than one.
    album_nameThe name of the album that includes the track.
    track_nameThe name of the track.
    popularityNumerical value ranges from 0 to 100, with 100 being the highest popularity. This is calculated based on the number of times the track has been played recently, with more recent plays contributing more to the score. Duplicate tracks are scored independently.
    duration_msThe length of the track, measured in milliseconds.
    explicitIndicates whether the track contains explicit lyrics. true means it does, false means it does not or it's unknown.
    danceabilityA score ranges between 0.0 and 1.0 that represents the track's suitability for dancing. This is calculated by algorithm and is determined by factors like tempo, rhythm stability, beat strength, and regularity.
    energyA score ranges between 0.0 and 1.0 indicating the track's intensity and activity level. Energetic tracks tend to be fast, loud, and noisy.
    keyThe key the track is in. Integers map to pitches using standard Pitch class notation. E.g.0 = C, 1 = Cā™Æ/Dā™­, 2 = D, and so on. If no key was detected, the value is -1.
    loudnessThe overall loudness, measured in decibels (dB).
    modeThe modality of a track, represented as 1 for major and 0 for minor.
    speechinessMeasures the amount of spoken words in a track. A value close to 1.0 denotes speech-based content, while 0.33 to 0.66 indicates a mix of speech and music like rap. Values below 0.33 are usually music and non-speech tracks.
    acousticnessA confidence measure ranges from 0.0 to 1.0, with 1.0 representing the highest confidence that the track is acoustic.
    instrumentalnessInstrumentalness estimates the likelihood of a track being instrumental. Non-lyrical sounds such as "ooh" and "aah" are considered instrumental, whereas rap or spoken word tracks are classified as "vocal". A value closer to 1.0 indicates a higher probability that the track lacks vocal content.
    livenessA measure of the probability that the track was performed live. Scores above 0.8 indicate a high likelihood of the track being live.
    valenceA score from 0.0 to 1.0 representing the track's positiveness. High scores suggest a more positive or happier track.
    tempoThe track's estimated tempo, measured in beats per minute (BPM).
    time_signatureAn estimate of the track's time signature (meter), which is a notational convention to specify how many beats are in each bar (or measure). The time signature ranges from 3 to 7 indicating time signatures of 3/4, to 7/4.
    track_genreThe genre of the track.

    Source (data has been modified)

    import pandas as pd
    import matplotlib.pyplot as plt
    import seaborn as sns
    
    # Set up Seaborn style
    sns.set(style="whitegrid")
    
    spotify = pd.read_csv('data/spotify.csv')
    spotify

    1. Feature Selection:

    1. Feature Selection:

    1.1 Dance-themed playlist

    Given your goal of curating a dance-themed playlist that will get attendees dancing and create an electrifying mood, the following audio features should be prioritized:

    Danceability: This should be your top priority. Danceability is a measure of how suitable a track is for dancing. Higher danceability scores indicate tracks that are more dance-friendly. Prioritize songs with high danceability to ensure that attendees will want to dance to them.

    Energy: Energy is crucial for maintaining an upbeat and lively atmosphere at your dance party. Tracks with high energy levels tend to be more engaging and are more likely to get people on the dance floor.

    Tempo: Tempo, measured in beats per minute (BPM), plays a significant role in dance music. Depending on the type of dance or mood you want to set, you may want to prioritize songs with a tempo that matches the desired style of dance. Faster tempos often encourage more energetic dancing.

    Valence: Valence represents the emotional tone of a track, with higher values indicating a more positive or happier mood. Prioritize songs with higher valence to ensure a positive and joyful atmosphere.

    These four features directly relate to the danceability and mood of the music, making them essential for creating a playlist that will get attendees dancing and set an electrifying mood.

    While other features like loudness, instrumentalness, and speechiness can also influence the overall vibe of the playlist, they can be considered secondary to the primary features listed above for your specific goal of a dance-themed playlist. However, we should still consider during the curation process to maintain variety and cater to different tastes within the dance music genre.

    Hidden code

    1.2 Audio Features:

    It's crucial to pay special attention to the audio features like 'danceability', 'energy', 'loudness', and 'tempo'. These features will be important for selecting dance-themed songs. 'Danceability' and 'energy' are particularly relevant.

    Hidden code

    1.3 Correlation:

    Danceability positively correlates with valence (0.4737) and has weak positive correlations with energy (0.1269) and loudness (0.2498). It weakly negatively correlates with tempo (-0.05598).

    Energy strongly correlates with loudness (0.7609) and has weak positive correlations with tempo (0.2457) and valence (0.2567).

    Loudness has a strong positive correlation with energy (0.7609) and a weak positive correlation with danceability (0.2498).

    Tempo has weak positive correlations with energy (0.2457) and valence (0.0754).

    Valence positively correlates with danceability (0.4737) and has weak positive correlations with energy (0.2567) and loudness (0.2753).

    Implications:

    These correlations offer guidance for selecting songs for a dance-themed playlist. Consider high danceability and valence for an energetic, positive atmosphere. Note that correlations do not imply causation, and other unmeasured factors may influence danceability and energy.

    Hidden code

    1.4 Statistics Summarize

    The provided statistics summarize attributes of a music tracks dataset with Explict = False:

    Popularity ranges from 0 to 100, with a mean of ~33.06. Track duration varies (mean ~230395 ms). Danceability ranges from 0 to 0.985 (mean ~0.5618). Energy varies (mean ~0.6363). Key spans 0 to 11. Loudness varies (mean ~-8.37 dB). Speechiness ranges from 0 to 0.963 (mean ~0.0746). Acousticness varies (mean ~0.3212). Instrumentalness spans 0 to 1 (mean ~0.1641). Liveness varies (mean ~0.2116). Valence ranges from 0 to 0.995 (mean ~0.4758). Tempo varies (mean ~122.32 BPM). Time signature spans 3 to 5 (mean ~3.92). These stats provide insights into the dataset's music track characteristics.

    popular_tracks = spotify[(spotify['popularity'] >= 0) & 
                             (spotify['explicit'] == False)].describe()
    popular_tracks

    2. Explore how danceability relates

    ā€Œ
    ā€Œ
    ā€Œ