<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/runtime-vs-success-using-imdb/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://blog.nycdatascience.com/student-works/imdb-runtime-vs-success/"> R – NYC Data Science Academy Blog</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<table>
<tbody>
<tr>
<td><img alt="Movies" src="https://i1.wp.com/github.com/TheMitchWorksPro/NYCDSA_TMWP_Shiny/blob/master/www/movies_splashimage_lite.jpg?w=450&ssl=1" data-recalc-dims="1"></td>
</tr>
</tbody>
</table>
<p>The content in this blog comes from a shiny application proof of concept using IMDB movie data.  <span>To view the application:</span></p>
<ol>
<li><a rel="nofollow" href="https://themitchworkspro.shinyapps.io/tmwp_shiny_app_-_imdb/" target="_blank"><span>IMDB Movie Data App on Shiny.io</span></a><span> (Created in R / Shiny Dashboard)</span></li>
<li><a rel="nofollow" href="https://github.com/TheMitchWorksPro/NYCDSA_TMWP_Shiny" target="_blank"><span>Source Code on Github</span></a></li>
</ol>
<h2>Background and Inspiration:</h2>
<p><span>Years ago, students of film writing were advised to make their feature length movie scripts between 90 and 129 pages.  A page is expected to be one minute of runtime, and today these numbers have been revised to a simple target of 110 minutes.  Little fun fact connected with this:  my professor tells the story of an insider’s view from development and how the decision makers at one of the giants used to pick up a screenplay, weigh it in his hands, and say “too light” or “too heavy.” Then the script was rejected without ever getting a single page read.  </span><span>Are these page length numbers arbitrary, or is there something to these guidelines?</span></p>
<h2>A Walkthrough of The Shiny App And What It Can Tell Us</h2>
<table>
<tbody>
<tr>
<td>
<p>
<div class="wp-caption"><img alt="Movie Releases by year - Small Bins" src="https://i2.wp.com/github.com/TheMitchWorksPro/NYCDSA_TMWP_Shiny/blob/master/about_project/releases_by_yr_smallBins.png?resize=380%2C366&ssl=1" data-recalc-dims="1">
<p class="wp-caption-text">Movie Releases by year – Small Bins</p>
</div>
</td>
<td>
<p>
<div class="wp-caption"><img alt="Movie Releases by Years - Big Bins" src="https://i0.wp.com/github.com/TheMitchWorksPro/NYCDSA_TMWP_Shiny/blob/master/about_project/releases_by_yr_bigBins.png?resize=380%2C370&ssl=1" data-recalc-dims="1">
<p class="wp-caption-text">Movie Releases by Years – Big Bins</p>
</div>
</td>
</tr>
</tbody>
</table>
<p><span>With the bin size set very small in the above visualizations, we can see movie releases increasing over time, with the rate accelerating much more starting in the 1970’s. Increasing the bin size from 2 to 28, further illustrates how in recent years, there are so many more movies then in the past. </span></p>
<p><span>A quick look at the history may shed a little light on what’s going on here.  The first motion pictures were created in the 1890’s and were little more than short, black and white moving images.  As the novelty of this waned, next came serial shorts from which the term “cliff hanger” originates.  When real full-length stories started to evolve, they were  expensive and hard to produce.  As a practical matter, only small numbers could be made per year. Today, the bar has been raised but technology keeps lowering the cost of what it takes to meet that bar.  Independent and ancillary markets have widened the distribution channels and even YouTube is becoming a part of this expanding network.  It’s just a matter of time before low budget movies get made on smart phones if they haven’t been already.  Nothing earth shattering here but the visualization does help show that the run-away escalation started during the time when “<em>Star Wars</em>”, “<em>Jaws</em>”, and “<em>Close Encounters of The Third Kind</em>” all made their debut.  Many see this time as “the beginning of the blockbuster.”</span></p>
<p><span>As shown here, the data used in this application is organized into 5 subsets of data:</span></p>
<table>
<tbody>
<tr>
<td>
<p>
<div class="wp-caption"><img src="https://i2.wp.com/github.com/TheMitchWorksPro/NYCDSA_TMWP_Shiny/blob/master/about_project/app_data_tab_TopAll3Ws.png?w=450&ssl=1" data-recalc-dims="1">
<p class="wp-caption-text">IMDB Shiny App – Data Tab</p>
</div>
</td>
</tr>
</tbody>
</table>
<p><span>There is some overlap in the data sets shown on the application’s “Data” tab:</span></p>
<ol>
<li><span>The 5270 “Kaggle 5000 Project IDs” data set contains the results of merging 5000 movies whose IDs were obtained from a “Kaggle” project with the unique IDs from all the other data sets described above.  The “Kaggle Project IDs” included a sample of releases from 1916 up until 2016. </span></li>
<li><span>The other data sets came from Top and Bottom lists on IMDB.  Most of the Top 250 English Movies were also in the “Top 250 Movies”.  Some of the “Top 250 Indian Movies” are also in the “Top 250 Movies”.  The Bottom 100 should only overlap with the “Kaggle” data set.  Movies in these lists include titles from 2017.</span></li>
</ol>
<p><span>Click on the “Visualization” tab of </span><a rel="nofollow" href="https://themitchworkspro.shinyapps.io/tmwp_shiny_app_-_imdb/" target="_blank"><span>the app</span></a><span> to obtain basic stats on each of the aforementioned  datasets (Min, Max, Mean, Median and Quartiles) for these 4 numeric variables:</span></p>
<ol>
<li><span>Year Released</span></li>
<li><span>Runtime (in minutes)</span></li>
<li><span>Number of Reviews</span></li>
<li><span>Movie Rating</span></li>
</ol>
<p><span>This tab also provides a line plot using </span><a rel="nofollow" href="https://en.wikipedia.org/wiki/Local_regression" target="_blank"><span>Loess</span></a><span> linear regression which we can analyze for the general trend in movie runtimes that we are looking for.  </span></p>
<div class="wp-caption"><img src="https://i2.wp.com/github.com/TheMitchWorksPro/NYCDSA_TMWP_Shiny/blob/master/about_project/Loess_Line_K5000All.png?w=450&ssl=1" alt="Line Plot of " data-recalc-dims="1">
<p class="wp-caption-text">“Kaggle 5000 Project IDs” Record Set (All of Our Data)</p>
</div>
<p><span>If we start with the plot for “all the data” in our application, outliers are mostly clustered pretty close to the general confidence interval for the model.  No outliers outside this range appear after 1990, and only a small number of points barely outside the confidence interval appear from 1960 to 1990.</span></p>
<p><span>Since there is a limited outlier effect, the mean seems like a reasonable metric.  It is 109.2 minutes. Of more interest to the original question, this plot essentially reflects a 5000+ record sample of what got made.  The hills and valleys of the line seem to range between 105 and 120 minutes up through the 1970’s.  Then the line becomes a slightly downward sloping trend up through the present with our data points mostly appearing at around the 110 minute mark. Though anecdotal in nature, the original 110 minute recommendation for movie scripts would seem to be supported by the data.  The confidence interval around the line though might suggest a range from about 100 to 120 minutes.  </span><span>If our movie gets made, we may then be concerned with what are its chances of making it into the top or bottom? Starting with the Top 250 Movies:</span></p>
<div class="wp-caption"><img alt="Line plot of Top 250 Movies (On IMDB)" src="https://i2.wp.com/github.com/TheMitchWorksPro/NYCDSA_TMWP_Shiny/blob/master/about_project/Loess_Line_Top250.png?w=450&ssl=1" data-recalc-dims="1">
<p class="wp-caption-text">Top 250 Movies (On IMDB)</p>
</div>
<p><span>The mean for the Top 250 movies was 130 minutes.  The curve trends upwards over all with a range in recent years (1990 to the present) that fell between: 130 and 140 minutes.  There are a larger scattering of outliers on this plot, but based on how the outliers mostly cluster not too far from the confidence interval after 1990, the mean still seems reasonable to use.  If we think about why these better received movies are often longer than the general trend for what gets made, I’m sure there are many factors involved.  For one thing, big name director and  producers have the kind of clout to make us sit through longer movies.  Consider “<em>The Lord of The Rings</em>” saga, which collectively was over 9 hours long with each of 3 movies lasting in the range of 3 hours a piece.</span></p>
<p><span>We don’t want to end up in the bottom, so we’ll take a look at this too:</span></p>
<div class="wp-caption"><img alt="Line Plot of 100 Bottom Movies (on IMDB)" src="https://i0.wp.com/github.com/TheMitchWorksPro/NYCDSA_TMWP_Shiny/blob/master/about_project/Loess_Line_Bottom100.png?w=450&ssl=1" data-recalc-dims="1">
<p class="wp-caption-text">Bottom 100 Movies (on IMDB)</p>
</div>
<p><span>The mean for the Bottom 100 movies was 92.26 minutes.  This curve is also showing a distinct upwards trend over all but with a range in recent years (1990 to the present) that was from about 90 minutes to 115 minutes.  There are fewer outliers, but there is also less data in this grouping.</span></p>
<h2>In Conclusion</h2>
<p>Note that for this application about 6000 <a rel="nofollow" href="http://www.imdb.com/" target="_blank">IMDB</a> records were obtained. In 2017 alone, IMDB recorded <a rel="nofollow" href="http://www.imdb.com/search/title?year=2017,2017&title_type=feature&view=advanced&page=7&sort=release_date,desc&ref_=adv_nxt" target="_blank">12,193</a> new releases by July and the year is still young!   Further analysis is indicated and performing the analysis with more data would also be helpful.  Given the small size of the data, findings here should not be taken as an absolute.  Given that, here is a summary of what the data suggests so far:</p>
<ol>
<li>The “Sweet Spot” to target for a feature length screen play to get made is about 110 minutes</li>
<li>If we want that movie to make it into the Top 250 on IMDB, the final movie produces is expected to range from 130 to 140 minutes</li>
<li>It is also interesting to note that movies in the bottom 100 tend to range between 90 and 115 minutes</li>
</ol>
<p><span>With more time and development, a more thorough analysis could be developed from IMDB data.</span></p>
<h2>The Data Collection Process</h2>
<p><a rel="nofollow" href="https://github.com/TheMitchWorksPro/NYCDSA_TMWP_Shiny/tree/master/data_srv" target="_blank"><span>Three R markdown scripts</span></a><span> (available on Git) were used to gather source data.  A full workflow from initial input files to what got used in the application is provided in the </span><a rel="nofollow" href="https://github.com/TheMitchWorksPro/NYCDSA_TMWP_Shiny/blob/master/data_srv/IMDB_Data3_Munging.Rmd" target="_blank"><span>third script</span></a><span>.  As this process was experimentally developed and modified while creating the source data for this project, R markdown was used to step through the process and keep notes on what was going.  High level:</span></p>
<ol>
<li><span>An XML based R library was used to screen scrape data from “hot lists” (Top 250, Bottom 100, etc.) directly off of the IMDB website in July of 2017. This produced ‘csv’ files used as source for all the “Top / Bottom” lists provided in the final application.</span></li>
<li><span>5000+ IMDB IDs were extracted using a software process (not documented) from a json file posted with a Kaggle project.  That project last gathered data in 2016.  IDs from steps 1 and 2 were then used with step 3 to extract current data on these IDs.</span></li>
<li><span>An Open API referred to as “IMDB Open API” was used to extract records from the IMDB website one record at a time, with a 3 second delay between each extraction.  This was to ensure no harm to the website.  This script was designed to save its work “along the way” and provide helpful output messages so that if an error occurred that halted the program.  Data collected so far would be available, and the script could then pick up where it left off to finish the job.</span></li>
<li><span>Close to 6000 observations in total (5270 after filtering out of duplicates) w/ about 27  variables were obtained from IMDB.</span></li>
<li><span>Data cleaning of just the 7 variables brought into the Shiny application ensued with the intent to clean other variables in future development iterations.  The vision was to develop subset tables with Movie_IDs on each one as a unique identifier, and then join them to previous data when bringing in each new set to expand the app in support of new analysis and features.</span></li>
</ol>
<h2>The Initial Plan for this Project</h2>
<p><span>The CEO of a company I used to work for would tell stories of how senior management of various IT areas under him would plan and design solutions on a napkin in a bar which formed the basis of software project requirements.  For this shiny app, the “napkin” was actually a piece of notebook paper captured as a </span><a rel="nofollow" href="https://github.com/TheMitchWorksPro/NYCDSA_TMWP_Shiny/blob/master/about_project/Initial_Planning_Napkin.pdf" target="_blank"><span>PDF</span></a><span> for your amusement.  Only a small piece of this plan has been realized so far.</span></p>
<p>The post <a rel="nofollow" href="http://blog.nycdatascience.com/student-works/imdb-runtime-vs-success/" target="_blank">Runtime vs. Success (Using IMDB)</a> appeared first on <a rel="nofollow" href="http://blog.nycdatascience.com/" target="_blank">NYC Data Science Academy Blog</a>.</p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://blog.nycdatascience.com/student-works/imdb-runtime-vs-success/"> R – NYC Data Science Academy Blog</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/6Ms83E9HAIA" height="1"></a></div>