<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-6012733759439953488</atom:id><lastBuildDate>Sun, 01 Sep 2024 12:00:38 +0000</lastBuildDate><category>Data Science</category><category>NYC Subway Data</category><category>Udacity</category><category>Data Analysis</category><category>Data Wrangling</category><category>Intro to Data Science</category><category>Coefficient of Determination</category><category>Data Visualization</category><category>Descriptive Statistics</category><category>First Blog Post</category><category>Goodness of Fit</category><category>Gradient Descent</category><category>Linear Regression</category><category>Mann-Whitney U test</category><category>Mathematics</category><category>Python</category><category>Residuals Vs Fits</category><category>Statistics</category><category>Syllabus</category><category>Weather Data</category><category>dummy variable</category><title>The Stats Are Not What They Seem</title><description></description><link>http://whattheyseem.blogspot.com/</link><managingEditor>noreply@blogger.com (Anonymous)</managingEditor><generator>Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6012733759439953488.post-9111574204354943882</guid><pubDate>Wed, 21 Oct 2015 20:07:00 +0000</pubDate><atom:updated>2015-10-21T13:07:56.326-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Data Wrangling</category><category domain="http://www.blogger.com/atom/ns#">NYC Subway Data</category><category domain="http://www.blogger.com/atom/ns#">Udacity</category><title>Project 1: Some Wrangling Code</title><description>Use on your local machine!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Example 1)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
import csv&lt;br /&gt;
import os&lt;br /&gt;
&lt;br /&gt;
def &lt;span style=&quot;color: blue;&quot;&gt;fix_turnstile_data&lt;/span&gt;(filenames):&lt;br /&gt;
&amp;nbsp; &amp;nbsp; #filenames is supposed to be a list of filenames&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: lime;&quot;&gt;&#39;&#39;&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; Filenames is a list of MTA Subway turnstile text files. A link&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; to an example MTA Subway turnstile text file can be seen at the URL below:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; http://web.mta.info/developers/data/nyct/turnstile/turnstile_110507.txt&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; As you can see, there are numerous data points included in each row of the&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; a MTA Subway turnstile text file.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; You want to write a function that will update each row in the text&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; file so there is only one entry per row. A few examples below:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; A002,R051,02-00-00,05-28-11,00:00:00,REGULAR,003178521,001100739&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; A002,R051,02-00-00,05-28-11,04:00:00,REGULAR,003178541,001100746&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; A002,R051,02-00-00,05-28-11,08:00:00,REGULAR,003178559,001100775&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; Write the updates to a different text file in the format of&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;updated_&quot; + filename.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; For example:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1) if you read in a text file called &quot;turnstile_110521.txt&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2) you should write the updated data to &quot;updated_turnstile_110521.txt&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; The order of the fields should be preserved.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; You can see a sample of the turnstile text file that&#39;s passed into this function&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; and the the corresponding updated file in the links below:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; Sample input file:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; https://www.dropbox.com/s/mpin5zv4hgrx244/turnstile_110528.txt&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; Sample updated file:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; https://www.dropbox.com/s/074xbgio4c39b7h/solution_turnstile_110528.txt&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; &#39;&#39;&#39;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for name in filenames:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; outgoing_filename = &quot;alternative_updated_&quot; + name&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; path = r&#39; ... &lt;span style=&quot;color: lime;&quot;&gt;select your path to input and output files&lt;/span&gt; ...&#39;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; g = open(os.path.join(path, outgoing_filename), &#39;w&#39;)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; outgoing_file = csv.writer(g)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; with open(os.path.join(path, name), &#39;rb&#39;) as f:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; reader = csv.reader(f)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for row in reader:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i = 0&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; initial = row[:3]&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; while row[3+i:3+i+5]:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; outgoing_file.writerow(initial + row[3+i:3+i+5])&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i = i + 5&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
filenames = [&#39;turnstile_110528.txt&#39;, &#39;turnstile_110529.txt&#39;]&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;fix_turnstile_data&lt;/span&gt;(filenames)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Example 2:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
# -*- coding: utf-8 -*-&lt;br /&gt;
import os&lt;br /&gt;
import csv&lt;br /&gt;
import re&lt;br /&gt;
&lt;br /&gt;
def &lt;span style=&quot;color: blue;&quot;&gt;create_master_turnstile_file&lt;/span&gt;(filenames, output_file):&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: lime;&quot;&gt;&#39;&#39;&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; Write a function that takes the files in the list filenames, which all have the&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; columns &#39;C/A, UNIT, SCP, DATEn, TIMEn, DESCn, ENTRIESn, EXITSn&#39;, and consolidates&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; them into one file located at output_file. &amp;nbsp;There should be ONE row with the column&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; headers, located at the top of the file.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; For example, if file_1 has:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; &#39;C/A, UNIT, SCP, DATEn, TIMEn, DESCn, ENTRIESn, EXITSn&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; line 1 ...&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; line 2 ...&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; and another file, file_2 has:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; &#39;C/A, UNIT, SCP, DATEn, TIMEn, DESCn, ENTRIESn, EXITSn&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; line 3 ...&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; line 4 ...&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; line 5 ...&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; We need to combine file_1 and file_2 into a master_file like below:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&#39;C/A, UNIT, SCP, DATEn, TIMEn, DESCn, ENTRIESn, EXITSn&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; line 1 ...&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; line 2 ...&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; line 3 ...&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; line 4 ...&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; line 5 ...&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; &#39;&#39;&#39;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; path = r&#39; ...path to location for input and output files ...&#39;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; with open(os.path.join(path, output_file), &#39;w&#39;) as master_file:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; master_file.write(&#39;C/A,UNIT,SCP,DATEn,TIMEn,DESCn,ENTRIESn,EXITSn\n&#39;)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for filename in filenames:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;master_file.write(re.sub(&#39;C/A, UNIT, SCP, DATEn, TIMEn, DESCn, ENTRIESn, EXITSn&#39;, &#39;&#39;, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&#39;&#39;.join(open(os.path.join(path, filename), &quot;rb&quot;).readlines())))&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;create_master_turnstile_file&lt;/span&gt;([ &#39;file_2.txt&#39;, &#39;file_3.txt&#39;], &#39;output_file.txt&#39;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description><link>http://whattheyseem.blogspot.com/2015/10/project-1-some-wrangling-code.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6012733759439953488.post-8857362968040090808</guid><pubDate>Sat, 03 Oct 2015 18:28:00 +0000</pubDate><atom:updated>2015-10-21T06:11:09.661-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Coefficient of Determination</category><category domain="http://www.blogger.com/atom/ns#">Data Analysis</category><category domain="http://www.blogger.com/atom/ns#">dummy variable</category><category domain="http://www.blogger.com/atom/ns#">Goodness of Fit</category><category domain="http://www.blogger.com/atom/ns#">Gradient Descent</category><category domain="http://www.blogger.com/atom/ns#">Intro to Data Science</category><category domain="http://www.blogger.com/atom/ns#">Linear Regression</category><category domain="http://www.blogger.com/atom/ns#">Mann-Whitney U test</category><category domain="http://www.blogger.com/atom/ns#">NYC Subway Data</category><category domain="http://www.blogger.com/atom/ns#">Residuals Vs Fits</category><title>Project 1: NYC Subway Ridership and Weather</title><description>&lt;div style=&quot;text-align: justify;&quot;&gt;
Font colors:&lt;br /&gt;
&lt;b&gt;black&lt;/b&gt;: Udacity final project questionnaire&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;blue&lt;/span&gt;&lt;/b&gt;: my answers&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;red&lt;/span&gt;&lt;/b&gt;: selected code examples.&lt;br /&gt;
&lt;b&gt;WARNING&lt;/b&gt;: the code can be applied to the&amp;nbsp;&lt;a href=&quot;https://drive.google.com/file/d/0B15LMNvJXFnNSE5zSm1RSGpmNnc/view?usp=sharing&quot; target=&quot;_blank&quot;&gt;turnstile_data_master_with_weather.csv&lt;/a&gt;&amp;nbsp;&amp;nbsp;right away on your local machine but will display results&amp;nbsp;different from the discussion below. This is because Udacity provided a manipulated master file (a smaller &quot;randomly chosen subset&quot; as they said) at their UI, not visible for the user, containing only ~15% of the data contained in the original master file.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;
Short Questions to Analyzing the NYC Subway Dataset&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Section 0. References&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Section 1. Statistical Test&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Section 2. Linear Regression&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Section 3. Visualization&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Section 4. Conclusion&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Section 5. Reflection&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;
Section 0. References&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Please include a list of references you have used for this project. Please be specific - for example, instead of including a general website such as stackoverflow.com, try to include a specific topic from Stackoverflow that you have found useful.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;• „Python for Data Analysis“ (1st ed.), Wes McKinney, O&#39;Reilly, 2013:&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;- Chapter 4: NumPy Basics&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;- Chapter 5: Getting Started with pandas&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;- Chapter 6: Data Loading, Storage, and File Formats&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;- Chapter 8: Plotting and Visualization&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;- Chapter 9: Data Aggregation and Group Operations&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;• „Python 3“ (3rd ed.), Ernesti, Johannes; Kaiser, Peter, Galileo Computing, 2012&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;- Chapter 24.3.1: Überblick über den Datentyp numpy.ndarray (Overview of the Datatype&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;numpy.ndarray)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;• „Street-Smart Stats – A Friendly Introduction to Statistical Research Methods“, Katie&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Kormanik, http://www.amazon.com/Street-Smart-Stats-Friendly-Introduction-&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Statistical/dp/1500872105&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;- Lesson 9: Hypothesis Testing&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;• Equally distributed bins for matplotlib histograms:&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;http://stackoverflow.com/questions/6986986/bin-size-in-matplotlib-histogram&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;• The Mann-Whitney-U Test:&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;- https://www.youtube.com/watch?v=LnfPKGhJypU#&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;- „MannWhitneyUTest“ in Downloadables from https://www.udacity.com/course/viewer#!/cud359/&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;l-649959144/m-750618549&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;• Residuals VS Fits Plot&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;- http://www.itl.nist.gov/div898/handbook/pri/section2/pri24.htm&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;
Section 1. Statistical Test&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;1.1 Which statistical test did you use to analyze the NYC subway data? Did you use a one-tail or&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;a two-tail P value? What is the null hypothesis? What is your p-critical value?&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;• I used the the Mann-Whitney U test of the scipy.stats implementation, 2-tailed.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;• Null Hypothesis: Let X be the population of turnstile entries on non-rainy days and Y be the&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;population of turnstile entries on rainy days;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;H0: P(x&amp;gt;y) = 0.5 for each random draw x from X and y from Y .&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;• The p-critical value is set to 0.05.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;
1.2 Why is this statistical test applicable to the dataset? In particular, consider the assumptions&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;that the test is making about the distribution of ridership in the two samples.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;The Mann-Whitney U test assumes 2 independent samples of ordinal (or interval) datatype. The&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;turnstile dataset fulfills both conditions.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;The Mann-Whitney U does not assume the sample data is drawn from any particular known&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;underlying distribution or that the samples are of equal size or variance.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;
1.3 What results did you get from this statistical test? These should include the following&lt;br /&gt;numerical values: p-values, as well as the means for each of the two samples under test.&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Results:&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;1. average number of turnstile entries where &#39;rain&#39;=1: &lt;b&gt;1105.45&lt;/b&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;2. average number of turnstile entries where &#39;rain&#39;=0: &lt;b&gt;1090.28&lt;/b&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;3. Mann-Whitney statistic U = &lt;b&gt;1924409167.0&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;4. 1-sided p-value p: &lt;b&gt;0.024999912793489721&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;
1.4 What is the significance and interpretation of these results?&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;According to the&amp;nbsp;&lt;a href=&quot;http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.mannwhitneyu.html&quot; target=&quot;_blank&quot;&gt;scipy.stats implementation&lt;/a&gt;, the obtained 1-sided p value p = 0.024999912793489721 has to be multiplied by 2 in order to compare it with our p-critical value of 0.5. This gives us p = 0.04999982558697944 and since p&amp;lt;0.05, we reject H0.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Meaning: p is the probability of obtaining the Mann-Whitney U test statistic of at most U =&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;1924409167.0, given H0 is true. This probability is less than 0.05. This means that even if there&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;were no difference between entries on rainy days and entries on non-rainy days, we would see a&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;value of U equal or greater than 1924409167.0 in 5% of the times.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;
Section 2. Linear Regression&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;2.1 What approach did you use to compute the coefficients theta and produce prediction for&amp;nbsp;&lt;/b&gt;&lt;b&gt;ENTRIESn_hourly in your regression model:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;1. OLS using Statsmodels or Scikit Learn&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;2. Gradient descent using Scikit Learn&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;3. Or something different?&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Linear regression with gradient descent using pandas and numpy.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;import numpy as np&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;import pandas&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;from pandas import Series&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;from dateutil.parser import parse&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;from problem7_R2  import compute_r_squared #&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;this module contains the code shown in Section 2.5 below&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-paragraph-type: empty; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-paragraph-type: empty; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;def normalize_features(df):&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 2; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;    &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 2; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;    Normalize the features in the data set.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;    &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    mu = df.mean()&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    sigma = df.std()&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    if (sigma == 0).any():&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;raise Exception(&quot;One or more features had the same value for all samples, and thus could &quot; + \&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;not be normalized. Please do not include features with only a single value &quot; + \&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;in your model.&quot;)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    df_normalized = (df - df.mean()) / df.std()&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-paragraph-type: empty; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    return df_normalized, mu, sigma&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-paragraph-type: empty; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-paragraph-type: empty; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;def compute_cost(features, values, theta):&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 2; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;    &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 2; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;    Compute the cost function given a set of features / values, &lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 2; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;    and the values for our thetas.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;    &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    m = len(values)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    sum_of_square_errors = np.square(np.dot(features, theta) - values).sum()&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    cost = sum_of_square_errors / (2*m)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-paragraph-type: empty; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    return cost&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-paragraph-type: empty; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;def gradient_descent(features, values, theta, alpha, num_iterations):&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 2; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;    &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 2; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;    Perform gradient descent given a data set with an arbitrary number of features.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;    &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    m = len(values)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    cost_history = []&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-paragraph-type: empty; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    for i in range(num_iterations):&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;predicted_values = np.dot(features, theta)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;theta = theta + ( (alpha / m) * np.dot((values - predicted_values), features) ) &lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;cost_history.append(compute_cost(features, values, theta))&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    return theta, pandas.Series(cost_history)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-paragraph-type: empty; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-paragraph-type: empty; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;def predictions(dataframe):&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 1; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;    &#39;&#39;&#39;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 1; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: lime;&quot;&gt;    The NYC turnstile data is stored in a pandas dataframe called weather_turnstile.&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: lime;&quot;&gt;Using the information stored in the dataframe, let&#39;s predict the ridership of&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: lime;&quot;&gt;the NYC subway using linear regression with gradient descent.&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: lime;&quot;&gt;You can download the complete turnstile weather dataframe here:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 1; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;    https://www.dropbox.com/s/meyki2wl9xfa7yk/turnstile_data_master_with_weather.csv    &lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 1; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 1; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: lime;&quot;&gt;    Your prediction should have a R^2 value of 0.40 or better.&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: lime;&quot;&gt;You need to experiment using various input features contained in the dataframe.&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: lime;&quot;&gt;We recommend that you don&#39;t use the EXITSn_hourly feature as an input to the&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: lime;&quot;&gt;linear model because we cannot use it as a predictor: we cannot use exits&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: lime;&quot;&gt;counts as a way to predict entry counts.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;    &#39;&#39;&#39;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    #Selection of features&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    features = dataframe[[&#39;Hour&#39;,&#39;meanpressurei&#39;, &#39;maxdewpti&#39;, &#39;rain&#39;, &#39;fog&#39;]]&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    #Adding dayofweek to features using dummy variables&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    dataframe[&#39;dayofweek&#39;] = Series(parse(x).strftime(&#39;%a&#39;) for x in dataframe[&#39;DATEn&#39;])   &lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    dummy_dayofweek = pandas.get_dummies(dataframe[&#39;dayofweek&#39;])&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    features = features.join(dummy_dayofweek)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    # Add UNIT to features using dummy variables&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    dummy_units = pandas.get_dummies(dataframe[&#39;UNIT&#39;], prefix=&#39;unit&#39;)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    features = features.join(dummy_units)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    # Values&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    values = dataframe[&#39;ENTRIESn_hourly&#39;]&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    m = len(values)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-paragraph-type: empty; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    features, mu, sigma = normalize_features(features)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    features[&#39;ones&#39;] = np.ones(m) # Add a column of 1s (y intercept)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    # Convert features and values to numpy arrays&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    features_array = np.array(features)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    values_array = np.array(values)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-paragraph-type: empty; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    # Set values for alpha, number of iterations.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    alpha = 0.1 # please feel free to change this value&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    num_iterations = 50 # please feel free to change this value&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-paragraph-type: empty; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    # Initialize theta, perform gradient descent&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    theta_gradient_descent = np.zeros(len(features.columns))&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    theta_gradient_descent, cost_history = gradient_descent(features_array, &lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; values_array, &lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; theta_gradient_descent, &lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; alpha, &lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; num_iterations)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    predictions = np.dot(features_array, theta_gradient_descent)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;return predictions&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-paragraph-type: empty; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-paragraph-type: empty; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;file = = r&quot; ... /turnstile_data_master_with_weather.csv&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;df= pandas.read_csv(file)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;print(compute_r_squared(df[&#39;ENTRIESn_hourly&#39;],predictions(df)))&lt;/span&gt;&lt;!--EndFragment--&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;
2.2 What features (input variables) did you use in your model? Did you use any dummy variables&amp;nbsp;as part of your features?&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;I accepted the predefined dummy variable &lt;b&gt;&#39;UNIT&#39;&lt;/b&gt; and I also added another dummy variable&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;&#39;dayofweek&#39;&lt;/b&gt;.&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;Finally, I added &lt;b&gt;&#39;Hour&#39;&lt;/b&gt;, &lt;b&gt;&#39;meanpressurei&#39;&lt;/b&gt;, &lt;b&gt;&#39;maxdewpti&#39;&lt;/b&gt;, &lt;b&gt;&#39;rain&#39;&lt;/b&gt; and &lt;b&gt;&#39;fog&#39;&lt;/b&gt; to the list of features.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;
2.3 Why did you select these features in your model? We are looking for specific reasons that&lt;br /&gt;
lead you to believe that the selected features will contribute to the predictive power of your model.&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;• Your reasons might be based on intuition. For example, response for fog might be: “I&lt;/span&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;decided to use fog because I thought that when it is very foggy outside people might decide&lt;/span&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;to use the subway more often.”&lt;/span&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;• Your reasons might also be based on data exploration and experimentation, for example: “I&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;used feature X because as soon as I included it in my model, it drastically improved my R2&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;value.”&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;I accepted the predefined UNIT dummy variable because it provided the largest increase of the R2&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;value (0.425) which I could find during my experimentation. Other groups of features did not show&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;that strong impact on R2.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;As for the &#39;dayofweek&#39; dummy, my intuition was that weather based decisions to use the subway&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;may differ significantly on weekends compared to normal working days.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;In order to further boost my R2 I proceeded by searching for features with a broad variability in&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;comparison to &#39;UNIT&#39; and &#39;dayofweek&#39; but this is easier said than done. So the method was rather&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;trial and error. Finally, I chose &#39;Hour&#39; and the weather-related features &#39; meanpressurei&#39;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&#39;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;maxdewpti&#39;, &#39;rain&#39;, and &#39;fog&#39;.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;
2.4 What are the parameters (also known as &quot;coefficients&quot; or &quot;weights&quot;) of the non-dummy&lt;br /&gt;features in your linear regression model?&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Starting the regression with alpha = 0.1 and num_iterations = 50 on the random subset provided, I&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;obtained the following non-dummy coefficients:&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&#39;Hour&#39;: 4.63757966e+02&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&#39;meanpressurei&#39;: -2.64689006e+01&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&#39;maxdewpti&#39;: -4.89940069e+01&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&#39;rain&#39;: -1.27974911e+01&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&#39;fog&#39;: 4.94588410e+01&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;
2.5 What is your model’s R2 (coefficients of determination) value?&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;R2 = 0.476546529828&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;!--StartFragment--&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;import numpy as np&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-paragraph-type: empty; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;def compute_r_squared(data, predictions):&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 1; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;    &#39;&#39;&#39;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 1; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;Given a list of original data points, and also a list of predicted data points,&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 1; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;    this function will compute and return the coefficient of determination (R^2)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 1; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;    for this data.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-paragraph-type: empty; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;&#39;&#39;&#39;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;nominator = np.square((data - predictions)).sum()&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    denominator = np.square(data - data.mean()).sum()&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;    r_squared = 1.0 - (nominator/denominator)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;-qt-block-indent: 0; -qt-user-state: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;return r_squared&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;
2.6 What does this R2 value mean for the goodness of fit for your regression model? Do you think&amp;nbsp;this linear model to predict ridership is appropriate for this dataset, given this R2 value?&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Let v1 be the variance of the residuals around the regression line and let v2 be the overall&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;variance (in our case: the variance of turnstile entries). The following formula was used to&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;compute R2:&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;R2 = 1 – (v1/v2)&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;Meaning1&lt;/b&gt;: R2 gives a measure of how well the regression line of a model fits the data. If v1=0 (the&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;predicted values match the data perfectly), then R2=1. In the worst case v1=v2 (there is no&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;relationship between the independent variables and the output variable) and therefore R2=0.&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;Since an R2 of 0.48 falls approximately in the middle of [0,1], there could be worse fits, but also&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;better ones, e.g. obtainable by just adding more and more regressors (at the cost of more&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;complicated models).&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;Meaning2&lt;/b&gt;: v1 is called „the unexplained variation“. Since v1 = v2*(1-R2) and given R2 as above,&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;one can therefore conclude that the given model has explained around 0.48% of the overall&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;variation of observed turnstile entries and left unexplained 0.52%.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;Appropriateness&lt;/b&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Multiple regression assumes that the the residuals are normally distributed. One way to check this&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;assumption is to plot the residuals. While a histogram of the residuals shows a long-legged Bell&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;curve centered around 0 suggesting normality, I have chosen to do a „Residuals Vs Fits“ plot:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhP7UZCpxXSwHu9x-cmASQG1owYQuILfVWY0cYELYvkz_Dd9DGuS0d6FnyJtv2dbvpdbpL1TqsNRrg3-4Du621fTOPQH-mrjm-tSnH9fbgJzcAj2zYfRARuP2RyKahjLGI4oT7QH1ap-s8/s1600/ResidualsVSFits2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhP7UZCpxXSwHu9x-cmASQG1owYQuILfVWY0cYELYvkz_Dd9DGuS0d6FnyJtv2dbvpdbpL1TqsNRrg3-4Du621fTOPQH-mrjm-tSnH9fbgJzcAj2zYfRARuP2RyKahjLGI4oT7QH1ap-s8/s1600/ResidualsVSFits2.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Interpretation: The higher the output variable, the higher the residual error. This implies a pattern&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;where the residuals should be randomly distributed about 0. Hence, the assumption of normality&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;does not seem to be fulfilled. Further analysis is needed to check normality conclusively. So I&#39;m&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;not sure if the model can be called appropriate.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;
Section 3. Visualization&lt;/span&gt;&lt;/h3&gt;
Please include two visualizations that show the relationships between two or more variables in&lt;br /&gt;
the NYC subway data.&lt;br /&gt;
Remember to add appropriate titles and axes labels to your plots. Also, please add a short&lt;br /&gt;
description below each figure commenting on the key insights depicted in the figure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;
3.1 One visualization should contain two histograms: one of ENTRIESn_hourly for rainy days&lt;br /&gt;and one of ENTRIESn_hourly for non-rainy days.&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
• You can combine the two histograms in a single plot or you can use two separate plots.&lt;br /&gt;
• If you decide to use to two separate plots for the two histograms, please ensure that the xaxis&lt;br /&gt;
limits for both of the plots are identical. It is much easier to compare the two in that&lt;br /&gt;
case.&lt;br /&gt;
• For the histograms, you should have intervals representing the volume of ridership (value of&lt;br /&gt;
ENTRIESn_hourly) on the x-axis and the frequency of occurrence on the y-axis. For&lt;br /&gt;
example, each interval (along the x-axis), the height of the bar for this interval will represent&lt;br /&gt;
the number of records (rows in our data) that have ENTRIESn_hourly that falls in this&lt;br /&gt;
interval.&lt;br /&gt;
• Remember to increase the number of bins in the histogram (by having larger number of&lt;br /&gt;
bars). The default bin width is not sufficient to capture the variability in the two samples.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihsM3LhRdO9bK2U7flDxsoG1uWbF6j_LSXBjNlzjkC3-KIyCbgYZyUgBCSQLGMTxe3-idW1vn_tLCLWvPyZnGj08ay-ioG-77G-5_U3FTb_y4lHHkeO7Kvczuqzudfg2bZZSyPQ2hTUCA/s1600/1_histo.jpeg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;480&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihsM3LhRdO9bK2U7flDxsoG1uWbF6j_LSXBjNlzjkC3-KIyCbgYZyUgBCSQLGMTxe3-idW1vn_tLCLWvPyZnGj08ay-ioG-77G-5_U3FTb_y4lHHkeO7Kvczuqzudfg2bZZSyPQ2hTUCA/s640/1_histo.jpeg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;import numpy as np&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;import pandas&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;import matplotlib.pyplot as plt&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;def entries_histogram(turnstile_weather):&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;fig = plt.figure(); ax = fig.add_subplot(1,1,1)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;ax.set_xlim([0,4000])&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;ax.set_ylim([0,50000])&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;no_rain = list(turnstile_weather[&quot;ENTRIESn_hourly&quot;][turnstile_weather[&quot;rain&quot;] == 0])&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;ax.hist(no_rain,color=&#39;y&#39;,bins=np.arange(min(no_rain), max(no_rain) + 250, 250),label=&#39;no rain&#39;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;rain = list(turnstile_weather[&quot;ENTRIESn_hourly&quot;][turnstile_weather[&quot;rain&quot;] == 1])&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;ax.hist(rain,color=&#39;b&#39;,bins=np.arange(min(rain), max(rain) + 250, 250),label=&#39;rain&#39;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;ax.set_title(&#39;Comparison of Entries on Rainy and Non-Rainy Days&#39;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;ax.set_xlabel(&#39;Volume of Ridership (bin size = 250)&#39;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;ax.set_ylabel(&#39;Frequency&#39;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;ax.legend(loc=&#39;best&#39;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;return fig&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;file = r“(... turnstile_data_master_with_weather.csv“)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;turnstile_weather = pandas.read_csv(file)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;entries_histogram(turnstile_weather)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Note that the &#39;Entries_hourly&#39; column contained the cumulative sum of the last 4 hours for a given turnstile unit. Each day was thus partitioned into 6 intervals. The histogram counts the number of occurrences of these entries per bin (binsize=250). Thus, there are more than 40k entries in the column smaller than 250 (lots of them equal to 0).&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;I&#39;d like to further comment that this histogram might be easily misinterpreted by concluding that&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;there are far more entries during rainy days than during non-rainy days. This is not the case: since&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;there were twice as many non-rainy days (20) than rainy days (10) and the bar height ratios of both&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;groups appear to be roughly constant, the above histogram is better interpreted by mentally&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;dividing the absolute frequency of non-rainy days by 2, thus roughly equalling the absolute&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;frequency of rainy days. Equivalently, a histogram of relative frequency would show that the&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;difference between the two groups is small (by comparing the results of each class interval to the&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;total number of entries). This is confirmed by the small difference between the average numbers&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;mentioned in Section 1.3.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;The only purpose of plotting such a histogram is to get some hint about the nature of the&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;distribution of data. In this case, the data distribution does not appear to be normal which suggests&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;to continue the investigation with non-parametric tools.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;
3.2 One visualization can be more freeform. You should feel free to implement something that we&amp;nbsp;discussed in class (e.g., scatter plots, line plots) or attempt to implement something more advanced if you&#39;d like. Some suggestions are:&lt;/b&gt;&lt;br /&gt;
• Ridership by time-of-day&lt;br /&gt;
• Ridership by day-of-week&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgi-hriEVBQH4cYs-PxQVWEPVpAZ3jSXx1pu-zTsN9b7vchb1YL8K09EvXvNw_WIiszDK8TwylA1olamAVSR-N8r30T0KeMyLj1HfMW7q6xgMb5gW9T_WV6M0aVPKx_sXjm1QWmm-FF9kM/s1600/2_freeform.jpeg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;464&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgi-hriEVBQH4cYs-PxQVWEPVpAZ3jSXx1pu-zTsN9b7vchb1YL8K09EvXvNw_WIiszDK8TwylA1olamAVSR-N8r30T0KeMyLj1HfMW7q6xgMb5gW9T_WV6M0aVPKx_sXjm1QWmm-FF9kM/s640/2_freeform.jpeg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;from pandas import *&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;from ggplot import *&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;filename = r&#39;.../turnstile_data_master_with_weather.csv&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;with open(filename,&#39;rb&#39;) as df:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;df = pandas.read_csv(filename)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;grouped = df[&#39;ENTRIESn_hourly&#39;].groupby(df[&#39;Hour&#39;])&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;result = grouped.agg([&#39;mean&#39;])&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;gg = ggplot(result.reset_index(), aes(x=&#39;Hour&#39;,y=&#39;mean&#39;)) + \&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;geom_point(stat = &quot;identity&quot;) + geom_line(color=&#39;blue&#39;) +\&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;xlab(&quot;Hours of the Day&quot;) + xlim(-0.5,24.5) + ylim(0,3000) + ylab(&#39;Means&#39;)+\&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;ggtitle(&#39;&#39;&#39;Average Number of N.Y. Subway Turnstile Entries&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;per Hour of the Day (May 2011)&#39;&#39;&#39;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;print(gg)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Like with other time granularities on the X-axis (month,week,day) the above line plot shows a&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;specifc pattern. But in contrast to week or day, the &#39;hour&#39;-plot is very problematic. The peak&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;values at noon and 20:00 are somewhat surprising since one would expect rush hours to be&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;peaks. This surprise can be explained by the cumulative way of counting entries displayed in the&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&#39;Entries_hourly&#39; column, mentioned above. Thus, one can only guess where exactly within the 4&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;hour interval before noon and 20:00 respectively the real peaks are to be located (if any). Since&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;this undetermined „backwards shift in time“ applies to all points of the line plot, the analytic value&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;of the above plot can be considered low.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Section 4. Conclusion&lt;/h3&gt;
Please address the following questions in detail. Your answers should be 1-2 paragraphs long.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;
4.1 From your analysis and interpretation of the data, do more people ride the NYC&lt;br /&gt;subway when it is raining or when it is not raining?&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Data rather inconclusive: There are slightly more turnstile entries on rainy days than on&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;non-rainy days. The difference is statistically significant at a significance level of 0.05,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;though the decision is very tight. It might be uncertain whether this result will lead to practical consequences.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;
4.2 What analyses lead you to this conclusion? You should use results from both your statistical&lt;br /&gt;tests and your linear regression to support your analysis.&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;span style=&quot;color: blue;&quot;&gt;First I observed the average numbers of turnstile entries:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;rain &amp;nbsp; &amp;nbsp; &amp;nbsp; mean&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1090.278780&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1105.446377&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;The difference appears to be relatively small. The histogram in Section 3 indicates that the data is not normally distributed. Thus proceeding&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;with parameter-free tools would be promising. I ran the Mann-Whitney U-test for comparing both&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;groups. The obtained p-value was only very slightly smaller than the p-critical value of 0.05, but&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;enough to reject the Null Hypotesis.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;A linear regression model showed that adding several weather features has indeed some small&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;impact on the goodness of fit of the model for predicting future turnstile data.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;On the other hand, a non-weather related variable like „UNIT“ has far greater impact on the coefficient of&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;determination: R2=0.425036652566 if the only variable is „UNIT“.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Given the small amount of data (month of May, 2011), it can be doubted whether this tight result might lead to practical consequences. Rain might have a different impact on ridership depending on the season of the year and data of one month only is clearly not representative.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;
Section 5. Reflection&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
Please address the following questions in detail. Your answers should be 1-2 paragraphs long.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;
5.1 Please discuss potential shortcomings of the methods of your analysis, including:&lt;br /&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;1. Dataset,&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;span style=&quot;color: blue;&quot;&gt;- Data from 1 month only is not representative.&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;span style=&quot;color: blue;&quot;&gt;- Granularity: Merging the subway data with a weather table on a daily basis may be not&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;accurate enough. Decisions to enter the subway because of weather conditions may be&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;based partly on momentary conditions (but also on the weather forecast).&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;- Cumulative Counts: The cumulative sum of entries of the last four hours as presented in&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;the „ENTRIESn_hourly“ column may cause problems in finding certain key values like&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;maximum or minimum number of entries per hour (as mentioned in Section 3.2). In&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;connection with the granularity problem mentioned above, it would be desireable to have a&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;1-1 correspondence between hourly weather data and hourly number of entries.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;- Additional demographic and geographical details would be helpful, e.g. different&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;demographic groups of the City of New York could be set in relation to certain areas&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;containing certain subway units.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;
2. Analysis, such as the linear regression model or statistical test.&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;span style=&quot;color: blue;&quot;&gt;- It is questionable whether the linear regression model used is the best way of analyzing a&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;possible correlation of weather and subway entries. The greatest part of the coefficient of&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;determination R2 does not come from weather related features but from the dummy&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;variable „UNIT“.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;- Further examinations are needed to check conclusively whether all assumptions for linear&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;regression are fulfilled (e.g. normality assumption for the residuals).&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;
5.2 (Optional) Do you have any other insight about the dataset that you would like to share with&lt;br /&gt;us?&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
</description><link>http://whattheyseem.blogspot.com/2015/10/project-1.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhP7UZCpxXSwHu9x-cmASQG1owYQuILfVWY0cYELYvkz_Dd9DGuS0d6FnyJtv2dbvpdbpL1TqsNRrg3-4Du621fTOPQH-mrjm-tSnH9fbgJzcAj2zYfRARuP2RyKahjLGI4oT7QH1ap-s8/s72-c/ResidualsVSFits2.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6012733759439953488.post-3840333653899707594</guid><pubDate>Fri, 02 Oct 2015 19:14:00 +0000</pubDate><atom:updated>2015-10-21T13:10:00.883-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Data Analysis</category><category domain="http://www.blogger.com/atom/ns#">Data Science</category><category domain="http://www.blogger.com/atom/ns#">Data Visualization</category><category domain="http://www.blogger.com/atom/ns#">Data Wrangling</category><category domain="http://www.blogger.com/atom/ns#">Descriptive Statistics</category><category domain="http://www.blogger.com/atom/ns#">Intro to Data Science</category><category domain="http://www.blogger.com/atom/ns#">NYC Subway Data</category><category domain="http://www.blogger.com/atom/ns#">Udacity</category><category domain="http://www.blogger.com/atom/ns#">Weather Data</category><title>Project 1: NYC Subway Ridership and Weather (Short Description with Links)</title><description>&lt;h2&gt;
NYC Subway Ridership and Weather (Short Description)&lt;/h2&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&quot;Project 1&quot; is my final project for Udacity&#39;s course &quot;&lt;a href=&quot;http://whattheyseem.blogspot.com/2015/10/udacity-course-359-intro-to-data.html&quot; target=&quot;_blank&quot;&gt;Intro To Data Science&lt;/a&gt;&quot;. Here I present a short project description with links included.&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
------------------------------------&lt;i&gt;Project Description&lt;/i&gt;----------------------------------------&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
The project consisted essentially of three parts. Given weather data (&lt;a href=&quot;https://drive.google.com/file/d/0B15LMNvJXFnNMWRTelRLYjBZcTQ/view?usp=sharing&quot; target=&quot;_blank&quot;&gt;weather_underground.csv&lt;/a&gt;)&amp;nbsp;and NYC subway data (like&amp;nbsp;&lt;a href=&quot;https://drive.google.com/file/d/0B15LMNvJXFnNLTBkQS11d0ZkNjg/view?usp=sharing&quot; target=&quot;_blank&quot;&gt;turnstile_110528.txt&lt;/a&gt;), perform&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;1) Data Wrangling&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&amp;nbsp; &amp;nbsp; for producing a master file (&lt;a href=&quot;https://drive.google.com/file/d/0B15LMNvJXFnNSE5zSm1RSGpmNnc/view?usp=sharing&quot; target=&quot;_blank&quot;&gt;turnstile_data_master_with_weather.csv&lt;/a&gt;) on which the following &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; investigations are based:&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;2) Descriptive Statistics and Data Visualization&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;3) Data Analysis&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&amp;nbsp; &amp;nbsp; with particular regard to the question:&amp;nbsp;&lt;b&gt;Do more people ride the NYC subway when it is raining &amp;nbsp; &amp;nbsp; &amp;nbsp; or when it is not raining?&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
------------------------------------&lt;i&gt;Project Description&lt;/i&gt;----------------------------------------&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
While the data wrangling was done in Section 2 of the &lt;a href=&quot;http://whattheyseem.blogspot.com/2015/10/udacity-course-359-intro-to-data.html&quot; target=&quot;_blank&quot;&gt;course&lt;/a&gt;, the final project submission concentrated on parts 2 and 3. Some wrangling code can be seen &lt;b&gt;&lt;a href=&quot;http://whattheyseem.blogspot.com/2015/10/project-1-some-wrangling-code.html&quot; target=&quot;_blank&quot;&gt;HERE&lt;/a&gt;&lt;/b&gt;.&amp;nbsp;&lt;b&gt;The final project submission, slightly changed and extended by code examples, can be accessed &lt;a href=&quot;http://whattheyseem.blogspot.com/2015/10/project-1.html&quot; target=&quot;_blank&quot;&gt;HERE&lt;/a&gt;!&lt;/b&gt;&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description><link>http://whattheyseem.blogspot.com/2015/10/project-1-nyc-subway-ridership-and.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6012733759439953488.post-3208776693258163889</guid><pubDate>Fri, 02 Oct 2015 18:59:00 +0000</pubDate><atom:updated>2015-10-02T12:06:04.477-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Data Science</category><category domain="http://www.blogger.com/atom/ns#">Syllabus</category><category domain="http://www.blogger.com/atom/ns#">Udacity</category><title>Udacity Course 359  &quot;Intro To Data Science&quot; (Syllabus)</title><description>On September 10, I finished Udacity&#39;s&amp;nbsp;&lt;a href=&quot;https://www.udacity.com/course/intro-to-data-science--ud359&quot;&gt;Intro To Data Science&lt;/a&gt;&amp;nbsp;course. Here I present a slightly altered and augmented syllabus of the course.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;background-color: red; font-size: large;&quot;&gt;Lesson 1: Introduction to Data Science&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Introduction to Data Science&lt;br /&gt;
What is a Data Scientist&lt;br /&gt;
Pi-Chaun (Data Scientist @ Google): What is Data Science?&lt;br /&gt;
Simpson&#39;s Paradox&lt;br /&gt;
Intro to Numpy&lt;br /&gt;
Problems Solved by Data Science&lt;br /&gt;
Intro to Pandas&lt;br /&gt;
Dataframes&lt;br /&gt;
Exercises: Sotchi Olympic Medal Count&lt;br /&gt;
Pandas Vectorized Methods&lt;br /&gt;
Matrix Multiplication and Numpy Dot&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Problem Set 1: Titanic Survivor Data&lt;/b&gt;&lt;br /&gt;
(http://www.kaggle.com/c/titanic-gettingStarted/data)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;background-color: red; font-size: large;&quot;&gt;Lesson 2: Data Wrangling&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
What is Data Wrangling?&lt;br /&gt;
Acquiring Data&lt;br /&gt;
Common Data Formats&lt;br /&gt;
CSV Data&lt;br /&gt;
What are Relational Databases?&lt;br /&gt;
Aadhaar Data&lt;br /&gt;
Aadhaar Data and Relational Databases&lt;br /&gt;
Introduction to Databases Schemas&lt;br /&gt;
Database Queries Using Pandas and SQLite&lt;br /&gt;
API’s&lt;br /&gt;
Data in JSON Format&lt;br /&gt;
How to Access an API efficiently&lt;br /&gt;
Missing Values&lt;br /&gt;
Easy Imputation&lt;br /&gt;
Impute using Linear Regression&lt;br /&gt;
Tip of the Imputation Iceberg&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Problem Set 2: Wrangling Subway Data&lt;/b&gt;&lt;br /&gt;
Pandasql queries on Weather Data&lt;br /&gt;
Reformatting, Combining, Filtering New York Subway Data&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;background-color: red; font-size: large;&quot;&gt;Lesson 3: Data Analysis&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Statistical Rigor&lt;br /&gt;
Kurt (Data Scientist @ Twitter) - Why is Stats Useful?&lt;br /&gt;
Introduction to Normal Distribution&lt;br /&gt;
T Test&lt;br /&gt;
Welch T Test&lt;br /&gt;
Exercise: Welch&#39;s T-Test in Python on Baseball Data (left-handed vs right-handed hitters)&lt;br /&gt;
Non-Parametric Tests&lt;br /&gt;
Non-Normal Data&lt;br /&gt;
Stats vs. Machine Learning&lt;br /&gt;
Different Types of Machine Learning&lt;br /&gt;
Prediction with Regression&lt;br /&gt;
Linear Regression with Gradient Descent&lt;br /&gt;
Cost Function&lt;br /&gt;
How to Minimize Cost Function&lt;br /&gt;
Coefficients of Determination&lt;br /&gt;
Other Considerations&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Problem Set 3: Analyzing Subway Data&lt;/b&gt;&lt;br /&gt;
Histogram: Entries on Rainy Vs Entries on non-Rainy Days&lt;br /&gt;
Is Welch&#39;s T-Test Applicable?&lt;br /&gt;
Mann-Whitney U-Test (Entries on Rainy and Non-Rainy Days)&lt;br /&gt;
Linear Regression with Gradient Descent on Subway Data&lt;br /&gt;
Plotting Residuals&lt;br /&gt;
Compute R²&lt;br /&gt;
OLS Regression Using Python Module StatsModels (Optional)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;background-color: red; font-size: large;&quot;&gt;Lesson 4: Data Visualization&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Effective Information Visualization&lt;br /&gt;
Napoleon&#39;s March on Russia&lt;br /&gt;
Don (Principal Data Scientist @ AT&amp;amp;T): Communicating Findings&lt;br /&gt;
Rishiraj (Principal Data Scientist @ AT&amp;amp;T): Communicating Findings Well&lt;br /&gt;
Visual Encodings&lt;br /&gt;
Perception of Visual Cues&lt;br /&gt;
Plotting in Python (Intro to GGPLOT)&lt;br /&gt;
Data Types&lt;br /&gt;
Data Scales&lt;br /&gt;
Visualizing Time Series Data&lt;br /&gt;
Plots (Scatter, Line Charts, Loess Curve, Multivariate Data)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Problem Set 4: Visualizing Subway Data&lt;/b&gt;&lt;br /&gt;
Using Python and GGPLOT for plotting&lt;br /&gt;
- Ridership by time of day or day of week&lt;br /&gt;
- How ridership varies based on Subway station (UNIT)&lt;br /&gt;
- Which stations have more exits or entries at different times of day&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;background-color: red; font-size: large;&quot;&gt;Lesson 5: MapReduce&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Big Data and the MapReduce Programming Model&lt;br /&gt;
Basics of the MapReduce Programming Model&lt;br /&gt;
Mapper&lt;br /&gt;
Reducer&lt;br /&gt;
MapReduce with Aadhaar Data&lt;br /&gt;
MapReduce with Subway Data&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Problem Set 5: MapReduce on Subway Data&lt;/b&gt;&lt;br /&gt;
Ridership per Station&lt;br /&gt;
Ridersip by Weather Type&lt;br /&gt;
Busiest Hour&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;background-color: red; font-size: large;&quot;&gt;Final Project: Analyze the New York Subway Data&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</description><link>http://whattheyseem.blogspot.com/2015/10/udacity-course-359-intro-to-data.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6012733759439953488.post-8157764863465713186</guid><pubDate>Fri, 02 Oct 2015 11:19:00 +0000</pubDate><atom:updated>2015-10-02T04:19:58.676-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Data Science</category><category domain="http://www.blogger.com/atom/ns#">First Blog Post</category><category domain="http://www.blogger.com/atom/ns#">Mathematics</category><category domain="http://www.blogger.com/atom/ns#">Python</category><category domain="http://www.blogger.com/atom/ns#">Statistics</category><title>First Entry</title><description>This blog was created to publish my projects in data science. It may also contain short hints, remarks and interesting or funny facts around statistics and the programming language Python - the language I use most for processing and analyzing data. I am not a statistician, though I have some university mathematics background. I&#39;m also not a programmer, though I started learning programming in Python two and a half years ago. Nevertheless I like both very much and my aim is to improve my skills in that combination of fields called &quot;data science&quot;. I&#39;ll be using this blog to showcase projects for employers and other interested parties.&lt;br /&gt;
&lt;br /&gt;
The title of this blog is a variation of a quote from my favorite TV series &quot;Twin Peaks&quot;: &quot;The owls are not what they seem.&quot;</description><link>http://whattheyseem.blogspot.com/2015/10/first-entry.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item></channel></rss>