Goal: to predict the average rating of horror movies. Click here for the data

Import Data

horror_movies <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2022/2022-11-01/horror_movies.csv')
## Rows: 32540 Columns: 20
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (10): original_title, title, original_language, overview, tagline, post...
## dbl   (8): id, popularity, vote_count, vote_average, budget, revenue, runtim...
## lgl   (1): adult
## date  (1): release_date
## 
## ℹ 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.
skimr::skim(horror_movies)
Data summary
Name horror_movies
Number of rows 32540
Number of columns 20
_______________________
Column type frequency:
character 10
Date 1
logical 1
numeric 8
________________________
Group variables None

Variable type: character

skim_variable n_missing complete_rate min max empty n_unique whitespace
original_title 0 1.00 1 191 0 30296 0
title 0 1.00 1 191 0 29563 0
original_language 0 1.00 2 2 0 97 0
overview 1286 0.96 1 1000 0 31020 0
tagline 19835 0.39 1 237 0 12513 0
poster_path 4474 0.86 30 32 0 28048 0
status 0 1.00 7 15 0 4 0
backdrop_path 18995 0.42 29 32 0 13536 0
genre_names 0 1.00 6 144 0 772 0
collection_name 30234 0.07 4 56 0 815 0

Variable type: Date

skim_variable n_missing complete_rate min max median n_unique
release_date 0 1 1950-01-01 2022-12-31 2012-12-09 10999

Variable type: logical

skim_variable n_missing complete_rate mean count
adult 0 1 0 FAL: 32540

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
id 0 1.00 445910.83 305744.67 17 146494.8 426521.00 707534.00 1033095.00 ▇▆▆▅▅
popularity 0 1.00 4.01 37.51 0 0.6 0.84 2.24 5088.58 ▇▁▁▁▁
vote_count 0 1.00 62.69 420.89 0 0.0 2.00 11.00 16900.00 ▇▁▁▁▁
vote_average 0 1.00 3.34 2.88 0 0.0 4.00 5.70 10.00 ▇▂▆▃▁
budget 0 1.00 543126.59 4542667.81 0 0.0 0.00 0.00 200000000.00 ▇▁▁▁▁
revenue 0 1.00 1349746.73 14430479.15 0 0.0 0.00 0.00 701842551.00 ▇▁▁▁▁
runtime 0 1.00 62.14 41.00 0 14.0 80.00 91.00 683.00 ▇▁▁▁▁
collection 30234 0.07 481534.88 324498.16 656 155421.0 471259.00 759067.25 1033032.00 ▇▅▅▅▅
data2 <- horror_movies %>%
  
  # Treat Missing Values
  select(-tagline) %>%
  filter(budget != 0) %>%
  filter(revenue != 0) %>%
  na.omit() %>%
  
  # Log Transform Variables with Pos-Skewed Distribution
  mutate(vote_average = log(vote_average))

Explore Data

Identify good predictors

Revenue

data2 %>%
  ggplot(aes(vote_average, revenue)) +
  scale_y_log10()+
  geom_point()

Popularity

data2 %>%
  ggplot(aes(vote_average, popularity)) +
  scale_y_log10() +
  geom_point()

Budget

data2 %>%
  ggplot(aes(vote_average, budget)) +
  scale_y_log10() +
  geom_point()

EDA Shortcut

# Step 1: Prepare data
data_binarized_tbl2 <- data2 %>%
  select(-id, -original_title, -title, -overview, -poster_path, -backdrop_path, -genre_names, -collection_name, -release_date) %>%
  binarize()

data_binarized_tbl2 %>% glimpse()
## Rows: 390
## Columns: 34
## $ original_language__en                           <dbl> 1, 1, 1, 1, 1, 1, 1, 1…
## $ original_language__es                           <dbl> 0, 0, 0, 0, 0, 0, 0, 0…
## $ original_language__hi                           <dbl> 0, 0, 0, 0, 0, 0, 0, 0…
## $ original_language__ja                           <dbl> 0, 0, 0, 0, 0, 0, 0, 0…
## $ original_language__ko                           <dbl> 0, 0, 0, 0, 0, 0, 0, 0…
## $ `original_language__-OTHER`                     <dbl> 0, 0, 0, 0, 0, 0, 0, 0…
## $ `popularity__-Inf_14.8335`                      <dbl> 0, 0, 0, 0, 0, 0, 0, 0…
## $ popularity__14.8335_27.89                       <dbl> 0, 0, 0, 0, 0, 0, 0, 0…
## $ popularity__27.89_51.0185                       <dbl> 0, 0, 0, 0, 0, 0, 0, 0…
## $ popularity__51.0185_Inf                         <dbl> 1, 1, 1, 1, 1, 1, 1, 1…
## $ `vote_count__-Inf_424`                          <dbl> 1, 0, 0, 0, 0, 0, 0, 0…
## $ vote_count__424_1095.5                          <dbl> 0, 1, 0, 0, 0, 1, 0, 0…
## $ vote_count__1095.5_2517.5                       <dbl> 0, 0, 1, 1, 0, 0, 0, 0…
## $ vote_count__2517.5_Inf                          <dbl> 0, 0, 0, 0, 1, 0, 1, 1…
## $ `vote_average__-Inf_1.7227665977411`            <dbl> 0, 0, 0, 0, 0, 1, 0, 0…
## $ vote_average__1.7227665977411_1.80828877117927  <dbl> 1, 0, 0, 0, 0, 0, 0, 0…
## $ vote_average__1.80828877117927_1.88706964903238 <dbl> 0, 0, 0, 0, 0, 0, 0, 0…
## $ vote_average__1.88706964903238_Inf              <dbl> 0, 1, 1, 1, 1, 0, 1, 1…
## $ `budget__-Inf_2500000`                          <dbl> 0, 0, 0, 0, 0, 0, 0, 0…
## $ budget__2500000_8150000                         <dbl> 0, 0, 0, 0, 0, 1, 0, 0…
## $ `budget__8150000_1.9e+07`                       <dbl> 0, 1, 0, 0, 0, 0, 0, 0…
## $ `budget__1.9e+07_Inf`                           <dbl> 1, 0, 1, 1, 1, 0, 1, 1…
## $ `revenue__-Inf_10341767.5`                      <dbl> 1, 0, 0, 0, 0, 1, 0, 0…
## $ revenue__10341767.5_33900000                    <dbl> 0, 1, 0, 0, 0, 0, 0, 0…
## $ revenue__33900000_91132596.5                    <dbl> 0, 0, 0, 0, 1, 0, 0, 0…
## $ revenue__91132596.5_Inf                         <dbl> 0, 0, 1, 1, 0, 0, 1, 1…
## $ `runtime__-Inf_89`                              <dbl> 1, 0, 0, 0, 0, 0, 0, 0…
## $ runtime__89_96                                  <dbl> 0, 0, 0, 0, 0, 0, 0, 0…
## $ runtime__96_104.75                              <dbl> 0, 0, 0, 0, 0, 1, 0, 0…
## $ runtime__104.75_Inf                             <dbl> 0, 1, 1, 1, 1, 0, 1, 1…
## $ `collection__-Inf_12263`                        <dbl> 0, 0, 0, 1, 0, 0, 0, 0…
## $ collection__12263_111751                        <dbl> 1, 0, 1, 0, 0, 1, 0, 0…
## $ collection__111751_355090.5                     <dbl> 0, 0, 0, 0, 0, 0, 1, 0…
## $ collection__355090.5_Inf                        <dbl> 0, 1, 0, 0, 1, 0, 0, 1…
# Step 2: Correlate
data_corr_tbl2 <- data_binarized_tbl2 %>%
  correlate(vote_average__1.88706964903238_Inf)

data_corr_tbl2
## # A tibble: 34 × 3
##    feature           bin                               correlation
##    <fct>             <chr>                                   <dbl>
##  1 vote_average      1.88706964903238_Inf                    1    
##  2 vote_average      -Inf_1.7227665977411                   -0.335
##  3 vote_average      1.7227665977411_1.80828877117927       -0.322
##  4 vote_average      1.80828877117927_1.88706964903238      -0.318
##  5 vote_count        2517.5_Inf                              0.277
##  6 runtime           104.75_Inf                              0.263
##  7 original_language ja                                      0.185
##  8 popularity        51.0185_Inf                             0.179
##  9 collection        355090.5_Inf                            0.152
## 10 original_language en                                     -0.151
## # … with 24 more rows
# Step 3: Plot
data_corr_tbl2 %>%
  plot_correlation_funnel()