<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/using-nyc-citi-bike-data-to-help-bike-enthusiasts-find-their-mate/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://blog.nycdatascience.com/student-works/r-visualization/using-nyc-citi-bike-data-help-bike-enthusiasts-find-mate-dating-app/"> 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>
<p><span>There is no shortage of analyses on the NYC bike share system. Most of them aim at predicting the demand for bikes and balancing bike stock, i.e forecasting when to remove bikes from fully occupied stations, and refill stations before the supply runs dry.</span></p>
<p> </p>
<p><span>This is why I decided to take a different approach and use the Citi Bike data to help its users instead.</span></p>
<p> </p>
<h2><span>The Challenge</span></h2>
<p><span><a target="_blank" rel="nofollow" href="https://i1.wp.com/blog.nycdatascience.com/wp-content/uploads/2017/04/citibike_citiTinder2.jpg"><img sizes="(max-width: 458px) 100vw, 458px" alt="citibike_citiTinder2" class="wp-image-21036" src="https://i1.wp.com/blog.nycdatascience.com/wp-content/uploads/2017/04/citibike_citiTinder2.jpg?w=450" data-recalc-dims="1"></a>The online dating scene is complicated and unreliable: there is a discrepancy between what online daters say and what they do. Although this challenge is not relevant to me anymore – I am married – I wished that, as a bike enthusiast, I had a platform where I could have spotted like-minded people who did ride a bike (and not just pretend they did).</span></p>
<p><span>The goal of this project was to turn the Citi Bike data into an app where a rider could identify the best spots and times to meet other Citi Bike users and cyclists in general.</span></p>
<p> </p>
<p> </p>
<h2><span>The Data</span></h2>
<p><span><a target="_blank" rel="nofollow" href="https://i1.wp.com/blog.nycdatascience.com/wp-content/uploads/2017/04/map.png"><img sizes="(max-width: 420px) 100vw, 420px" alt="map" class="wp-image-21035" src="https://i1.wp.com/blog.nycdatascience.com/wp-content/uploads/2017/04/map.png?resize=420%2C531" data-recalc-dims="1"></a>As of March 31, 2016, the total number of annual subscribers was 163,865, and Citi Bike riders took an average of 38,491 rides per day in 2016 (source: <a target="_blank" rel="nofollow" href="https://en.wikipedia.org/wiki/Citi_Bike">wikipedia)</a></span></p>
<p><span>This is more than 14 million rides in 2016!</span></p>
<p><span>I used the Citi Bike data for the month of May 2016 (approximately 1 million observations). Citi Bike provides the following variables:</span></p>
<div>
<ul>
<li><span>Trip duration (in seconds).</span></li>
<li><span>Timestamps for when the trip started and ended.</span></li>
<li><span>Station locations for where the trip started and ended (both the names and coordinates).</span></li>
<li><span>Rider’s gender and birth year – this is the only demographic data we have.</span></li>
<li><span>Rider’s plan (annual subscriber, 7-day pass user or 1-day pass user).</span></li>
<li><span>Bike ID.</span></li>
</ul>
</div>
<h2><span> </span></h2>
<h2></h2>
<h2><span>Riders per Age Group</span></h2>
<p><span>Before moving ahead with building the app, I was interested in exploring the data and identifying patterns in relation to gender, age and day of the week. Answering the following questions helped identify which variables influence how riders use the Citi Bike system and form better features for the app:</span></p>
<div>
<ul>
<li><span>Who are the primary users of Citi Bike?</span></li>
<li><span>What is the median age per Citi Bike station?</span></li>
<li><span>How do the days of the week impact biking behaviours?</span></li>
</ul>
</div>
<p><span>As I expected, based on my daily rides from Queens to Manhattan, 75% of the Citi Bike trips are taken by males. The primary users are 25 to 24 years old.</span></p>
<p><a target="_blank" rel="nofollow" href="https://i0.wp.com/blog.nycdatascience.com/wp-content/uploads/2017/04/ridersperage.png"><img sizes="(max-width: 1153px) 100vw, 1153px" alt="ridersperage" class="wp-image-21039" src="https://i0.wp.com/blog.nycdatascience.com/wp-content/uploads/2017/04/ridersperage.png?w=450" data-recalc-dims="1"></a></p>
<p><em>Riders per Age Group</em></p>
<p> </p>
<h2><span>Distribution of Riders per Hour of the Day (weekdays)</span></h2>
<p><span>However, while we might expect these young professionals to be the primary users during the weekdays around 8-9am and 5-6pm (when they commute to and from work), and the older audience to take over the Citi Bike system midday, this hypothesis proved to be wrong. The tourists don’t have anything to do with it; the short term customers only represent 10% of the dataset.</span></p>
<p><span><a target="_blank" rel="nofollow" href="https://i1.wp.com/blog.nycdatascience.com/wp-content/uploads/2017/04/agegroupdistribution.png"><img sizes="(max-width: 1177px) 100vw, 1177px" alt="agegroupdistribution" class="wp-image-21026" src="https://i1.wp.com/blog.nycdatascience.com/wp-content/uploads/2017/04/agegroupdistribution.png?w=450" data-recalc-dims="1"></a></span></p>
<p><span><em>Distribution of Riders per Hour of the Day (weekdays only)</em></span></p>
<p> </p>
<h2><span>Median Age per Departure Station</span></h2>
<p><span>Looking at the median age of the riders for each station departure, we see the youngest riders in East Village, while older riders start their commute from Lower Manhattan (as shown in the map below). The age trends disappear when mapping the station arrival, above all in the financial district (in Lower Manhattan), which is populated by the young wolves of Wall Street (map not shown).</span></p>
<p><span>The map also confirms that the Citi Bike riders are mostly between 30 and 45 years old.</span></p>
<p><span><a target="_blank" rel="nofollow" href="https://i0.wp.com/blog.nycdatascience.com/wp-content/uploads/2017/04/medianage.png"><img sizes="(max-width: 730px) 100vw, 730px" alt="medianage" class="wp-image-21025" src="https://i0.wp.com/blog.nycdatascience.com/wp-content/uploads/2017/04/medianage.png?w=450" data-recalc-dims="1"></a></span></p>
<p><span><em>Median Age per Departure Station</em></span></p>
<p> </p>
<p> </p>
<h2><span>Rides by Hour of the Day</span></h2>
<p><span>Finally, when analyzing how the days of the week impacted biking behaviours, I was surprised to see that Citi Bike users didn’t ride for a longer period of time during the weekend: the median trip duration is 19 minutes for each day of the week.</span></p>
<p><a target="_blank" rel="nofollow" href="https://i0.wp.com/blog.nycdatascience.com/wp-content/uploads/2017/04/tripdurationperminute.png"><img sizes="(max-width: 1182px) 100vw, 1182px" alt="tripdurationperminute" class="wp-image-21040" src="https://i0.wp.com/blog.nycdatascience.com/wp-content/uploads/2017/04/tripdurationperminute.png?w=450" data-recalc-dims="1"></a></p>
<p><em>Trip Duration per Gender and Age Group</em></p>
<p> </p>
<p><span>However, as illustrated below, there is a difference in peak hours; during the weekend, riders hop on a bike later during the day, with most of the rides happening midday while the peak hours during the weekdays are around 8-9am and 5-7pm when riders commute to and from work.</span></p>
<p> </p>
<p><a target="_blank" rel="nofollow" href="https://i2.wp.com/blog.nycdatascience.com/wp-content/uploads/2017/04/weekday_weekend.png"><img sizes="(max-width: 1395px) 100vw, 1395px" alt="weekday_weekend" class="wp-image-21027" src="https://i2.wp.com/blog.nycdatascience.com/wp-content/uploads/2017/04/weekday_weekend.png?w=450" data-recalc-dims="1"></a></p>
<p><span><em>Number of Riders per Hour of the Day (weekdays vs. weekends)</em></span></p>
<p> </p>
<p> </p>
<h2><span>The App</span></h2>
<p><span><strong>Where does this analysis leave us?</strong></span></p>
<div>
<ul>
<li><span>The day of the week and the hour of the day are meaningful variables which we need to take into account in the app.</span></li>
<li><span><span>Most of the users are between 30 and 45 years. This means that the age groups 25-34 and 35-44 won’t be granular enough when app users need to filter their search. We will let them filter by age instead.</span></span></li>
</ul>
<p> </p>
<p><strong><span><span>The Citi Tinder app in a few words and screenshots.</span></span></strong></p>
<p><span>There are 3 steps to the app:</span></p>
<ul>
<li><span>The “<strong>when</strong>“: find the times and days where your ideal mate is more likely to ride.</span></li>
</ul>
<p><a target="_blank" rel="nofollow" href="https://i2.wp.com/blog.nycdatascience.com/wp-content/uploads/2017/04/step1_when.png"><img sizes="(max-width: 1227px) 100vw, 1227px" alt="step1_when" class="wp-image-21041" src="https://i2.wp.com/blog.nycdatascience.com/wp-content/uploads/2017/04/step1_when.png?w=450" data-recalc-dims="1"></a></p>
<p> </p>
<ul>
<li><span>The “<strong>where</strong>“: once you know the best times and days, filter out the location by day of the week, time of the day, gender and age. You can also select if you want to spot where they arrive or depart.<a target="_blank" rel="nofollow" href="http://blog.nycdatascience.com/wp-content/uploads/2017/04/step3_how.png"><br>
</a></span></li>
</ul>
<p><img sizes="(max-width: 1228px) 100vw, 1228px" alt="step2_where" class="wp-image-21043" src="https://i2.wp.com/blog.nycdatascience.com/wp-content/uploads/2017/04/step2_where.png?w=450" data-recalc-dims="1"></p>
<p> </p>
<ul>
<li><span>The “<strong>how</strong>‘: the final step is to grab a Citi Bike and get to those hot spots. The app calls the Google Maps API to show the directions with a little extra: you can compare the time estimated by Google to connect two stations versus the average time it took Citi Bike users. I believe the latter is more accurate because it factors in the time of the day and day of the week (which the app let you filter).</span></li>
</ul>
<p><img sizes="(max-width: 1223px) 100vw, 1223px" alt="step3_how" class="wp-image-21042" src="https://i1.wp.com/blog.nycdatascience.com/wp-content/uploads/2017/04/step3_how.png?w=450" data-recalc-dims="1"></p>
<p> </p>
<p><span>Although screenshots are nice, the interactive app is better so <strong><a target="_blank" rel="nofollow" href="https://claire-vk.shinyapps.io/project1_citibike_lowres/">head to the first step of the app to get started!</a></strong></span></p>
</div>
<p> </p>
<p> </p>
<h2><span>Would Have, Should Have, Could Have</span></h2>
<p><span>This is the first of the four projects from the NYC Data Science Academy Data Science Bootcamp program. With a two-week timeline and only 24 hours in a day, some things gotta give… Below is a quick list of the analysis I could have, would have and should have done if given more time and data:<a target="_blank" rel="nofollow" href="https://i1.wp.com/blog.nycdatascience.com/wp-content/uploads/2017/04/yeahbike.jpg"><img sizes="(max-width: 419px) 100vw, 419px" alt="yeahbike" class="wp-image-21045" src="https://i1.wp.com/blog.nycdatascience.com/wp-content/uploads/2017/04/yeahbike.jpg?resize=419%2C466" data-recalc-dims="1"></a></span></p>
<div>
<ul>
<li><span><strong>Limited scope</strong> : I only took the data from May 2016. However, I expect the Citi Bike riders to behave differently depending on the season, temperature, etc. Besides, the bigger the sample size the more reliable the insights are.</span></li>
<li><span><strong>Missing data</strong> : There was no data on the docks available per station that could be scraped from the Citi Bike website. The map would have been more complete if the availability of docks had been displayed.</span></li>
<li><span><strong>Limited number of variables</strong> : I would have liked to have more demographics data (aside from gender and age); a dating app with only the age and gender as filters is restrictive…</span></li>
<li><span><strong>Incomplete filters</strong> : With more time, I’d have added a filter ‘speed’ in the 2nd step of the app (the ‘where’ part) to enable the hard core cyclists to filter the fastest ones…</span></li>
<li><span><strong>Sub-optimal visualization</strong> : I am aware that the map in the introduction page (with the dots displaying the median age per station) is hard to read and with more time, I’d have used polygons instead to group by neighbourhoods.</span></li>
<li><span>Finally, I would have liked to track unique users. Although users don’t have a unique identifier in the Citi Bike dataset, I could have identified unique users by looking at their gender, age, zip and usual start/end stations.</span></li>
</ul>
</div>
<p>The post <a target="_blank" rel="nofollow" href="http://blog.nycdatascience.com/student-works/r-visualization/using-nyc-citi-bike-data-help-bike-enthusiasts-find-mate-dating-app/">Using NYC Citi Bike Data to Help Bike Enthusiasts Find their Mate</a> appeared first on <a target="_blank" rel="nofollow" href="http://blog.nycdatascience.com/">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/r-visualization/using-nyc-citi-bike-data-help-bike-enthusiasts-find-mate-dating-app/"> 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 title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/search/data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/search/map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/search/animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/search/sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/search/SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/search/git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/search/hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/search/PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/search/time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/search/trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/aKi5lZL2ZH8"></a></div>