<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.7.3">Jekyll</generator><link href="https://jblinder.github.io//feed.xml" rel="self" type="application/atom+xml" /><link href="https://jblinder.github.io//" rel="alternate" type="text/html" /><updated>2018-08-14T01:42:49+00:00</updated><id>https://jblinder.github.io//</id><title type="html">Justin Blinder</title><subtitle>Data Science Deep Dive</subtitle><entry><title type="html">Ghost Lots: Can urban infrastructural data help predict imminent development?</title><link href="https://jblinder.github.io//Ghost-Lots/" rel="alternate" type="text/html" title="Ghost Lots: Can urban infrastructural data help predict imminent development?" /><published>2018-05-22T00:00:00+00:00</published><updated>2018-05-22T00:00:00+00:00</updated><id>https://jblinder.github.io//Ghost-Lots</id><content type="html" xml:base="https://jblinder.github.io//Ghost-Lots/">&lt;p&gt;&lt;img src=&quot;/images/project03/research-2.jpeg&quot; alt=&quot;Noise&quot; height=&quot;75%&quot; width=&quot;75%&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;h1 id=&quot;ghost-lots&quot;&gt;Ghost Lots&lt;/h1&gt;
&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;
&lt;p&gt;Between 2002 and 2013, the Bloomberg administration rezoned 37% of the New York City as part of a new development policy. Belowis an actual pamphlet from that proposal— The areas in red are those to be rezoned. Many now directly tie this rezoning to rapid, widespread displacement in NYC.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/project03/research-1.jpeg&quot; alt=&quot;Noise&quot; height=&quot;75%&quot; width=&quot;75%&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;In the past, vacant lots have been signs of both blight and development potential. Given this recent, dramatic rezoning history, can vacant lots be used as predictors for new development?&lt;/p&gt;

&lt;h2 id=&quot;data&quot;&gt;Data&lt;/h2&gt;
&lt;p&gt;The main dataset I used for this research is the &lt;a href=&quot;https://www1.nyc.gov/site/planning/data-maps/open-data/dwn-pluto-mappluto.page&quot;&gt;NYC PLUTO&lt;/a&gt; dataset, which contains tax lot level data about most properties in all 5 boroughs. Brooklyn was the main focus for the first iteration.&lt;/p&gt;

&lt;h2 id=&quot;analysis&quot;&gt;Analysis&lt;/h2&gt;
&lt;p&gt;One of the first analyses was to see the geographic distribution of vacant lots— here we can see that the majority of the distribution lies in industrial areas like ports, and along the north and northeast neighborhoods.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/project03/eda-2.jpeg&quot; alt=&quot;Noise&quot; height=&quot;75%&quot; width=&quot;75%&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The main outcome I wanted to predict is whether a lot that’s currently vacant will convert to a building in the future. To predict this, I had to engineer a dependent variable that determines if existing buildings in 2017 used to be vacant in the 2013 version of the PLUTO dataset.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/project03/eda-3.jpeg&quot; alt=&quot;Noise&quot; height=&quot;75%&quot; width=&quot;75%&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;modeling&quot;&gt;Modeling&lt;/h2&gt;

&lt;p&gt;Modeling was tricky because of the state of my data. There were vastly fewer vacant lots that converted since 2013 than those that remained vacant, around 3%. Using smote helped a little, but these steps were not very effective.&lt;/p&gt;

&lt;p&gt;The two best performing models were Logistic and Random Forest models, the latter proving best on both precision and recall.&lt;/p&gt;

&lt;p&gt;There is some trade-off between precision and recall. Since it was key to not miss vacant lots that might convert, recall was more important. Additionally, finding false positives would likely be it wouldn’t hurt their efforts.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/project03/performance-1.jpeg&quot; alt=&quot;Noise&quot; height=&quot;75%&quot; width=&quot;75%&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Among the top important features were the number of buildings on a lot, the total value of assessed land, and building area.&lt;/p&gt;

&lt;h2 id=&quot;predictions&quot;&gt;Predictions&lt;/h2&gt;

&lt;p&gt;After validating the model, my next step was to run predictions for all of the currently vacant lots in Brooklyn. One area that the model seemed to do well in was Red Hook and Gowanus. Red Hook has been massively developed for a number of years, and Mayor Bill DeBlasio will soon rezone Gowanus for more mixed us and residential building. As we can see here, most of the vacant lots in both neighborhoods were highly predicted as being developed in the next 4 years.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/project03/prediction-1.jpeg&quot; alt=&quot;Noise&quot; height=&quot;75%&quot; width=&quot;75%&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/project03/prediction-2.jpeg&quot; alt=&quot;Noise&quot; height=&quot;75%&quot; width=&quot;75%&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;One area where model results seemed a bit more suspect was Downtown Brooklyn, which has also been massively developed in the past decade. Right around the Barclays Center and Fort Greene Park, there were a significant number of lots that were predicted as not being developed in the next 4 years. We’re interested in trying to find what variables might be playing a role in these particular predictions.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;As the city and third-parties release more nuanced types of civic data, it’s interesting to consider what might be emmerging markers of impending development. For instance, citi bikes, public wifi, potholes, and surveillance cameras might be telling signifiers of urban shifts. A future direction for this project will be exploring these trace data points.&lt;/p&gt;</content><author><name></name></author><summary type="html"></summary></entry><entry><title type="html">SubText: Exploring temporal dialogue changes in movies</title><link href="https://jblinder.github.io//SubText/" rel="alternate" type="text/html" title="SubText: Exploring temporal dialogue changes in movies" /><published>2018-04-28T00:00:00+00:00</published><updated>2018-04-28T00:00:00+00:00</updated><id>https://jblinder.github.io//SubText</id><content type="html" xml:base="https://jblinder.github.io//SubText/">&lt;p&gt;&lt;img src=&quot;/images/project02/noise.jpg&quot; alt=&quot;Noise&quot; height=&quot;75%&quot; width=&quot;75%&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;h1 id=&quot;introduction&quot;&gt;Introduction&lt;/h1&gt;
&lt;p&gt;In 2013, reporters revealed that cable networks have been speeding up older TV shows and movies to make room for more advertisements. For example, &lt;em&gt;I Love Lucy&lt;/em&gt; episodes have an average runtime of 30 minutes; in contrast, &lt;em&gt;The Big Bang Theory&lt;/em&gt; averages at 22 minutes per episode. This model translates to other contemporary platforms as well, such as YouTube and Twitch, where content creators compete for viewers’ attention by producing shorter content. Essentially, today’s movies and TV shows are conceived of and written with de facto compression, but we don’t often consider how this informs the media content we consume.&lt;/p&gt;

&lt;p&gt;This research led to a few key questions I wanted to explore:&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;Is the pace of movie dialogue getting faster over time? 
Are movies becoming “talkier” in a specific way– with fewer scenes without dialogue, and shorter pauses? 
Will future films follow this trend, and what variables can predict this?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;img src=&quot;/images/project02/unnoise.jpg&quot; alt=&quot;UnNoise&quot; height=&quot;75%&quot; width=&quot;75%&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;
&lt;h1 id=&quot;datasets&quot;&gt;Datasets&lt;/h1&gt;

&lt;p&gt;I focused on the top-grossing and top-rated films from the 20th and 21st centuries. I used Scrapy to screen scrape the data from &lt;a href=&quot;imdb.com&quot;&gt;IMDB&lt;/a&gt;. To acquire additional financial information, I also scraped movie financial data from &lt;a href=&quot;thenumbers.com&quot;&gt;The Numbers&lt;/a&gt; and &lt;a href=&quot;boxofficemojo.com&quot;&gt;Box Office Mojo&lt;/a&gt;. Some of the final fields I relied on were:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Domestic gross&lt;/li&gt;
  &lt;li&gt;Worldwide gross&lt;/li&gt;
  &lt;li&gt;MPAA rating&lt;/li&gt;
  &lt;li&gt;Runtime&lt;/li&gt;
  &lt;li&gt;Release data/ year&lt;/li&gt;
  &lt;li&gt;Genre&lt;/li&gt;
  &lt;li&gt;Number of critic reviews&lt;/li&gt;
  &lt;li&gt;IMDB rating&lt;/li&gt;
  &lt;li&gt;Popularity&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Determining the dialogue speed of movies proved a bit trickier task. I relied on a widely adopted file format called SubRip (.srt) to extract this information. SupRip files are used by media players to show a film’s corresponding subtitles. Viewers can download them in a variety of languages. The file contains 4 fields for each line of dialogue:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Number of line&lt;/li&gt;
  &lt;li&gt;Start time of line&lt;/li&gt;
  &lt;li&gt;End time of line&lt;/li&gt;
  &lt;li&gt;Dialogue text&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I built a scraper using Scrapy that went through each title on IMDB and performed a search on &lt;a href=&quot;subscene.com&quot;&gt;Subscene&lt;/a&gt; and &lt;a href=&quot;podnapisi.com&quot;&gt;Podnapisi&lt;/a&gt; (two SubRip aggregators). If a match was found, the script would download the file (which was zip compressed), unzip the file, put it into a directory, and delete the zip file. I built another script to parse each &lt;code class=&quot;highlighter-rouge&quot;&gt;.srt&lt;/code&gt; file, merge in the corresponding movie title, and convert it to a &lt;code class=&quot;highlighter-rouge&quot;&gt;.csv&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(Before Conversion)&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;1
00:02:32,276 --&amp;gt; 00:02:33,902
Rosebud.

2
00:03:12,276 --&amp;gt; 00:03:14,276
News on the March.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;(After Conversion)&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;| id | start_time | end_time | duration | pause | text                | title        | 
|----|------------|----------|----------|-------|---------------------|--------------|
| 1  | 2327       | 2339     | 300      | 2327  | Rosebud.            | Citizen Kane |
| 2  | 3122       | 3142     | 2000     | 783   | News on the march.  | Citizen Kane |
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I calculated the line duration by subtracting each end time from the start time. The pause was calculated by subtracting each line’s start time from the previous line’s end time. Overall, I scraped roughly 2000 films and subtitles.&lt;/p&gt;

&lt;h1 id=&quot;analysis&quot;&gt;Analysis&lt;/h1&gt;

&lt;p&gt;Initially, I wanted to look at a few individual films to see what the dialogue pacing looked like throughout. I decided to use Alfred Hitchcock’s &lt;em&gt;Vertigo&lt;/em&gt; (1958) as a test case. I immediately saw that there was a 15-minute section in the movie that had no dialogue and thought my code might be broken. However, I checked/ watched part of the film and realized that this long, silent scene was indeed in the film. I compared this film to a few other popular films from different decades and genres and noticed that the dialogue pacing does seem to shift quite dramatically depending on the year and genre. &lt;em&gt;(Here, the x-axis represents each minute of the film and the y -xis is the average dialogue length per minute.)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/project02/vertigo.png.png&quot; alt=&quot;vertigo&quot; height=&quot;50%&quot; width=&quot;50%&quot; /&gt; Vertigo (1958)
&lt;img src=&quot;/images/project02/thegodfather.png&quot; alt=&quot;thegodfather&quot; height=&quot;50%&quot; width=&quot;50%&quot; /&gt;  The Godfather (1974)
&lt;img src=&quot;/images/project02/Gaurdians.png&quot; alt=&quot;Gaurdians&quot; height=&quot;50%&quot; width=&quot;50%&quot; /&gt; Gaurdians of the Galaxy (2014)
&lt;img src=&quot;/images/project02/americansniper.png&quot; alt=&quot;americansinper&quot; height=&quot;50%&quot; width=&quot;50%&quot; /&gt; American Sniper (2014)&lt;/p&gt;

&lt;p&gt;For instance, &lt;em&gt;The Godfather&lt;/em&gt; has fairly long lines of dialogue and a good amount of pauses, which makes sense given the film’s dramatic pacing. In comparison, &lt;em&gt;Guardians of the Galaxy&lt;/em&gt; has almost half the length of dialogue in many scenes and very short gaps between dialogue, which is what we would expect from an action film.&lt;/p&gt;

&lt;p&gt;I also wanted to see how the pacing of movies has changed over the course of multiple years. For this, I grouped movies by year and calculated the median number length of line dialogue for each year. I graphed this between 1930-2017.
&lt;img src=&quot;/images/project02/median.png&quot; alt=&quot;years&quot; height=&quot;75%&quot; width=&quot;75%&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I found this very promising since it showed an overall downward trend– It was also intriguing that the pacing fell sharply in 2008.&lt;/p&gt;

&lt;p&gt;The next step was to see if there were any strong correlations in the fields I was analyzing. I ran a correlation table on my data (here, shown as a heatmap using the Seaborn graphing library).&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/project02/heat-map.png&quot; alt=&quot;heatmap&quot; height=&quot;75%&quot; width=&quot;75%&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;There was a very strong relationship between the line duration and the number of IMDB critic reviews and the year a film was released. I noted this as I continued onto my next step of creating a model.&lt;/p&gt;

&lt;h1 id=&quot;modeling&quot;&gt;Modeling&lt;/h1&gt;

&lt;p&gt;I used used statsmodels and patsy to create my first model. I plugged in all of my data fields, which included numericals like financial data and categoricals like genre and MPAA rating. I ran a summary to see if there were any coefficients that appeared to have stronger relationships to line duration than others. Year clearly had the lowest p-value and still stood as out as a potentially strong indicator of line duration.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/project02/coef.png&quot; alt=&quot;coef&quot; height=&quot;75%&quot; width=&quot;75%&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I also wanted to see what my residuals looked like to see if there was any heteroskedasticity, and if perhaps I was missing some key variables. It appeared that the residuals were fairly randomly dispersed, and have a fairly even distribution above and below the 0 axis.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/project02/resid.png&quot; alt=&quot;resid&quot; height=&quot;75%&quot; width=&quot;75%&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The plotted best fit lines showed a downward trend in the data. However, I didn’t take too much stock in the model’s predictive power just yet, as the r-squared was &lt;code class=&quot;highlighter-rouge&quot;&gt;.22&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/project02/fit.png&quot; alt=&quot;fit&quot; height=&quot;75%&quot; width=&quot;75%&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I then wanted to see if there were key features I should keep in that could improve my model. I used LASSO to see which coefficents are stronger predictors in my model. This revealed that year and number of IMDB critic reviews were strongly correlated with line duration. Also, Comedy appeared to have faster line dialogue, whereas Fantasy, Musical, and Mystery had slower dialogue. This seemed consistent with my conjectures. When I tried to optimize my coefficient using LASSO, I received an r-squared of &lt;code class=&quot;highlighter-rouge&quot;&gt;.19&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/project02/lasso.png&quot; alt=&quot;fit&quot; height=&quot;75%&quot; width=&quot;75%&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;h1 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h1&gt;

&lt;p&gt;Overall, the data suggests that dialogue pacing is becoming faster over time. Year appeared to be the strongest predictor for predicting dialogue pace, followed by the number of IMDB critic reviews and American films. In terms of genres, comedies, family, and animated films appeared to be related to faster dialogue. Mystery, fantasy, drama, and musicals corresponded to longer dialogue.&lt;/p&gt;

&lt;p&gt;In the future, I’d like to explore creating a unique index for dialogue pacing. This feature was very hard to understand when first viewing the project, so creating a “pace index” might help abstract and communicate it better. I’m also interested in seeing if sentiment analysis might highlight any hidden relationships or trends in the data.&lt;/p&gt;

&lt;p&gt;I would like to collect more data and conduct further analyses to gauge whether the sharp decline in pacing in 2008 remains consistent. If so, it would be interesting to explore supplemental qualitative research, since this was right around the time the iPhone was released and Google acquired Youtube. With sufficient additional data, it would also be interesting to analyze whether the change in slope around 2008 suggests that some sort of “intervention” accurred around then, and whether this model might be better interpreted as a sort of interrupted time series, rather than traditional linear regression.&lt;/p&gt;

&lt;p&gt;You can get the code for SubText on &lt;a href=&quot;https://github.com/jblinder/subtext&quot;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;</content><author><name></name></author><summary type="html"></summary></entry></feed>