Theoretical Proabbility of each genre being played
With 144 songs on the playlist, this is the theoretical percentage
of each genre being “played”:
- Hiphop/Rap: 18%, pop/kpop/Latin: 15%, House/Ska: 4%, rnb/soul:
30%, - alt/indie/folk: 24%, country/rock: 10%.
When you play shuffle on spotify, it “randomly” selects a song from
this playlist to play. The values above show how likely it is for each
of our genres to play if you click shuffle.
df5<- sample_n(df, 10)
samp10<-df5 %>% count(genre)%>% mutate(Experimental_probability = n/sum(n))
samp10
## # A tibble: 5 × 3
## genre n Experimental_probability
## <chr> <int> <dbl>
## 1 Genre 1 - hiphop/rap 1 0.1
## 2 Genre 2 - pop/kpop/Latin 2 0.2
## 3 Genre 4 - rnb/soul 3 0.3
## 4 Genre 5 - alt/indie/folk 3 0.3
## 5 Genre 6 - country/rock 1 0.1
After Randomly generating 10 songs from our playlist, these were the
choices.
In this 10 song sample size, rnb/soul came up 3 times,
pop/kpop/Latin came up 4 times, country/rock was pulled twice, and
hiphop/rap was pulled once. Two genres were not generated in this
simulation, both house/ska, and indie/alt/folk.
With this data, we can calculate the experimental probability of
each genre picking played on shuffle
- rnb/soul 30%, alt/indie/folk 0%, pop/kpop/Latin 40%, house/ska 0%,
rock/country 20%, hiphop/rap 10%
Is this a good representaion of songs in our playlist?
I believe its too small a sample size to properally represent our
whole playlist. Pulling these 10 songs, we got no house/ska and no
indie/alt/folk, so it is difficult to say this is a proper
representation of our full playlist.
What about other sample sizes?
df2<- sample_n(df, 15)
df2
## # A tibble: 15 × 3
## genre artist title
## <chr> <chr> <chr>
## 1 Genre 4 - rnb/soul Amerie Can't Let Go
## 2 Genre 5 - alt/indie/folk Death Cab for Cutie No Sunlight
## 3 Genre 1 - hiphop/rap PnB Rock Selfish
## 4 Genre 2 - pop/kpop/Latin Taeyang Wedding dress
## 5 Genre 5 - alt/indie/folk Sorry Showgirl
## 6 Genre 1 - hiphop/rap Russ Handsomer
## 7 Genre 1 - hiphop/rap Common Be
## 8 Genre 4 - rnb/soul sza normal girl
## 9 Genre 4 - rnb/soul Beyonce Summertime
## 10 Genre 4 - rnb/soul Thee sacred souls For now
## 11 Genre 6 - country/rock Citizen Hyper Trophy
## 12 Genre 1 - hiphop/rap Ken carson Murda musik
## 13 Genre 2 - pop/kpop/Latin Post Malone Goodbyes
## 14 Genre 2 - pop/kpop/Latin renee rap tummy hurts
## 15 Genre 5 - alt/indie/folk Taylor Swift Peace
samp15<-df2 %>% count(genre)%>% mutate(Experimental_probability = n/sum(n))
samp15
## # A tibble: 5 × 3
## genre n Experimental_probability
## <chr> <int> <dbl>
## 1 Genre 1 - hiphop/rap 4 0.267
## 2 Genre 2 - pop/kpop/Latin 3 0.2
## 3 Genre 4 - rnb/soul 4 0.267
## 4 Genre 5 - alt/indie/folk 3 0.2
## 5 Genre 6 - country/rock 1 0.0667
This sample pulled 15 songs and our yeilded a different experimental
probability for each genre:
- Genre 1 - hiphop/rap 20%, Genre 2 - pop/kpop/Latin 6.6%, Genre 3 -
house/ska 6.6%, Genre 4 - rnb/soul 33.3%, Genre 5 - alt/indie/folk,
26.6%, and Genre 6 - country/rock 6.6%.
This slightly larger sample size seemed to yeild a more similar
probability to our previously calculated theorhectical probability.
What if the sample size is smaller?
df3<- sample_n(df, 5)
df3
## # A tibble: 5 × 3
## genre artist title
## <chr> <chr> <chr>
## 1 Genre 4 - rnb/soul Beyonce Summertime
## 2 Genre 4 - rnb/soul Leon Bridges River
## 3 Genre 4 - rnb/soul Sade Keep Looking
## 4 Genre 4 - rnb/soul Marvin Gaye Just to keep you satisfied
## 5 Genre 1 - hiphop/rap Kanye west Missed call
samp5<-df3 %>% count(genre)%>% mutate(Experimental_probability = n/sum(n))
samp5
## # A tibble: 2 × 3
## genre n Experimental_probability
## <chr> <int> <dbl>
## 1 Genre 1 - hiphop/rap 1 0.2
## 2 Genre 4 - rnb/soul 4 0.8
This smaller sample size is practically doomed from the start.
Simulating only five playlist shuffles, it will never be able to include
all six of our genres to accurately represent them. In reality it only
simulated four genres!
-Genre 2 - pop/kpop/Latin 20%, Genre 4 - rnb/soul 40%, Genre 5 -
alt/indie/folk 20%, Genre 6 - country/rock 20%.
In this sample size, two genres were not represented, both
House/Ska, and hiphop/rap. The experimental probability of these genres
were very different from out original theorhetical values.
All of our sample sizes so far were fairly small, and didnt
represent the original set of data closely, to test if the sample size
makes a difference on the correlation, lets try a much bigger sample
size.
df4<- sample_n(df, 50)
df4
## # A tibble: 50 × 3
## genre artist title
## <chr> <chr> <chr>
## 1 Genre 5 - alt/indie/folk Ginger Root Loretta
## 2 Genre 2 - pop/kpop/Latin renee rap tummy hurts
## 3 Genre 1 - hiphop/rap Stormzy Hide & Seek (FLO Remix)
## 4 Genre 4 - rnb/soul Lauryn Hill Tell Him
## 5 Genre 5 - alt/indie/folk Thundercat Them Changes
## 6 Genre 4 - rnb/soul Solange Don't Touch My Hair
## 7 Genre 1 - hiphop/rap Lakeyah Worst thing
## 8 Genre 6 - country/rock Dolly parton Jolene
## 9 Genre 1 - hiphop/rap Kanye West Everything I Am
## 10 Genre 1 - hiphop/rap Mac Miller Surf
## # ℹ 40 more rows
samp50<-df4 %>% count(genre)%>% mutate(Experimental_probability = n/sum(n))
samp50
## # A tibble: 6 × 3
## genre n Experimental_probability
## <chr> <int> <dbl>
## 1 Genre 1 - hiphop/rap 12 0.24
## 2 Genre 2 - pop/kpop/Latin 10 0.2
## 3 Genre 3 - house/ska 2 0.04
## 4 Genre 4 - rnb/soul 14 0.28
## 5 Genre 5 - alt/indie/folk 9 0.18
## 6 Genre 6 - country/rock 3 0.06
This sample size pulled 50 songs, around a third of the original
data. The experimental probablities were:
- Genre 1 - hiphop/rap 18%, Genre 2 - pop/kpop/Latin 16%, Genre 4 -
rnb/soul 26%, Genre 5 - alt/indie/folk 26%, Genre 6 - country/rock
14%
These values show very close correlation with our original
probabilities, although there still is a genre unrepresented: House/Ska.
This genre only had 5 songs in the whole sample size, so it was a fairly
low chance of it getting selected, but this can still show how
incorrectly sized samples cannot fairly represent data.
sampfull<-sampfull%>%select (genre, theoretic_probability)
samp50<-samp50%>%select (genre, Experimental_probability)
fulltable<-full_join(sampfull, samp50, by = "genre")
fulltable
## # A tibble: 6 × 3
## genre theoretic_probability Experimental_probability
## <chr> <dbl> <dbl>
## 1 Genre 1 - hiphop/rap 0.181 0.24
## 2 Genre 2 - pop/kpop/Latin 0.153 0.2
## 3 Genre 3 - house/ska 0.0347 0.04
## 4 Genre 4 - rnb/soul 0.299 0.28
## 5 Genre 5 - alt/indie/folk 0.236 0.18
## 6 Genre 6 - country/rock 0.0972 0.06
This final model ties in both our original theorhetical probability
calculated in the begining, as well the experimental probability for our
50 song experimental sample. Using this, it is easier to compare the two
data sets.
Analysis and Reflection:
1. Analysis
- To decide how likely each genre getting played really is, you have
to pick the sample size you believe fits the data the best.
- The larger the sample size, the more accuratte data it will
provide, so to discuss the the experimental probability, i will focus on
my 50 song sample group.
- This sample is extremly similar to the therorhetical probabiliy
origanlly calculated. The differences between the two samples is
negligable and if resimulated could show slightly different results, all
due to chance.
- This project has everything to do with data science, as we used
science to analyze our data! We collected our data and cleaned it,
analyzed it by building a model to represent what we have gathered, and
presented it in this very file.
2. Reflection
- The process of coding this project allowed me to view the original
data at the right angle to answer my question I posed at the beginning
of my research, and conclude that the songs played on shuffle reflect
the statistics fairly well, but not often exactly.
- The most challenging code I wrote throughout the project was not
specifically one section, but just remembering to name all my data,
models, and specific sections. Many times i had to go back and alter all
my code because of incorrect labelling, or somtimes none at all.
- I feel most proud of the last chunk of code because of the way it
is able to synthesize my previous models and data.
- I really love the formatting aspect of coding; seeing how all
chunks fit together in a consise way, and playing around with code until
it looks neat and tidy.
- If i were to do this project again i would like to play around
with the theme of the knit file, possible coloring and models I made, or
finding new ways to format my text.