Example of Logistic Regression¶
import altair as alt
import numpy as np
import pandas as pd
from pandas.api.types import is_numeric_dtype
pd.set_option('display.float_format', lambda x: '%.3f' % x)
from sklearn.preprocessing import StandardScaler
rng = np.random.default_rng()
df = pd.read_csv("../data/spotify_dataset.csv", na_values = " ")
df["Streams"] = pd.to_numeric(df["Streams"].map(lambda s: s.replace(",","")))
df = df[df.notna().all(axis=1)].copy()
numeric_cols = [c for c in df.columns if is_numeric_dtype(df[c])]
scaler = StandardScaler()
scaler.fit(df[numeric_cols])
df[numeric_cols] = scaler.transform(df[numeric_cols])
df["Genre"] = df["Genre"].map(eval)
df
Index | Highest Charting Position | Number of Times Charted | Week of Highest Charting | Song Name | Streams | Artist | Artist Followers | Song ID | Genre | ... | Danceability | Energy | Loudness | Speechiness | Acousticness | Liveness | Tempo | Duration (ms) | Valence | Chord | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | -1.731 | -1.494 | -0.164 | 2021-07-23--2021-07-30 | Beggin' | 12.535 | Måneskin | -0.680 | 3Wrjm47oTz2sjIgck11l5e | [indie rock italiano, italian pop] | ... | 0.169 | 1.031 | 0.614 | -0.664 | -0.486 | 1.234 | 0.378 | 0.289 | 0.327 | B |
1 | -1.729 | -1.477 | -0.469 | 2021-07-23--2021-07-30 | STAY (with Justin Bieber) | 12.124 | The Kid LAROI | -0.749 | 5HCyWlXZPP0y6Gqq8TgA20 | [australian hip hop] | ... | -0.695 | 0.808 | 0.345 | -0.683 | -0.841 | -0.543 | 1.593 | -1.191 | -0.162 | C#/Db |
2 | -1.727 | -1.494 | 0.019 | 2021-06-25--2021-07-02 | good 4 u | 10.024 | Olivia Rodrigo | -0.507 | 4ZtFanR9U6ndgddUvNcjcG | [pop] | ... | -0.892 | 0.189 | 0.520 | 0.275 | 0.345 | -0.669 | 1.491 | -0.420 | 0.763 | A |
3 | -1.725 | -1.460 | -0.347 | 2021-07-02--2021-07-09 | Bad Habits | 9.324 | Ed Sheeran | 4.114 | 6PQ88X9TkUIAUIZJHW2upE | [pop, uk pop] | ... | 0.829 | 1.631 | 1.051 | -0.805 | -0.806 | 1.269 | 0.109 | 0.702 | 0.336 | B |
4 | -1.722 | -1.425 | -0.591 | 2021-07-23--2021-07-30 | INDUSTRY BABY (feat. Jack Harlow) | 8.183 | Lil Nas X | -0.554 | 27NovPIUIRrOZoCHxABJwK | [lgbtq+ hip hop, pop rap] | ... | 0.323 | 0.436 | -0.423 | -0.563 | -0.913 | -0.910 | 0.919 | 0.298 | 1.669 | D#/Eb |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
1551 | 1.720 | 1.844 | -0.591 | 2019-12-27--2020-01-03 | New Rules | -0.506 | Dua Lipa | 0.747 | 2ekn2ttSfGqwhhate0LSR0 | [dance pop, pop, uk pop] | ... | 0.506 | 0.412 | 0.131 | -0.492 | -0.983 | -0.196 | -0.228 | 0.241 | 0.411 | A |
1552 | 1.722 | 1.861 | -0.591 | 2019-12-27--2020-01-03 | Cheirosa - Ao Vivo | -0.508 | Jorge & Mateus | 0.018 | 2PWjKmjyTZeDpmOUa3a5da | [sertanejo, sertanejo universitario] | ... | -1.138 | 1.464 | 1.286 | -0.349 | -0.035 | 1.054 | 0.999 | -0.340 | 0.877 | B |
1553 | 1.724 | 1.879 | -0.591 | 2019-12-27--2020-01-03 | Havana (feat. Young Thug) | -0.509 | Camila Cabello | 0.479 | 1rfofaqEpACxVEHIZBJe6W | [dance pop, electropop, pop, post-teen pop] | ... | 0.527 | -0.684 | 0.803 | -0.849 | -0.259 | -0.342 | -0.603 | 0.411 | -0.531 | D |
1554 | 1.726 | 1.896 | -0.591 | 2019-12-27--2020-01-03 | Surtada - Remix Brega Funk | -0.513 | Dadá Boladão, Tati Zaqui, OIK | -0.870 | 5F8ffc8KWKNawllr5WsW0r | [brega funk, funk carioca] | ... | 0.997 | -0.517 | -0.270 | -0.589 | 0.001 | 0.006 | 1.057 | -0.958 | 1.612 | F |
1555 | 1.728 | 1.913 | -0.591 | 2019-12-27--2020-01-03 | Lover (Remix) [feat. Shawn Mendes] | -0.516 | Taylor Swift | 1.650 | 3i9UVldZOE0aD0JnyfAZZ0 | [pop, post-teen pop] | ... | -1.699 | -0.189 | -0.330 | -0.541 | 0.737 | -0.660 | 2.788 | 0.496 | -0.408 | G |
1545 rows × 23 columns
df["Genre"].map(type)
0 <class 'list'>
1 <class 'list'>
2 <class 'list'>
3 <class 'list'>
4 <class 'list'>
...
1551 <class 'list'>
1552 <class 'list'>
1553 <class 'list'>
1554 <class 'list'>
1555 <class 'list'>
Name: Genre, Length: 1545, dtype: object
[2,3]+[4,10]
[2, 3, 4, 10]
df["Genre"].sum()
['indie rock italiano',
'italian pop',
'australian hip hop',
'pop',
'pop',
'uk pop',
'lgbtq+ hip hop',
'pop rap',
'lgbtq+ hip hop',
'pop rap',
'dance pop',
'pop',
'puerto rican pop',
'trap latino',
'latin',
'reggaeton',
'trap latino',
'indie rock italiano',
'italian pop',
'dance pop',
'pop',
'uk pop',
'latin',
'reggaeton',
'reggaeton colombiano',
'k-pop',
'k-pop boy group',
'canadian pop',
'pop',
'post-teen pop',
'k-pop',
'k-pop boy group',
'pop',
'pop',
'canadian contemporary r&b',
'canadian pop',
'pop',
'latin',
'reggaeton',
'trap latino',
'dance pop',
'pop',
'reggaeton',
'trap latino',
'dance pop',
'pop',
'pop',
'gauze pop',
'indietronica',
'shiver pop',
'canadian contemporary r&b',
'canadian pop',
'pop',
'pop',
'latin',
'latin hip hop',
'reggaeton',
'trap latino',
'dfw rap',
'melodic rap',
'rap',
'dance pop',
'house',
'pop dance',
'tropical house',
'uk dance',
'australian hip hop',
'dance pop',
'pop',
'post-teen pop',
'dance pop',
'electropop',
'pop',
'post-teen pop',
'pop',
'colombian pop',
'latin',
'reggaeton',
'reggaeton colombiano',
'pop',
'post-teen pop',
'chicago rap',
'dance pop',
'pop',
'latin',
'panamanian pop',
'reggaeton',
'trap latino',
'latin',
'reggaeton',
'trap latino',
'latin pop',
'pop argentino',
'pop',
'latin',
'reggaeton',
'reggaeton colombiano',
'k-pop',
'k-pop boy group',
'big room',
'brostep',
'dance pop',
'dutch edm',
'edm',
'electro house',
'house',
'pop dance',
'slap house',
'trance',
'tropical house',
'dance pop',
'edm',
'electro house',
'pop',
'pop dance',
'tropical house',
'cali rap',
'trap argentino',
'latin',
'latin hip hop',
'reggaeton',
'trap latino',
'argentine hip hop',
'pop venezolano',
'trap argentino',
'trap latino',
'electropop',
'pop',
'house',
'pop dance',
'uk dance',
'brostep',
'edm',
'pop',
'pop dance',
'progressive electro house',
'dreamo',
'indie surf',
'surf punk',
'vegas indie',
'puerto rican pop',
'trap latino',
'pop',
'pop rock',
'dance pop',
'piano rock',
'pop',
'pop rock',
'houston rap',
'pop',
'pop rap',
'trap queen',
'german dance',
'german techno',
'german trance',
'trance',
'pop',
'canadian contemporary r&b',
'canadian pop',
'pop',
'pop',
'r&b',
'modern alternative rock',
'modern rock',
'pop',
'latin',
'reggaeton',
'reggaeton colombiano',
'pop',
'uk pop',
'canadian hip hop',
'toronto rap',
'brooklyn drill',
'nyc rap',
'latin',
'reggaeton',
'reggaeton colombiano',
'latin',
'reggaeton',
'trap latino',
'aussietronica',
'indie rock italiano',
'italian pop',
'colombian pop',
'pop',
'mexican hip hop',
'rap conciencia',
'reggaeton',
'trap latino',
'australian pop',
'pop',
'australian hip hop',
'canadian hip hop',
'canadian pop',
'hip hop',
'pop rap',
'rap',
'toronto rap',
'comic',
'rap',
'slap house',
'dance pop',
'edm',
'pop',
'pop dance',
'tropical house',
'uk dance',
'dance pop',
'edm',
'pop',
'pop dance',
'tropical house',
'uk dance',
'melanesian pop',
'pacific islands pop',
'png pop',
'canadian hip hop',
'canadian trap',
'pop rap',
'rap',
'southern hip hop',
'trap',
'trap soul',
'underground hip hop',
'dutch pop',
'reggaeton',
'trap latino',
'dance pop',
'pop',
'post-teen pop',
'dfw rap',
'melodic rap',
'rap',
'german hip hop',
'latin',
'latin pop',
'rap latina',
'reggaeton',
'trap latino',
'dance pop',
'pop',
'afrofuturism',
'dance pop',
'electropop',
'pop',
'pop rap',
'post-teen pop',
'uk hip hop',
'pop',
'uk pop',
'dance pop',
'pop',
'uk pop',
'alt z',
'dance pop',
'electropop',
'pop',
'post-teen pop',
'modern rock',
'pop',
'rock',
'pop rap',
'rap',
'trap',
'dance pop',
'pop',
'post-teen pop',
'melodic rap',
'pop rap',
'rap',
'slap house',
'trap',
'latin',
'panamanian pop',
'reggaeton',
'trap latino',
'dance pop',
'latin',
'latin pop',
'latin viral pop',
'pop',
'rap latina',
'reggaeton',
'trap latino',
'electropop',
'pop',
'chill r&b',
'nyc pop',
'dance pop',
'pop',
'dance pop',
'edm',
'electro house',
'house',
'pop',
'progressive house',
'uk dance',
'sertanejo',
'sertanejo pop',
'sertanejo universitario',
'pop',
'uk pop',
'canadian pop',
'dance pop',
'pop',
'post-teen pop',
'viral pop',
'pop',
'uk pop',
'latin pop',
'latin',
'reggaeton',
'trap latino',
'north carolina hip hop',
'rap',
'alt z',
'bedroom pop',
'electropop',
'indie pop',
'pop',
'post-teen pop',
'alt z',
'dance pop',
'pop',
'post-teen pop',
'dance pop',
'edm',
'pop',
'pop dance',
'folk-pop',
'modern rock',
'pop',
'pop rock',
'grunge',
'permanent wave',
'rock',
'pop',
'modern alternative rock',
'modern rock',
'pop',
'melodic rap',
'rap',
'trap',
'pop',
'pop rock',
'pop',
'pop soul',
'irish singer-songwriter',
'modern rock',
'pop',
'modern rock',
'uk pop',
'sertanejo',
'sertanejo universitario',
'dance pop',
'pop',
'pop rap',
'rap',
'latin',
'reggaeton',
'reggaeton colombiano',
'pop',
'classic rock',
'glam rock',
'rock',
'trap latino',
'dance pop',
'edm',
'pop dance',
'pop house',
'tropical house',
'rap',
'slap house',
'edm',
'new french touch',
'pop dance',
'tropical house',
'colombian pop',
'reggaeton colombiano',
'dance pop',
'pop',
'post-teen pop',
'plugg',
'vapor trap',
'viral rap',
'dance pop',
'piano rock',
'pop',
'pop rock',
'permanent wave',
'pop',
'dance pop',
'edm',
'pop',
'pop dance',
'forro',
'sertanejo pop',
'brooklyn drill',
'art pop',
'norwegian pop',
'north carolina hip hop',
'rap',
'north carolina hip hop',
'rap',
'chicago rap',
'melodic rap',
'brooklyn drill',
'melodic rap',
'nyc rap',
'dance pop',
'pop',
'post-teen pop',
'brooklyn drill',
'pop',
'dance pop',
'pop',
'pop rap',
'rap',
'dance rock',
'modern rock',
'permanent wave',
'rock',
'album rock',
'art rock',
'classic rock',
'mellow gold',
'new wave',
'permanent wave',
'rock',
'soft rock',
'album rock',
'classic rock',
'mellow gold',
'rock',
'soft rock',
'yacht rock',
'pop',
'post-teen pop',
'talent show',
'uk pop',
'dance pop',
'pop',
'pop rap',
'post-teen pop',
'r&b',
'urban contemporary',
'brooklyn drill',
'brooklyn drill',
'sad rap',
'dance pop',
'pop',
'pop dance',
'post-teen pop',
'tropical house',
'uk pop',
'classic rock',
'glam rock',
'rock',
'canadian hip hop',
'canadian pop',
'hip hop',
'pop rap',
'rap',
'toronto rap',
'pop',
'post-teen pop',
'contemporary country',
'country',
'country road',
'modern country rock',
'puerto rican pop',
'trap latino',
'neo soul',
'pop',
'pop soul',
'r&b',
'urban contemporary',
'chicago rap',
'brooklyn drill',
'cali rap',
'dance pop',
'pop',
'pop rap',
'trap queen',
'canadian contemporary r&b',
'canadian pop',
'pop',
'pop',
'pop rap',
'r&b',
'dance pop',
'pop',
'pop dance',
'post-teen pop',
'tropical house',
'uk pop',
'latin',
'reggaeton',
'trap latino',
'dance pop',
'pop',
'post-teen pop',
'funk bh',
'funk carioca',
'dance pop',
'edm',
'german dance',
'pop dance',
'pop edm',
'tropical house',
'funk carioca',
'pop nacional',
'melodic rap',
'rap',
'trap',
'uk hip hop',
'detroit hip hop',
'hip hop',
'rap',
'brooklyn drill',
'brooklyn drill',
'melodic rap',
'rap',
'trap',
'brooklyn drill',
'brooklyn drill',
'uk hip hop',
'brooklyn drill',
'brooklyn drill',
'hip hop',
'rap',
'german alternative rap',
'german drill',
'german hip hop',
'german trap',
'london rap',
'brooklyn drill',
'latin',
'reggaeton',
'trap latino',
'italian hip hop',
'italian pop',
'dance pop',
'edm',
'pop dance',
'pop edm',
'slap house',
'tropical house',
'neo mellow',
'pop rock',
'singer-songwriter',
'modern rock',
'pop',
'rock',
'funk carioca',
'funk ostentacao',
'funk paulista',
'pop rap',
'rap',
'trap',
'modern rock',
'pop',
'rock',
'dance pop',
'pop',
'uk pop',
'k-pop',
'k-pop boy group',
'latin',
'panamanian pop',
'reggaeton',
'trap latino',
'dance pop',
'pop',
'post-teen pop',
'hip hop',
'pop rap',
'queens hip hop',
'rap',
'sudanese pop',
'underground hip hop',
'pop',
'sertanejo',
'sertanejo pop',
'sertanejo universitario',
'k-pop',
'k-pop girl group',
'escape room',
'r&b',
'rap latina',
'trap queen',
'contemporary country',
'country road',
'latin',
'reggaeton',
'reggaeton flow',
'trap latino',
'funk carioca',
'funk paulista',
'rave funk',
'latin',
'reggaeton',
'reggaeton colombiano',
'puerto rican pop',
'trap latino',
'dance pop',
'edm',
'electropop',
'pop',
'pop dance',
'tropical house',
'beatlesque',
'britpop',
'madchester',
'permanent wave',
'rock',
'dmv rap',
'pop',
'r&b',
'rap',
'dance pop',
'pop',
'eau claire indie',
'folktronica',
'hip hop',
'rap',
'comic',
'hip hop',
'miami hip hop',
'pop rap',
'rap',
'southern hip hop',
'trap',
'art pop',
'dance pop',
'electropop',
'metropopolis',
'nz pop',
'pop',
'post-teen pop',
'electropop',
'pop',
'frauenrap',
'german hip hop',
'german pop',
'nyc rap',
'sertanejo',
'sertanejo pop',
'sertanejo universitario',
'dance pop',
'pop',
'post-teen pop',
'dance pop',
'pop rap',
'puerto rican pop',
'trap latino',
'argentine hip hop',
'pop venezolano',
'trap argentino',
'trap latino',
'garage rock',
'permanent wave',
'rock',
'sheffield indie',
'hip hop',
'rap',
'hip hop',
'rap',
'hip hop',
'rap',
'hip hop',
'rap',
'hip hop',
'rap',
'hip hop',
'rap',
'hip hop',
'rap',
'hip hop',
'rap',
'hip hop',
'rap',
'dance pop',
'pop',
'hip hop',
'rap',
'hip hop',
'rap',
'dance pop',
'pop',
'atl hip hop',
'pop rap',
'rap',
'trap',
'dance pop',
'pop',
'dance pop',
'pop',
'italian adult pop',
'italian pop',
'latin',
'reggaeton',
'reggaeton colombiano',
'nz pop',
'latin',
'reggaeton',
'reggaeton colombiano',
'reggaeton',
'alt z',
'dance pop',
'pop',
'post-teen pop',
'francoton',
'french hip hop',
'pop urbaine',
'rap francais',
'rap marseille',
'conscious hip hop',
'hip hop',
'north carolina hip hop',
'rap',
'conscious hip hop',
'hip hop',
'north carolina hip hop',
'rap',
'emo rap',
'miami hip hop',
'chicago rap',
'melodic rap',
'rap',
'trap',
'modern rock',
'pop rap',
'seattle hip hop',
'ohio hip hop',
'pop rap',
'dance pop',
'pop',
'post-teen pop',
'rap',
'slap house',
'dance pop',
'pop',
'uk pop',
'canadian hip hop',
'canadian pop',
'hip hop',
'pop rap',
'rap',
'toronto rap',
'dance pop',
'dutch edm',
'edm',
'pop',
'pop dance',
'progressive house',
'tropical house',
'dembow',
'dominican pop',
'rap dominicano',
'trap latino',
'alternative metal',
'nu metal',
'post-grunge',
'rap metal',
'conscious hip hop',
'hip hop',
'north carolina hip hop',
'rap',
'rap',
'slap house',
'dance pop',
'edm',
'electropop',
'pop',
'pop dance',
'tropical house',
'dance pop',
'edm',
'pop dance',
'pop edm',
'slap house',
'tropical house',
'atl hip hop',
'pop rap',
'rap',
'trap',
'chicago rap',
'chicago rap',
'pop',
'pop rock',
'atl hip hop',
'pop rap',
'rap',
'trap',
'dance pop',
'pop',
'atl hip hop',
'pop rap',
'rap',
'trap',
'dance pop',
'pop',
'pop rap',
'chicago rap',
'atl hip hop',
'pop rap',
'rap',
'trap',
'latin',
'reggaeton',
'trap latino',
'funk 150 bpm',
'funk carioca',
'lgbtq+ hip hop',
'pop rap',
'chicago rap',
'dance pop',
'pop',
'post-teen pop',
'atl hip hop',
'atl trap',
'rap',
'trap',
'neo mellow',
'pop rock',
'singer-songwriter',
'atl hip hop',
'atl trap',
'rap',
'trap',
'k-pop',
'k-pop boy group',
'conscious hip hop',
'hip hop',
'north carolina hip hop',
'rap',
'melodic rap',
'rap',
'trap',
'rap',
'trap',
'colombian pop',
'latin',
'reggaeton',
'reggaeton colombiano',
'trap latino',
'pop',
'post-teen pop',
'indie rock italiano',
'italian pop',
'electropop',
'escape room',
'pop',
'detroit hip hop',
'hip hop',
'rap',
'electro house',
'pop nacional',
'slap house',
'chicago rap',
'melodic rap',
'chicago rap',
'melodic rap',
'k-pop',
'k-pop boy group',
'detroit hip hop',
'hip hop',
'rap',
'melodic rap',
'rap',
'rap conscient',
'trap',
'vapor trap',
'australian pop',
'canadian pop',
'pop',
'post-teen pop',
'funk carioca',
'funk ostentacao',
'conscious hip hop',
'hip hop',
'north carolina hip hop',
'rap',
'k-pop',
'k-pop boy group',
'k-pop',
'k-pop boy group',
'eurovision',
'nouvelle chanson francaise',
'modern rock',
'rock',
'modern rock',
'rock',
'conscious hip hop',
'hip hop',
'north carolina hip hop',
'rap',
'dance pop',
'hip pop',
'pop',
'pop rap',
'post-teen pop',
'queens hip hop',
'eurovision',
'oulu metal',
'trancecore',
'eurovision',
'k-pop girl group',
'conscious hip hop',
'hip hop',
'north carolina hip hop',
'rap',
'canadian hip hop',
'canadian pop',
'hip hop',
'pop rap',
'rap',
'toronto rap',
'boston hip hop',
'hip hop',
'pop rap',
'rap',
'bubblegrunge',
'chicago indie',
'indie pop',
'pop',
'brooklyn drill',
'melodic rap',
'nyc rap',
'dream smp',
'icelandic pop',
'sunnlensk tonlist',
'modern rock',
'rock',
'conscious hip hop',
'hip hop',
'north carolina hip hop',
'rap',
'conscious hip hop',
'hip hop',
'north carolina hip hop',
'rap',
'conscious hip hop',
'hip hop',
'north carolina hip hop',
'rap',
'conscious hip hop',
'hip hop',
'north carolina hip hop',
'rap',
'conscious hip hop',
'hip hop',
'north carolina hip hop',
'rap',
'conscious hip hop',
'hip hop',
'north carolina hip hop',
'rap',
'australian hip hop',
'argentine hip hop',
'pop venezolano',
'trap argentino',
'trap latino',
'latin',
'reggaeton',
'trap latino',
'dance pop',
'electropop',
'metropopolis',
'pop',
'post-teen pop',
'uk alternative pop',
'pop',
'post-teen pop',
'trap latino',
'reggaeton',
'reggaeton flow',
'trap latino',
'canadian pop',
'pop',
'post-teen pop',
'dance pop',
'pop rap',
'alt z',
'canadian contemporary r&b',
'indie cafe pop',
'pop',
'pop rock',
'post-teen pop',
'hip hop',
'miami hip hop',
'pop rap',
'rap',
'southern hip hop',
'trap',
'london rap',
'rap',
'trap',
'argentine hip hop',
...]
list(set(df["Genre"].sum()))
['brooklyn drill',
'german hip hop',
'country road',
'nyc rap',
'brill building pop',
'rap belge',
'cumbia pop',
'album rock',
'trap italiana',
'electropop',
'tennessee hip hop',
'grime',
'christlicher rap',
'piseiro',
'trap soul',
'turkish trap',
'swing',
'trancecore',
'trance',
'south african house',
'puerto rican pop',
'north carolina hip hop',
'art rock',
'funk 150 bpm',
'progressive electro house',
'indie r&b',
'deep house',
'k-rap',
'hip hop',
'basshall',
'indie rockism',
'rap francais',
'irish folk',
'norwegian pop',
'punk',
'rap latina',
'plugg',
'pop reggaeton',
'big room',
'tropical house',
'rap cearense',
'edm',
'uk alternative hip hop',
'american folk revival',
'indie pop',
'regional mexican',
'yacht rock',
'nz pop',
'brostep',
'francoton',
'oulu metal',
'rock-and-roll',
'latin',
'vocal jazz',
'permanent wave',
'tekk',
'melodic metalcore',
'icelandic pop',
'dutch pop',
'madchester',
'dutch edm',
'hamburg hip hop',
'quiet storm',
'dmv rap',
'r&b brasileiro',
'dreamo',
'afroswing',
'folk-pop',
'folk punk',
'uk metalcore',
'oakland hip hop',
'corrido',
'motown',
'deep euro house',
'champeta',
'dominican pop',
'australian pop',
'colombian pop',
'mariachi',
'rap metal',
'uk funky',
'k-pop',
'musical advocacy',
'cali rap',
'trap boricua',
'escape room',
'jawaiian',
'norteno',
'pop rap',
'sertanejo',
'rap conciencia',
'german drill',
'hip pop',
'reggaeton flow',
'pop',
'latin hip hop',
'soft rock',
'indietronica',
'eau claire indie',
'celtic rock',
'neo-psychedelic',
'canadian contemporary r&b',
'irish singer-songwriter',
'folk rock',
'show tunes',
'new wave',
'forro',
'country',
'reggaeton colombiano',
'modern alternative rock',
'italian pop rock',
'canadian hip hop',
'pop edm',
'nouvelle chanson francaise',
'funk pop',
'alternative pop rock',
'new romantic',
'trap brasileiro',
'comic',
'london rap',
'vapor trap',
'hard rock',
'pop urbaine',
'funk carioca',
'perreo',
'torch song',
'rap dominicano',
'chill r&b',
'new wave pop',
'k-pop girl group',
'florida rap',
'rhode island rap',
'social media pop',
'art pop',
'dembow',
'german techno',
'scandipop',
'sertanejo pop',
'funk paulista',
'minnesota hip hop',
'french hip hop',
'pop dance',
'modern indie pop',
'europop',
'soundtrack',
'soul',
'progressive house',
'hardcore hip hop',
'ranchera',
'trap chileno',
'uk pop',
'italian indie pop',
'slap house',
'alternative r&b',
'albanian hip hop',
'celtic',
'classic uk pop',
'r&b en espanol',
'trap triste',
'trap latino',
'glam rock',
'pop venezolano',
'nyc pop',
'seattle hip hop',
'adult standards',
'swedish pop',
'rockabilly',
'pop rock',
'alt z',
'singer-songwriter',
'melodic rap',
'easy listening',
'synthpop',
'folktronica',
'lounge',
'indie pop rap',
'pop soul',
'boy band',
'belgian hip hop',
'deep german hip hop',
'latin viral pop',
'bedroom soul',
'pagode baiano',
'moombahton',
'italian adult pop',
'ohio hip hop',
'queens hip hop',
'panamanian pop',
'a cappella',
'alternative metal',
'country rock',
'dfw rap',
'indonesian pop',
'rap marseille',
'sad rap',
'australian dance',
'jazz pop',
'pop nacional',
'indie poptimism',
'house',
'aussietronica',
'afrofuturism',
'etherpop',
'rave funk',
'australian psych',
'grunge',
'brega funk',
'west coast rap',
'conscious hip hop',
'philly rap',
'funk bh',
'post-teen pop',
'east coast hip hop',
'emo rap',
'banda',
'brazilian hip hop',
'toronto rap',
'bedroom pop',
'detroit hip hop',
'memphis hip hop',
'garage rock',
'vegas indie',
'german trance',
'gangster rap',
'urban contemporary',
'viral rap',
'trap argentino',
'miami hip hop',
'pop r&b',
'gauze pop',
'indie rock italiano',
'canadian pop',
'viral pop',
'lgbtq+ hip hop',
'indie surf',
'dance rock',
'cubaton',
'chicago rap',
'rap',
'jazz funk',
'canadian trap',
'girl group',
'mellow gold',
'neo mellow',
'new orleans rap',
'electro house',
'atl trap',
'pop argentino',
'trap',
'bubblegrunge',
'trap queen',
'pop house',
'german alternative rap',
'png pop',
'modern rock',
'german pop',
'metropopolis',
'pittsburgh rap',
'nu metal',
'piano rock',
'disco',
'modern country rock',
'german trap',
'chicago indie',
'houston rap',
'eurodance',
'indie cafe pop',
'british soul',
'uk dance',
'latin pop',
'dance pop',
'uk alternative pop',
'frauenrap',
'uk hip hop',
'funk ostentacao',
'italian pop',
'chicago drill',
'nuevo regional mexicano',
'electronic trap',
'electro latino',
'german dance',
'southern hip hop',
'kentucky hip hop',
'sunnlensk tonlist',
'sudanese pop',
'chicago soul',
'mexican hip hop',
'classic soul',
'weirdcore',
'surf punk',
'hollywood',
'k-pop boy group',
'eurovision',
'australian hip hop',
'argentine hip hop',
'new french touch',
'reggaeton',
'acoustic pop',
'deep underground hip hop',
'urbano espanol',
'contemporary country',
'neo soul',
'german underground rap',
'underground hip hop',
'melanesian pop',
'r&b',
'vancouver indie',
'metalcore',
'rock',
'german cloud rap',
'sheffield indie',
'pacific islands pop',
'post-grunge',
'sertanejo universitario',
'talent show',
'beatlesque',
'australian rock',
'meme rap',
'heartland rock',
'celtic punk',
'southern soul',
'drill',
'classic rock',
'shiver pop',
'boston hip hop',
'dream smp',
'canadian latin',
'rap conscient',
'venezuelan hip hop',
'britpop',
'funk',
'italian hip hop',
'old school rap francais',
'atl hip hop']
sorted(list(set(df["Genre"].sum())))
['a cappella',
'acoustic pop',
'adult standards',
'afrofuturism',
'afroswing',
'albanian hip hop',
'album rock',
'alt z',
'alternative metal',
'alternative pop rock',
'alternative r&b',
'american folk revival',
'argentine hip hop',
'art pop',
'art rock',
'atl hip hop',
'atl trap',
'aussietronica',
'australian dance',
'australian hip hop',
'australian pop',
'australian psych',
'australian rock',
'banda',
'basshall',
'beatlesque',
'bedroom pop',
'bedroom soul',
'belgian hip hop',
'big room',
'boston hip hop',
'boy band',
'brazilian hip hop',
'brega funk',
'brill building pop',
'british soul',
'britpop',
'brooklyn drill',
'brostep',
'bubblegrunge',
'cali rap',
'canadian contemporary r&b',
'canadian hip hop',
'canadian latin',
'canadian pop',
'canadian trap',
'celtic',
'celtic punk',
'celtic rock',
'champeta',
'chicago drill',
'chicago indie',
'chicago rap',
'chicago soul',
'chill r&b',
'christlicher rap',
'classic rock',
'classic soul',
'classic uk pop',
'colombian pop',
'comic',
'conscious hip hop',
'contemporary country',
'corrido',
'country',
'country road',
'country rock',
'cubaton',
'cumbia pop',
'dance pop',
'dance rock',
'deep euro house',
'deep german hip hop',
'deep house',
'deep underground hip hop',
'dembow',
'detroit hip hop',
'dfw rap',
'disco',
'dmv rap',
'dominican pop',
'dream smp',
'dreamo',
'drill',
'dutch edm',
'dutch pop',
'east coast hip hop',
'easy listening',
'eau claire indie',
'edm',
'electro house',
'electro latino',
'electronic trap',
'electropop',
'emo rap',
'escape room',
'etherpop',
'eurodance',
'europop',
'eurovision',
'florida rap',
'folk punk',
'folk rock',
'folk-pop',
'folktronica',
'forro',
'francoton',
'frauenrap',
'french hip hop',
'funk',
'funk 150 bpm',
'funk bh',
'funk carioca',
'funk ostentacao',
'funk paulista',
'funk pop',
'gangster rap',
'garage rock',
'gauze pop',
'german alternative rap',
'german cloud rap',
'german dance',
'german drill',
'german hip hop',
'german pop',
'german techno',
'german trance',
'german trap',
'german underground rap',
'girl group',
'glam rock',
'grime',
'grunge',
'hamburg hip hop',
'hard rock',
'hardcore hip hop',
'heartland rock',
'hip hop',
'hip pop',
'hollywood',
'house',
'houston rap',
'icelandic pop',
'indie cafe pop',
'indie pop',
'indie pop rap',
'indie poptimism',
'indie r&b',
'indie rock italiano',
'indie rockism',
'indie surf',
'indietronica',
'indonesian pop',
'irish folk',
'irish singer-songwriter',
'italian adult pop',
'italian hip hop',
'italian indie pop',
'italian pop',
'italian pop rock',
'jawaiian',
'jazz funk',
'jazz pop',
'k-pop',
'k-pop boy group',
'k-pop girl group',
'k-rap',
'kentucky hip hop',
'latin',
'latin hip hop',
'latin pop',
'latin viral pop',
'lgbtq+ hip hop',
'london rap',
'lounge',
'madchester',
'mariachi',
'melanesian pop',
'mellow gold',
'melodic metalcore',
'melodic rap',
'meme rap',
'memphis hip hop',
'metalcore',
'metropopolis',
'mexican hip hop',
'miami hip hop',
'minnesota hip hop',
'modern alternative rock',
'modern country rock',
'modern indie pop',
'modern rock',
'moombahton',
'motown',
'musical advocacy',
'neo mellow',
'neo soul',
'neo-psychedelic',
'new french touch',
'new orleans rap',
'new romantic',
'new wave',
'new wave pop',
'norteno',
'north carolina hip hop',
'norwegian pop',
'nouvelle chanson francaise',
'nu metal',
'nuevo regional mexicano',
'nyc pop',
'nyc rap',
'nz pop',
'oakland hip hop',
'ohio hip hop',
'old school rap francais',
'oulu metal',
'pacific islands pop',
'pagode baiano',
'panamanian pop',
'permanent wave',
'perreo',
'philly rap',
'piano rock',
'piseiro',
'pittsburgh rap',
'plugg',
'png pop',
'pop',
'pop argentino',
'pop dance',
'pop edm',
'pop house',
'pop nacional',
'pop r&b',
'pop rap',
'pop reggaeton',
'pop rock',
'pop soul',
'pop urbaine',
'pop venezolano',
'post-grunge',
'post-teen pop',
'progressive electro house',
'progressive house',
'puerto rican pop',
'punk',
'queens hip hop',
'quiet storm',
'r&b',
'r&b brasileiro',
'r&b en espanol',
'ranchera',
'rap',
'rap belge',
'rap cearense',
'rap conciencia',
'rap conscient',
'rap dominicano',
'rap francais',
'rap latina',
'rap marseille',
'rap metal',
'rave funk',
'reggaeton',
'reggaeton colombiano',
'reggaeton flow',
'regional mexican',
'rhode island rap',
'rock',
'rock-and-roll',
'rockabilly',
'sad rap',
'scandipop',
'seattle hip hop',
'sertanejo',
'sertanejo pop',
'sertanejo universitario',
'sheffield indie',
'shiver pop',
'show tunes',
'singer-songwriter',
'slap house',
'social media pop',
'soft rock',
'soul',
'soundtrack',
'south african house',
'southern hip hop',
'southern soul',
'sudanese pop',
'sunnlensk tonlist',
'surf punk',
'swedish pop',
'swing',
'synthpop',
'talent show',
'tekk',
'tennessee hip hop',
'torch song',
'toronto rap',
'trance',
'trancecore',
'trap',
'trap argentino',
'trap boricua',
'trap brasileiro',
'trap chileno',
'trap italiana',
'trap latino',
'trap queen',
'trap soul',
'trap triste',
'tropical house',
'turkish trap',
'uk alternative hip hop',
'uk alternative pop',
'uk dance',
'uk funky',
'uk hip hop',
'uk metalcore',
'uk pop',
'underground hip hop',
'urban contemporary',
'urbano espanol',
'vancouver indie',
'vapor trap',
'vegas indie',
'venezuelan hip hop',
'viral pop',
'viral rap',
'vocal jazz',
'weirdcore',
'west coast rap',
'yacht rock']
# All the art pop entries in df
df[df["Genre"] == "art pop"]
Index | Highest Charting Position | Number of Times Charted | Week of Highest Charting | Song Name | Streams | Artist | Artist Followers | Song ID | Genre | ... | Danceability | Energy | Loudness | Speechiness | Acousticness | Liveness | Tempo | Duration (ms) | Valence | Chord |
---|
0 rows × 23 columns
df[df["Genre"].map(lambda g_list: "art pop" in g_list)]
Index | Highest Charting Position | Number of Times Charted | Week of Highest Charting | Song Name | Streams | Artist | Artist Followers | Song ID | Genre | ... | Danceability | Energy | Loudness | Speechiness | Acousticness | Liveness | Tempo | Duration (ms) | Valence | Chord | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
158 | -1.380 | -1.184 | 0.447 | 2021-04-23--2021-04-30 | Runaway | -0.228 | AURORA | -0.782 | 0TCmhnbMpw5zwPsTvlXTJi | [art pop, norwegian pop] | ... | -1.187 | -2.207 | -1.591 | -0.798 | 1.540 | -0.543 | -0.264 | 1.080 | -1.693 | B |
244 | -1.188 | -1.081 | -0.408 | 2021-06-11--2021-06-18 | Solar Power | -0.327 | Lorde | -0.398 | 3KdoeNlEN0BoAKWzaRLNZa | [art pop, dance pop, electropop, metropopolis,... | ... | 0.316 | -1.012 | -1.218 | -0.214 | 0.069 | 0.964 | -1.178 | -0.113 | 1.682 | E |
481 | -0.661 | 1.104 | -0.591 | 2021-03-19--2021-03-26 | White Dress | -0.160 | Lana Del Rey | -0.061 | 4Hl9rOqYomojCmxYfr25im | [art pop, pop] | ... | -1.383 | -2.294 | -2.574 | -0.803 | 2.707 | -0.648 | -0.001 | 2.881 | -1.570 | C |
483 | -0.657 | 0.863 | -0.530 | 2021-01-15--2021-01-22 | Chemtrails Over The Country Club | -0.272 | Lana Del Rey | -0.061 | 7bPWdJgx8vek7S5i5yAtvG | [art pop, pop] | ... | -2.500 | -2.213 | -2.701 | -0.538 | 2.511 | -0.474 | 2.644 | 1.554 | -0.377 | E |
838 | 0.133 | 1.793 | -0.591 | 2020-10-16--2020-10-23 | Let Me Love You Like A Woman | -0.496 | Lana Del Rey | -0.061 | 1gxdWpeOUBpvB908fiZs4D | [art pop, pop] | ... | -2.718 | -2.380 | -2.139 | -0.115 | 2.882 | -0.446 | -1.889 | 0.058 | -1.688 | C |
5 rows × 23 columns
len(df[df["Genre"].map(lambda g_list: "art pop" in g_list)])
5
# function: input: a genre. output: how many songs
def count_songs(g):
return len(df[df["Genre"].map(lambda g_list: g in g_list)])
count_songs("pop")
485
all_genres = sorted(list(set(df["Genre"].sum())))
all_genres
['a cappella',
'acoustic pop',
'adult standards',
'afrofuturism',
'afroswing',
'albanian hip hop',
'album rock',
'alt z',
'alternative metal',
'alternative pop rock',
'alternative r&b',
'american folk revival',
'argentine hip hop',
'art pop',
'art rock',
'atl hip hop',
'atl trap',
'aussietronica',
'australian dance',
'australian hip hop',
'australian pop',
'australian psych',
'australian rock',
'banda',
'basshall',
'beatlesque',
'bedroom pop',
'bedroom soul',
'belgian hip hop',
'big room',
'boston hip hop',
'boy band',
'brazilian hip hop',
'brega funk',
'brill building pop',
'british soul',
'britpop',
'brooklyn drill',
'brostep',
'bubblegrunge',
'cali rap',
'canadian contemporary r&b',
'canadian hip hop',
'canadian latin',
'canadian pop',
'canadian trap',
'celtic',
'celtic punk',
'celtic rock',
'champeta',
'chicago drill',
'chicago indie',
'chicago rap',
'chicago soul',
'chill r&b',
'christlicher rap',
'classic rock',
'classic soul',
'classic uk pop',
'colombian pop',
'comic',
'conscious hip hop',
'contemporary country',
'corrido',
'country',
'country road',
'country rock',
'cubaton',
'cumbia pop',
'dance pop',
'dance rock',
'deep euro house',
'deep german hip hop',
'deep house',
'deep underground hip hop',
'dembow',
'detroit hip hop',
'dfw rap',
'disco',
'dmv rap',
'dominican pop',
'dream smp',
'dreamo',
'drill',
'dutch edm',
'dutch pop',
'east coast hip hop',
'easy listening',
'eau claire indie',
'edm',
'electro house',
'electro latino',
'electronic trap',
'electropop',
'emo rap',
'escape room',
'etherpop',
'eurodance',
'europop',
'eurovision',
'florida rap',
'folk punk',
'folk rock',
'folk-pop',
'folktronica',
'forro',
'francoton',
'frauenrap',
'french hip hop',
'funk',
'funk 150 bpm',
'funk bh',
'funk carioca',
'funk ostentacao',
'funk paulista',
'funk pop',
'gangster rap',
'garage rock',
'gauze pop',
'german alternative rap',
'german cloud rap',
'german dance',
'german drill',
'german hip hop',
'german pop',
'german techno',
'german trance',
'german trap',
'german underground rap',
'girl group',
'glam rock',
'grime',
'grunge',
'hamburg hip hop',
'hard rock',
'hardcore hip hop',
'heartland rock',
'hip hop',
'hip pop',
'hollywood',
'house',
'houston rap',
'icelandic pop',
'indie cafe pop',
'indie pop',
'indie pop rap',
'indie poptimism',
'indie r&b',
'indie rock italiano',
'indie rockism',
'indie surf',
'indietronica',
'indonesian pop',
'irish folk',
'irish singer-songwriter',
'italian adult pop',
'italian hip hop',
'italian indie pop',
'italian pop',
'italian pop rock',
'jawaiian',
'jazz funk',
'jazz pop',
'k-pop',
'k-pop boy group',
'k-pop girl group',
'k-rap',
'kentucky hip hop',
'latin',
'latin hip hop',
'latin pop',
'latin viral pop',
'lgbtq+ hip hop',
'london rap',
'lounge',
'madchester',
'mariachi',
'melanesian pop',
'mellow gold',
'melodic metalcore',
'melodic rap',
'meme rap',
'memphis hip hop',
'metalcore',
'metropopolis',
'mexican hip hop',
'miami hip hop',
'minnesota hip hop',
'modern alternative rock',
'modern country rock',
'modern indie pop',
'modern rock',
'moombahton',
'motown',
'musical advocacy',
'neo mellow',
'neo soul',
'neo-psychedelic',
'new french touch',
'new orleans rap',
'new romantic',
'new wave',
'new wave pop',
'norteno',
'north carolina hip hop',
'norwegian pop',
'nouvelle chanson francaise',
'nu metal',
'nuevo regional mexicano',
'nyc pop',
'nyc rap',
'nz pop',
'oakland hip hop',
'ohio hip hop',
'old school rap francais',
'oulu metal',
'pacific islands pop',
'pagode baiano',
'panamanian pop',
'permanent wave',
'perreo',
'philly rap',
'piano rock',
'piseiro',
'pittsburgh rap',
'plugg',
'png pop',
'pop',
'pop argentino',
'pop dance',
'pop edm',
'pop house',
'pop nacional',
'pop r&b',
'pop rap',
'pop reggaeton',
'pop rock',
'pop soul',
'pop urbaine',
'pop venezolano',
'post-grunge',
'post-teen pop',
'progressive electro house',
'progressive house',
'puerto rican pop',
'punk',
'queens hip hop',
'quiet storm',
'r&b',
'r&b brasileiro',
'r&b en espanol',
'ranchera',
'rap',
'rap belge',
'rap cearense',
'rap conciencia',
'rap conscient',
'rap dominicano',
'rap francais',
'rap latina',
'rap marseille',
'rap metal',
'rave funk',
'reggaeton',
'reggaeton colombiano',
'reggaeton flow',
'regional mexican',
'rhode island rap',
'rock',
'rock-and-roll',
'rockabilly',
'sad rap',
'scandipop',
'seattle hip hop',
'sertanejo',
'sertanejo pop',
'sertanejo universitario',
'sheffield indie',
'shiver pop',
'show tunes',
'singer-songwriter',
'slap house',
'social media pop',
'soft rock',
'soul',
'soundtrack',
'south african house',
'southern hip hop',
'southern soul',
'sudanese pop',
'sunnlensk tonlist',
'surf punk',
'swedish pop',
'swing',
'synthpop',
'talent show',
'tekk',
'tennessee hip hop',
'torch song',
'toronto rap',
'trance',
'trancecore',
'trap',
'trap argentino',
'trap boricua',
'trap brasileiro',
'trap chileno',
'trap italiana',
'trap latino',
'trap queen',
'trap soul',
'trap triste',
'tropical house',
'turkish trap',
'uk alternative hip hop',
'uk alternative pop',
'uk dance',
'uk funky',
'uk hip hop',
'uk metalcore',
'uk pop',
'underground hip hop',
'urban contemporary',
'urbano espanol',
'vancouver indie',
'vapor trap',
'vegas indie',
'venezuelan hip hop',
'viral pop',
'viral rap',
'vocal jazz',
'weirdcore',
'west coast rap',
'yacht rock']
[count_songs(g) for g in all_genres]
[1,
1,
18,
1,
2,
2,
8,
20,
1,
1,
14,
1,
8,
5,
4,
53,
13,
1,
5,
9,
11,
5,
1,
1,
3,
5,
4,
2,
2,
1,
1,
14,
1,
2,
3,
2,
2,
37,
4,
1,
9,
24,
32,
1,
85,
8,
1,
1,
1,
1,
1,
1,
47,
1,
3,
1,
12,
1,
1,
18,
2,
18,
13,
1,
3,
4,
1,
1,
1,
257,
1,
3,
1,
3,
3,
2,
24,
10,
2,
4,
3,
2,
1,
1,
4,
1,
2,
12,
1,
50,
10,
1,
4,
60,
12,
6,
4,
1,
3,
3,
3,
1,
2,
2,
1,
7,
7,
3,
10,
2,
1,
1,
15,
3,
2,
4,
4,
2,
1,
3,
7,
6,
6,
53,
7,
1,
1,
4,
1,
2,
4,
1,
1,
11,
2,
2,
2,
151,
5,
1,
7,
6,
1,
9,
7,
2,
7,
1,
4,
1,
1,
2,
1,
1,
1,
2,
7,
1,
11,
1,
1,
1,
3,
45,
30,
18,
1,
4,
154,
17,
15,
1,
8,
3,
17,
2,
2,
1,
11,
2,
124,
1,
4,
2,
3,
1,
12,
3,
4,
2,
3,
23,
1,
3,
1,
5,
2,
5,
2,
1,
2,
3,
5,
1,
30,
1,
1,
1,
2,
1,
8,
4,
2,
18,
1,
1,
1,
3,
9,
11,
1,
34,
3,
5,
11,
2,
1,
485,
1,
54,
7,
3,
5,
2,
164,
3,
17,
3,
10,
6,
1,
256,
4,
6,
22,
1,
3,
2,
30,
1,
6,
2,
310,
2,
1,
1,
5,
2,
7,
3,
2,
1,
1,
157,
45,
21,
3,
2,
32,
2,
3,
5,
1,
1,
10,
9,
12,
2,
1,
1,
3,
17,
4,
10,
5,
1,
1,
29,
1,
1,
1,
1,
1,
2,
2,
9,
1,
1,
1,
30,
2,
1,
159,
10,
9,
1,
1,
5,
155,
14,
3,
3,
45,
1,
1,
1,
9,
1,
10,
2,
52,
8,
7,
3,
1,
5,
1,
1,
18,
8,
11,
1,
1,
3]
{g:count_songs(g) for g in all_genres}
{'a cappella': 1,
'acoustic pop': 1,
'adult standards': 18,
'afrofuturism': 1,
'afroswing': 2,
'albanian hip hop': 2,
'album rock': 8,
'alt z': 20,
'alternative metal': 1,
'alternative pop rock': 1,
'alternative r&b': 14,
'american folk revival': 1,
'argentine hip hop': 8,
'art pop': 5,
'art rock': 4,
'atl hip hop': 53,
'atl trap': 13,
'aussietronica': 1,
'australian dance': 5,
'australian hip hop': 9,
'australian pop': 11,
'australian psych': 5,
'australian rock': 1,
'banda': 1,
'basshall': 3,
'beatlesque': 5,
'bedroom pop': 4,
'bedroom soul': 2,
'belgian hip hop': 2,
'big room': 1,
'boston hip hop': 1,
'boy band': 14,
'brazilian hip hop': 1,
'brega funk': 2,
'brill building pop': 3,
'british soul': 2,
'britpop': 2,
'brooklyn drill': 37,
'brostep': 4,
'bubblegrunge': 1,
'cali rap': 9,
'canadian contemporary r&b': 24,
'canadian hip hop': 32,
'canadian latin': 1,
'canadian pop': 85,
'canadian trap': 8,
'celtic': 1,
'celtic punk': 1,
'celtic rock': 1,
'champeta': 1,
'chicago drill': 1,
'chicago indie': 1,
'chicago rap': 47,
'chicago soul': 1,
'chill r&b': 3,
'christlicher rap': 1,
'classic rock': 12,
'classic soul': 1,
'classic uk pop': 1,
'colombian pop': 18,
'comic': 2,
'conscious hip hop': 18,
'contemporary country': 13,
'corrido': 1,
'country': 3,
'country road': 4,
'country rock': 1,
'cubaton': 1,
'cumbia pop': 1,
'dance pop': 257,
'dance rock': 1,
'deep euro house': 3,
'deep german hip hop': 1,
'deep house': 3,
'deep underground hip hop': 3,
'dembow': 2,
'detroit hip hop': 24,
'dfw rap': 10,
'disco': 2,
'dmv rap': 4,
'dominican pop': 3,
'dream smp': 2,
'dreamo': 1,
'drill': 1,
'dutch edm': 4,
'dutch pop': 1,
'east coast hip hop': 2,
'easy listening': 12,
'eau claire indie': 1,
'edm': 50,
'electro house': 10,
'electro latino': 1,
'electronic trap': 4,
'electropop': 60,
'emo rap': 12,
'escape room': 6,
'etherpop': 4,
'eurodance': 1,
'europop': 3,
'eurovision': 3,
'florida rap': 3,
'folk punk': 1,
'folk rock': 2,
'folk-pop': 2,
'folktronica': 1,
'forro': 7,
'francoton': 7,
'frauenrap': 3,
'french hip hop': 10,
'funk': 2,
'funk 150 bpm': 1,
'funk bh': 1,
'funk carioca': 15,
'funk ostentacao': 3,
'funk paulista': 2,
'funk pop': 4,
'gangster rap': 4,
'garage rock': 2,
'gauze pop': 1,
'german alternative rap': 3,
'german cloud rap': 7,
'german dance': 6,
'german drill': 6,
'german hip hop': 53,
'german pop': 7,
'german techno': 1,
'german trance': 1,
'german trap': 4,
'german underground rap': 1,
'girl group': 2,
'glam rock': 4,
'grime': 1,
'grunge': 1,
'hamburg hip hop': 11,
'hard rock': 2,
'hardcore hip hop': 2,
'heartland rock': 2,
'hip hop': 151,
'hip pop': 5,
'hollywood': 1,
'house': 7,
'houston rap': 6,
'icelandic pop': 1,
'indie cafe pop': 9,
'indie pop': 7,
'indie pop rap': 2,
'indie poptimism': 7,
'indie r&b': 1,
'indie rock italiano': 4,
'indie rockism': 1,
'indie surf': 1,
'indietronica': 2,
'indonesian pop': 1,
'irish folk': 1,
'irish singer-songwriter': 1,
'italian adult pop': 2,
'italian hip hop': 7,
'italian indie pop': 1,
'italian pop': 11,
'italian pop rock': 1,
'jawaiian': 1,
'jazz funk': 1,
'jazz pop': 3,
'k-pop': 45,
'k-pop boy group': 30,
'k-pop girl group': 18,
'k-rap': 1,
'kentucky hip hop': 4,
'latin': 154,
'latin hip hop': 17,
'latin pop': 15,
'latin viral pop': 1,
'lgbtq+ hip hop': 8,
'london rap': 3,
'lounge': 17,
'madchester': 2,
'mariachi': 2,
'melanesian pop': 1,
'mellow gold': 11,
'melodic metalcore': 2,
'melodic rap': 124,
'meme rap': 1,
'memphis hip hop': 4,
'metalcore': 2,
'metropopolis': 3,
'mexican hip hop': 1,
'miami hip hop': 12,
'minnesota hip hop': 3,
'modern alternative rock': 4,
'modern country rock': 2,
'modern indie pop': 3,
'modern rock': 23,
'moombahton': 1,
'motown': 3,
'musical advocacy': 1,
'neo mellow': 5,
'neo soul': 2,
'neo-psychedelic': 5,
'new french touch': 2,
'new orleans rap': 1,
'new romantic': 2,
'new wave': 3,
'new wave pop': 5,
'norteno': 1,
'north carolina hip hop': 30,
'norwegian pop': 1,
'nouvelle chanson francaise': 1,
'nu metal': 1,
'nuevo regional mexicano': 2,
'nyc pop': 1,
'nyc rap': 8,
'nz pop': 4,
'oakland hip hop': 2,
'ohio hip hop': 18,
'old school rap francais': 1,
'oulu metal': 1,
'pacific islands pop': 1,
'pagode baiano': 3,
'panamanian pop': 9,
'permanent wave': 11,
'perreo': 1,
'philly rap': 34,
'piano rock': 3,
'piseiro': 5,
'pittsburgh rap': 11,
'plugg': 2,
'png pop': 1,
'pop': 485,
'pop argentino': 1,
'pop dance': 54,
'pop edm': 7,
'pop house': 3,
'pop nacional': 5,
'pop r&b': 2,
'pop rap': 164,
'pop reggaeton': 3,
'pop rock': 17,
'pop soul': 3,
'pop urbaine': 10,
'pop venezolano': 6,
'post-grunge': 1,
'post-teen pop': 256,
'progressive electro house': 4,
'progressive house': 6,
'puerto rican pop': 22,
'punk': 1,
'queens hip hop': 3,
'quiet storm': 2,
'r&b': 30,
'r&b brasileiro': 1,
'r&b en espanol': 6,
'ranchera': 2,
'rap': 310,
'rap belge': 2,
'rap cearense': 1,
'rap conciencia': 1,
'rap conscient': 5,
'rap dominicano': 2,
'rap francais': 7,
'rap latina': 3,
'rap marseille': 2,
'rap metal': 1,
'rave funk': 1,
'reggaeton': 157,
'reggaeton colombiano': 45,
'reggaeton flow': 21,
'regional mexican': 3,
'rhode island rap': 2,
'rock': 32,
'rock-and-roll': 2,
'rockabilly': 3,
'sad rap': 5,
'scandipop': 1,
'seattle hip hop': 1,
'sertanejo': 10,
'sertanejo pop': 9,
'sertanejo universitario': 12,
'sheffield indie': 2,
'shiver pop': 1,
'show tunes': 1,
'singer-songwriter': 3,
'slap house': 17,
'social media pop': 4,
'soft rock': 10,
'soul': 5,
'soundtrack': 1,
'south african house': 1,
'southern hip hop': 29,
'southern soul': 1,
'sudanese pop': 1,
'sunnlensk tonlist': 1,
'surf punk': 1,
'swedish pop': 1,
'swing': 2,
'synthpop': 2,
'talent show': 9,
'tekk': 1,
'tennessee hip hop': 1,
'torch song': 1,
'toronto rap': 30,
'trance': 2,
'trancecore': 1,
'trap': 159,
'trap argentino': 10,
'trap boricua': 9,
'trap brasileiro': 1,
'trap chileno': 1,
'trap italiana': 5,
'trap latino': 155,
'trap queen': 14,
'trap soul': 3,
'trap triste': 3,
'tropical house': 45,
'turkish trap': 1,
'uk alternative hip hop': 1,
'uk alternative pop': 1,
'uk dance': 9,
'uk funky': 1,
'uk hip hop': 10,
'uk metalcore': 2,
'uk pop': 52,
'underground hip hop': 8,
'urban contemporary': 7,
'urbano espanol': 3,
'vancouver indie': 1,
'vapor trap': 5,
'vegas indie': 1,
'venezuelan hip hop': 1,
'viral pop': 18,
'viral rap': 8,
'vocal jazz': 11,
'weirdcore': 1,
'west coast rap': 1,
'yacht rock': 3}
from sklearn.linear_model import LogisticRegression
clf = LogisticRegression()
df.head()
Index | Highest Charting Position | Number of Times Charted | Week of Highest Charting | Song Name | Streams | Artist | Artist Followers | Song ID | Genre | ... | Danceability | Energy | Loudness | Speechiness | Acousticness | Liveness | Tempo | Duration (ms) | Valence | Chord | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | -1.731 | -1.494 | -0.164 | 2021-07-23--2021-07-30 | Beggin' | 12.535 | Måneskin | -0.680 | 3Wrjm47oTz2sjIgck11l5e | [indie rock italiano, italian pop] | ... | 0.169 | 1.031 | 0.614 | -0.664 | -0.486 | 1.234 | 0.378 | 0.289 | 0.327 | B |
1 | -1.729 | -1.477 | -0.469 | 2021-07-23--2021-07-30 | STAY (with Justin Bieber) | 12.124 | The Kid LAROI | -0.749 | 5HCyWlXZPP0y6Gqq8TgA20 | [australian hip hop] | ... | -0.695 | 0.808 | 0.345 | -0.683 | -0.841 | -0.543 | 1.593 | -1.191 | -0.162 | C#/Db |
2 | -1.727 | -1.494 | 0.019 | 2021-06-25--2021-07-02 | good 4 u | 10.024 | Olivia Rodrigo | -0.507 | 4ZtFanR9U6ndgddUvNcjcG | [pop] | ... | -0.892 | 0.189 | 0.520 | 0.275 | 0.345 | -0.669 | 1.491 | -0.420 | 0.763 | A |
3 | -1.725 | -1.460 | -0.347 | 2021-07-02--2021-07-09 | Bad Habits | 9.324 | Ed Sheeran | 4.114 | 6PQ88X9TkUIAUIZJHW2upE | [pop, uk pop] | ... | 0.829 | 1.631 | 1.051 | -0.805 | -0.806 | 1.269 | 0.109 | 0.702 | 0.336 | B |
4 | -1.722 | -1.425 | -0.591 | 2021-07-23--2021-07-30 | INDUSTRY BABY (feat. Jack Harlow) | 8.183 | Lil Nas X | -0.554 | 27NovPIUIRrOZoCHxABJwK | [lgbtq+ hip hop, pop rap] | ... | 0.323 | 0.436 | -0.423 | -0.563 | -0.913 | -0.910 | 0.919 | 0.298 | 1.669 | D#/Eb |
5 rows × 23 columns
df["Genre"].map(lambda g_list: "uk pop" if "uk pop" in g_list else "Not uk pop")
0 Not uk pop
1 Not uk pop
2 Not uk pop
3 uk pop
4 Not uk pop
...
1551 uk pop
1552 Not uk pop
1553 Not uk pop
1554 Not uk pop
1555 Not uk pop
Name: Genre, Length: 1545, dtype: object
df["Genre"].map(lambda g_list: "uk pop" if "uk pop" in g_list else "Not uk pop").value_counts()
Not uk pop 1493
uk pop 52
Name: Genre, dtype: int64
y = df["Genre"].map(lambda g_list: "uk pop" if "uk pop" in g_list else "Not uk pop")
X = df[["Energy","Loudness"]]
X
Energy | Loudness | |
---|---|---|
0 | 1.031 | 0.614 |
1 | 0.808 | 0.345 |
2 | 0.189 | 0.520 |
3 | 1.631 | 1.051 |
4 | 0.436 | -0.423 |
... | ... | ... |
1551 | 0.412 | 0.131 |
1552 | 1.464 | 1.286 |
1553 | -0.684 | 0.803 |
1554 | -0.517 | -0.270 |
1555 | -0.189 | -0.330 |
1545 rows × 2 columns
clf.fit(X,y)
LogisticRegression()
clf.predict(X)
array(['Not uk pop', 'Not uk pop', 'Not uk pop', ..., 'Not uk pop',
'Not uk pop', 'Not uk pop'], dtype=object)
clf.classes_
array(['Not uk pop', 'uk pop'], dtype=object)
clf.predict_proba(X.iloc[:5])
array([[0.97295972, 0.02704028],
[0.97454646, 0.02545354],
[0.96085138, 0.03914862],
[0.97363124, 0.02636876],
[0.98131548, 0.01868452]])
clf.coef_
array([[-0.52899561, 0.66794587]])
clf.intercept_
array([-3.44790123])