<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Daniel Forestell on Medium]]></title>
        <description><![CDATA[Stories by Daniel Forestell on Medium]]></description>
        <link>https://medium.com/@danforestell?source=rss-54a4fd816ce7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*cvePrR76QRngoTYr.jpg</url>
            <title>Stories by Daniel Forestell on Medium</title>
            <link>https://medium.com/@danforestell?source=rss-54a4fd816ce7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 04:48:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@danforestell/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Data Exploration — New York City Taxi]]></title>
            <link>https://medium.com/@danforestell/data-exploration-new-york-city-taxi-3a4d26ea54e5?source=rss-54a4fd816ce7------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a4d26ea54e5</guid>
            <category><![CDATA[taxi]]></category>
            <category><![CDATA[data-exploration]]></category>
            <dc:creator><![CDATA[Daniel Forestell]]></dc:creator>
            <pubDate>Wed, 05 Jun 2019 21:18:53 GMT</pubDate>
            <atom:updated>2019-06-05T21:18:53.202Z</atom:updated>
            <content:encoded><![CDATA[<h3>Data Exploration — New York City Taxi</h3><p>In one of the largest and busiest cities in the world, millions of people travel from point A to point B each day. The yellow taxis of New York City are known around the world and relied upon by almost 250 million people each year. With about 500 000 trips made and recorded each day, there is plenty of data available to explore and make predictions. Using trip data provided that contains fare amount, passenger count, time of trip, and pick up and drop off locations, predictions can be made about future fares. This information would prove very useful to taxi companies and consumers. It would provide a very good model for taxis to estimate their revenue and for consumers to plan their trips and expenses.</p><p><strong>Motivation</strong></p><p>Before creating a model to predict fares, the data must be explored to determine what the prediction should be based on. What variables most directly affect the fare?</p><p><strong>Exploratory Questions</strong></p><p>The exploration into the provided data will aim to answer the following questions:</p><ol><li>What is the average fare? What is the standard deviation?</li><li>How far is the average trip and what is the fare per kilometer traveled?</li><li>What is the most common fare?</li></ol><p><strong>Cleaning the Data</strong></p><p>Before working with the data, it must be checked diligently. Does all of the data make sense? Are there some inherent errors or mistakes in the collected data. Many issues can be exposed by simply looking at preliminary statistics.</p><pre>data.describe()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*Ks9Xp4iT808zYLv61nErVA.png" /><figcaption>Preliminary Statistics</figcaption></figure><p>From these statistics, some anomalies become apparent. For one, the minimum fare is negative. This cannot be accurate data as a taxi fare is never negative. Further, the maximum number of passengers is 208. A large cab may be able to seat 6 passengers, but no more, so this cannot be an accurate data point.</p><p>To clean the data, all fares that are less than zero will be removed and all trips with more than 6 passengers will be removed.</p><pre>data = data[data.fare_amount&gt;=0]<br>data = data[data.passenger_count&lt;=6]</pre><p>One additional step taken to clean the data is to focus on trips made in the Northeast United States. Since this data is from New York, any trips outside of this region are either errors or outliers that may skew the data.</p><p><strong>Mean and Standard Deviation</strong></p><p>Now that the data has been cleaned, the original questions can be addressed.</p><p>First, looking at the fare statistics, the mean and standard deviation can be seen. The mean fare is approximately $11.35 and the standard deviation is approximately $9.82. The fares can also be represented using a histogram to provide a visual representation of how they are distributed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*7b_-Kb28o3C498WaGwUMTw.png" /><figcaption>Fare (US$)</figcaption></figure><p><strong>Average Trip and Fare/Kilometer</strong></p><p>Another key metric in the fare price is the distance traveled. Since the pickup and drop off coordinates are given, the distance between the points can be calculated using a modification of the haversine formula.</p><pre>def distance(lat1, lon1, lat2, lon2):<br>    p = 0.017453292519943295 <em># Pi/180</em><br>    a = 0.5 - np.cos((lat2 - lat1) * p)/2 + np.cos(lat1 * p) * np.cos(lat2 * p) * (1 - np.cos((lon2 - lon1) * p)) / 2<br>    return 0.6213712 * 12742 * np.arcsin(np.sqrt(a)) * 1.609</pre><p>Adding a column to the data containing the distance of a trip provides greater insight into the data. Using the .describe() function on the updated data provides the average trip distance, it is approximately 3.36 km. A histogram provides a good visual representation of the trips, as seen, most trips are fairly short (&lt;5km).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*xj42gm5OHRTjERnKZR9Pog.png" /><figcaption>Trip Distance (km)</figcaption></figure><p>The average fare per kilometer can be calculated by summing the fares and dividing this sum by the sum of the distances.</p><pre>print(data.fare_amount.sum() / data.distance.sum())</pre><p>This provides an average fare per kilometer of $3.38/km.</p><p><strong>Most Common Fare</strong></p><p>Finally, looking at the most common fare can provide insight into whether certain trips are made frequently or if there is set fare for certain trips. First, the most common fare was extracted from the data using mode(). The most common fare was $6.50 and it was the fare for about 5% of all trips. Given that it was 5% of all trips, it is hard to say whether this will be a significant metric to provide insight. 5% is large enough to be significant, but not so large that it will guarantee any meaningful results. To check, the pickup and drop off locations for trips with a fare of $6.50 were plotted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*Z7OzI-PkM5w8hGOntpv9Cg.png" /><figcaption>Pick up locations for $6.50 fare</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*PoThaURaRTq417NnM7xQig.png" /><figcaption>Drop off locations for $6.50 fare</figcaption></figure><p>From the maps above, it is clear that a $6.50 fare is not a set fare from certain locations (for example, to or from an airport may have a set fare). Nothing significant can be extracted from this most common fare. To follow up with a similar idea, one could check what locations are most common.</p><p><strong>Outcomes</strong></p><p>From this exploration, a few key metrics can be seen in the data. The most important piece of information obtained is the average fare per kilometer as many taxis base their fare on how far and how long the taxi has traveled. To further expand on the exploration, it would be interesting to see how fare/km changes based on time of day or day of the week. This analysis has demonstrated how some key information can be extracted from large amounts of taxi data. This information can help inform taxi companies and passengers.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a4d26ea54e5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>