“Song Shuffle” by Metztli
Essential Questions: - What is the likelihood of a song of each genre being played? - How does the probability based on the amount of songs changes?
Background Info.
So this project will be showing the difference of probabilities as we go through the coding process as depending each amount of songs that are clumped together into another column, they can show either the increase or decrease of a genre song that will be potentially played within each playlist
# tidyverse is what will help us organize the coding and the data
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.4.4 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
# Organize the clean playlist
df <- read_csv("playlist.csv")
## Rows: 144 Columns: 3
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): genre, artist, title
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
head(df)
## # A tibble: 6 × 3
## genre artist title
## <chr> <chr> <chr>
## 1 Genre 1 - hiphop/rap Alesso When I'm Gone
## 2 Genre 1 - hiphop/rap Aliyah's Interlude It Girl
## 3 Genre 1 - hiphop/rap Big Sean Beware
## 4 Genre 1 - hiphop/rap Clipse Ma, I don't love her
## 5 Genre 1 - hiphop/rap Common Be
## 6 Genre 1 - hiphop/rap Drake Nice for what
#The list of music being rearranged as genres to artist
df %>% arrange(genre)
## # A tibble: 144 × 3
## genre artist title
## <chr> <chr> <chr>
## 1 Genre 1 - hiphop/rap Alesso When I'm Gone
## 2 Genre 1 - hiphop/rap Aliyah's Interlude It Girl
## 3 Genre 1 - hiphop/rap Big Sean Beware
## 4 Genre 1 - hiphop/rap Clipse Ma, I don't love her
## 5 Genre 1 - hiphop/rap Common Be
## 6 Genre 1 - hiphop/rap Drake Nice for what
## 7 Genre 1 - hiphop/rap Isaiah Rashad Headshots
## 8 Genre 1 - hiphop/rap Jcole change
## 9 Genre 1 - hiphop/rap Jcole Crooked smile
## 10 Genre 1 - hiphop/rap Jcole Immortal
## # ℹ 134 more rows
#Count the amount of music there is listed
df %>% count(genre)
## # A tibble: 6 × 2
## genre n
## <chr> <int>
## 1 Genre 1 - hiphop/rap 26
## 2 Genre 2 - pop/kpop/Latin 22
## 3 Genre 3 - house/ska 5
## 4 Genre 4 - rnb/soul 43
## 5 Genre 5 - alt/indie/folk 34
## 6 Genre 6 - country/rock 14
genre_counts <- df %>% count(genre)
#Find your probability by using your exact amount of music that is in your list
genre_counts<-genre_counts %>% mutate( probility = n/144)
genre_counts
## # A tibble: 6 × 3
## genre n probility
## <chr> <int> <dbl>
## 1 Genre 1 - hiphop/rap 26 0.181
## 2 Genre 2 - pop/kpop/Latin 22 0.153
## 3 Genre 3 - house/ska 5 0.0347
## 4 Genre 4 - rnb/soul 43 0.299
## 5 Genre 5 - alt/indie/folk 34 0.236
## 6 Genre 6 - country/rock 14 0.0972
#Tried a small sample that shows the increase of the probability with less songs
sample_count <-sample_n(df, 10) %>% count(genre)
sample_count
## # A tibble: 6 × 2
## genre n
## <chr> <int>
## 1 Genre 1 - hiphop/rap 3
## 2 Genre 2 - pop/kpop/Latin 1
## 3 Genre 3 - house/ska 1
## 4 Genre 4 - rnb/soul 3
## 5 Genre 5 - alt/indie/folk 1
## 6 Genre 6 - country/rock 1
# That same sample of the 10 songs that are given a experimental probability of how likely you'll listened to it
sample_count<-sample_count %>% mutate(probility = n/10)
sample_count
## # A tibble: 6 × 3
## genre n probility
## <chr> <int> <dbl>
## 1 Genre 1 - hiphop/rap 3 0.3
## 2 Genre 2 - pop/kpop/Latin 1 0.1
## 3 Genre 3 - house/ska 1 0.1
## 4 Genre 4 - rnb/soul 3 0.3
## 5 Genre 5 - alt/indie/folk 1 0.1
## 6 Genre 6 - country/rock 1 0.1
# This will be our 2nd sample for in search of another experimental probability if we increased the number by 4 more songs
sample_count2 <-sample_n(df, 14) %>% count(genre)
sample_count2
## # A tibble: 5 × 2
## genre n
## <chr> <int>
## 1 Genre 1 - hiphop/rap 3
## 2 Genre 2 - pop/kpop/Latin 2
## 3 Genre 3 - house/ska 1
## 4 Genre 4 - rnb/soul 5
## 5 Genre 5 - alt/indie/folk 3
#This shows an increase of the probability
#This gives us the probability when we increased it by 4 more songs
sample_count2<-sample_count2 %>% mutate(probility = n/14)
sample_count2
## # A tibble: 5 × 3
## genre n probility
## <chr> <int> <dbl>
## 1 Genre 1 - hiphop/rap 3 0.214
## 2 Genre 2 - pop/kpop/Latin 2 0.143
## 3 Genre 3 - house/ska 1 0.0714
## 4 Genre 4 - rnb/soul 5 0.357
## 5 Genre 5 - alt/indie/folk 3 0.214
#This is our 3rd sample but with a much lowered number than our last test run to see what will our probability will change to and if it will increase the chances more or less
sample_count3 <-sample_n(df, 5) %>% count(genre)
sample_count3
## # A tibble: 5 × 2
## genre n
## <chr> <int>
## 1 Genre 1 - hiphop/rap 1
## 2 Genre 2 - pop/kpop/Latin 1
## 3 Genre 4 - rnb/soul 1
## 4 Genre 5 - alt/indie/folk 1
## 5 Genre 6 - country/rock 1
#Here we are given our probability for our 3rd sample
sample_count3<-sample_count3 %>% mutate(probility = n/5)
sample_count3
## # A tibble: 5 × 3
## genre n probility
## <chr> <int> <dbl>
## 1 Genre 1 - hiphop/rap 1 0.2
## 2 Genre 2 - pop/kpop/Latin 1 0.2
## 3 Genre 4 - rnb/soul 1 0.2
## 4 Genre 5 - alt/indie/folk 1 0.2
## 5 Genre 6 - country/rock 1 0.2
sample_count4 <-sample_n(df, 24) %>% count(genre)
sample_count4
## # A tibble: 6 × 2
## genre n
## <chr> <int>
## 1 Genre 1 - hiphop/rap 5
## 2 Genre 2 - pop/kpop/Latin 5
## 3 Genre 3 - house/ska 1
## 4 Genre 4 - rnb/soul 6
## 5 Genre 5 - alt/indie/folk 6
## 6 Genre 6 - country/rock 1
sample_count4<-sample_count4 %>% mutate(probility = n/24)
sample_count4
## # A tibble: 6 × 3
## genre n probility
## <chr> <int> <dbl>
## 1 Genre 1 - hiphop/rap 5 0.208
## 2 Genre 2 - pop/kpop/Latin 5 0.208
## 3 Genre 3 - house/ska 1 0.0417
## 4 Genre 4 - rnb/soul 6 0.25
## 5 Genre 5 - alt/indie/folk 6 0.25
## 6 Genre 6 - country/rock 1 0.0417
Analysis and synthesize We realized that each probability is different as the number of songs and genres change, so do the probabilities. Each of the samples were samples of an experiment of just how much do the probabilities change as they either increase or decrease making it more or less likely for that genre to play.
The use of this type of simulation is used quite often such as flipping a coin, or throwing a dice, or even weather forecasting which is all based on the probility of what is likely to happen based on passed occurrences.
This simulation of probabilities is one of many, but one that is very often known and used.