{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Correlation
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A correlation is the degree of association between two variables. One of my favorite books on this topic is: \n", "\n", "\n", "\n", "and they illustrate it by looking at\n", "## Ladies expenditures on clothes and makeup\n", "\n", "\n", "\n", "\n", "So let's go ahead and create that data in Pandas and show the table:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
clothesmakeup
Ms A70003000
Ms B80005000
Ms C2500012000
Ms D50002000
Ms E120007000
Ms F3000015000
Ms G100005000
Ms H150006000
Ms I200008000
Ms J1800010000
\n", "
" ], "text/plain": [ " clothes makeup\n", "Ms A 7000 3000\n", "Ms B 8000 5000\n", "Ms C 25000 12000\n", "Ms D 5000 2000\n", "Ms E 12000 7000\n", "Ms F 30000 15000\n", "Ms G 10000 5000\n", "Ms H 15000 6000\n", "Ms I 20000 8000\n", "Ms J 18000 10000" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import pandas as pd\n", "import numpy as np\n", "from pandas import DataFrame\n", "makeup = [3000, 5000, 12000, 2000, 7000, 15000, 5000, 6000, 8000, 10000]\n", "clothes = [7000, 8000, 25000, 5000, 12000, 30000, 10000, 15000, 20000, 18000]\n", "ladies = ['Ms A','Ms B','Ms C','Ms D','Ms E','Ms F','Ms G','Ms H','Ms I','Ms J',]\n", "monthly = DataFrame({'makeup': makeup, 'clothes': clothes}, index= ladies)\n", "monthly\n", " \n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "and let's show the scatterplot" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYcAAAD8CAYAAACcjGjIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFtZJREFUeJzt3W2MnfWZ3/HvtbZLZjeB4WHWtcdO7SyuJShaHI6Qt46q\nNHR33Gi1dhBKveoWr5bCSqAoaSNXnkTq7r7C1LuhQlXYsiXFUDbgEmdAYVmX2JG2L4rpOEMyPE2Z\nFig+GOwFBm/bEbKdqy/O/8CZuR3m6Yxnzvj7kY7Of677/p9zHbD9m/vp3JGZSJLU6hcWugFJ0uJj\nOEiSKgwHSVKF4SBJqjAcJEkVhoMkqcJwkCRVGA6SpArDQZJUsXyhG5itK664ItetW7fQbUhSRzl6\n9OhfZ2bPVOt1bDisW7eOwcHBhW5DkjpKRLw+nfXcrSRJqjAcJEkVhoMkqcJwkCRVGA6SpIopwyEi\nPhERz0bETyLihYj4o1K/LCKejohXyvOlLXP6I2I0IkYioq+lfl1EDJdl90RElPpFEfFoqR+JiHXt\n/6iS1NkGhups2XOY9bufZMuewwwM1eftvaaz5fAB8IXM/FXgWmBrRGwGdgOHMnMDcKj8TERcBewA\nrga2At+OiGXlte4FbgU2lMfWUr8FeC8zrwTuBu5qw2eTpCVjYKhO/4Fh6mPjJFAfG6f/wPC8BcSU\n4ZAN/6f8uKI8EtgG7Cv1fcD2Mt4GPJKZH2Tmq8AocH1ErAIuzsxnsnFv0gcnzWm+1mPADc2tCkkS\n7D04wvjpsxNq46fPsvfgyLy837SOOUTEsoh4DjgBPJ2ZR4CVmXm8rPIWsLKMe4E3WqYfK7XeMp5c\nnzAnM88A7wOXn6OP2yJiMCIGT548OZ3WJWlJeHNsfEb1uZpWOGTm2cy8FlhDYyvg701anjS2JuZV\nZt6XmbXMrPX0THn1tyQtGau7u2ZUn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uYm4P/S2L3xocXae9k/v41GwK0Gfiki\nfqd1ncXa+7l0Uq+tIuKbNO4M+fBC9zKViPhF4BvAv17oXs6HJRMOEbGCRjA8nJkHSvntiFhVlq8C\nTpR6ncZ+w6Y1pVYv48n1+bQF+K2IeA14BPhCRPwnOqP3Y8CxzDxSfn6MRlh0Qu//CHg1M09m5mng\nAPD3O6T3pnb2+uGciFhOY5fhO/PWeeN9fhf4TeCflnCb0MekHhdD779C45eJn5S/r2uAH0fE317k\nfc/KkgiHcvT/fuClzPxWy6IngJ1lvJPGsYhmfUc5W2A9sAF4tmyin4qIzeU1b26ZMy8ysz8z12Tm\nOhoHpQ5n5u90SO9vAW9ExMZSuoHGPcIXfe80didtjohfLO95A/BSh/Te1M5eW1/rJhp/DudtSyQi\nttLYlfpbmfn/Jn2mRdl7Zg5n5i9n5rry9/UYjRNh3lrMfc/aQh/0aMcD+ByNTeqfAs+Vxxdp7L87\nBLwC/BC4rGXON2mcUTBCy9klQA14viz7d5zHA0TA5/nogHRH9A5cCwyW//YDwKUd1PsfAS+X932I\nxpkmi7J34Ls0jo2cpvGP0i3t7BX4BPCfgVEaZ9d8Zp57H6Wxv7359/VPF1vv5+p70vLXKAekF1Pf\n7Xp4hbQkqWJJ7FaSJLWX4SBJqjAcJEkVhoMkqcJwkCRVGA6SpArDQZJUYThIkir+PzRofEzkatT/\nAAAAAElFTkSuQmCC\n", "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Import package\n", "import matplotlib.pyplot as plt\n", "\n", "# Build Scatter plot\n", "plt.scatter(monthly['makeup'], monthly['clothes'])\n", "\n", "\n", "# Show plot\n", "plt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "That's pretty good. But notice in the picture of the chart from The Manga Guide to Statistics that there is a title to the chart as well as labels for the x and y axis. Can you add those to the chart?\n", "\n", "\n", "

Task 1: labels

\n", "\n" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [], "source": [ "# TBD" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "When the data points are close to a straight line going up, we say that there is a positive correlation between the two variables. It's sort of like saying:\n", "\n", " Ann: Is there any relationship between how much a person spends on makeup and how much they spend on clothes?\n", " Ms. Graph: Yes. The more a person spends on makeup the more she spends on clothes.\n", "\n", "Let's look at a few more examples:\n", "\n", "## Weight and calories in 1-3 yr/old children\n", "This is real data on the weight and calories consumed for children between 1 and 3 years of age." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
caloriesweight
03607.7
14007.8
25008.6
33708.5
45258.6
58009.0
690010.1
7120011.5
8100011.0
9140010.2
10160011.9
1185010.4
125759.3
134259.1
149508.5
1580011.0
\n", "
" ], "text/plain": [ " calories weight\n", "0 360 7.7\n", "1 400 7.8\n", "2 500 8.6\n", "3 370 8.5\n", "4 525 8.6\n", "5 800 9.0\n", "6 900 10.1\n", "7 1200 11.5\n", "8 1000 11.0\n", "9 1400 10.2\n", "10 1600 11.9\n", "11 850 10.4\n", "12 575 9.3\n", "13 425 9.1\n", "14 950 8.5\n", "15 800 11.0" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "weight = [7.7, 7.8, 8.6, 8.5, 8.6, 9, 10.1, 11.5, 11, 10.2, 11.9, 10.4, 9.3, 9.1, 8.5, 11]\n", "calories = [360, 400, 500, 370, 525, 800, 900, 1200, 1000, 1400, 1600, 850, 575, 425, 950, 800]\n", "kids = DataFrame({'weight': weight, 'calories': calories})\n", "kids" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "

Task 2: draw the scatter plot with appropriate labels

\n", "We are interested in seeing the correlation between weight and calories consumed.\n", "\n" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [], "source": [ "# Your code here" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "

What do you think? Is there a correlation?

\n", "\n", "\n", "\n", "\n", "\n", "\n", "## The stronger the correlation the closer to a straight line:\n", "The more the datapoints are in a straight line, the sronger the correlation. Let's look at students' midtern and final grades.\n" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
finalmidterm
07265
16870
27572
37675
47978
57378
67980
78583
88987
98787
109290
119390
129492
139193
149795
1598100
\n", "
" ], "text/plain": [ " final midterm\n", "0 72 65\n", "1 68 70\n", "2 75 72\n", "3 76 75\n", "4 79 78\n", "5 73 78\n", "6 79 80\n", "7 85 83\n", "8 89 87\n", "9 87 87\n", "10 92 90\n", "11 93 90\n", "12 94 92\n", "13 91 93\n", "14 97 95\n", "15 98 100" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "midterm = [65, 70, 72, 75, 78, 78, 80, 83, 87, 87, 90, 90, 92, 93, 95, 100]\n", "final = [72, 68, 75, 76, 79, 73, 79, 85, 89, 87, 92, 93, 94, 91, 97, 98]\n", "grades = DataFrame({'midterm': midterm, 'final': final})\n", "grades" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Task 3: Can you create that scatter plot?

\n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# Your code here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## The Medicine Hat Tigers\n", "\n", "\n", "\n", "Let's load in some data about players from the Medicine Hat Tigers.\n", "After that we'll create a few new columns:\n", "\n", "* `heightcm` is the height of the player in centimeters (note that the Height column is the player's height in inches)\n", "* `hometownLength` is the number of characters in the string representing the hometown. for example, number 11, Jordon Hickmott's hometown is Mission BC which has 10 letters as indicated in hometownLength." ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
NamePos.L/RHeightWeightBirthdayHometownheightcmhometownLength
0Brennan BoschCR6817302/14/88Martensville, SK172.7216
1Scott WasdenCR7318801/04/88Westbank, BC185.4212
2Colton GrantLWL6917703/20/89Standard, AB175.2612
3Darren HelmLWL7218201/21/87St. Andrews, MB182.8815
4Derek DorsettRWL7117812/20/86Kindersley, SK180.3414
5Daine ToddCR7017301/10/87Red Deer, AB177.8012
6Tyler SwystunRWR7118501/15/88Cochrane, AB180.3412
7Matt LowryCR7218603/02/88Neepawa, MB182.8811
8Kevin UndershuteLWL7217804/12/87Medicine Hat, AB182.8816
9Jerrid SauerRWR7119609/12/87Medicine Hat, AB180.3416
10Tyler EnnisCL6916010/06/89Edmonton, AB175.2612
11Jordan HickmottCR7218304/11/90Mission BC182.8810
12Jakub RumpelRWR6816601/27/87Hrnciarovce, SLO172.7216
13Bretton CameronCR7116801/26/89Didsbury, AB180.3412
14Chris StevensLWL7019708/20/86Dawson Creek, BC177.8016
15Gord BaldwinDL7720503/01/87Winnipeg, MB195.5812
16David SchlemkoDL7319505/07/87Edmonton, AB185.4212
17Trever GlassDL7219001/22/88Cochrane, AB182.8812
18Kris RussellDL7017705/02/87Caroline, AB177.8012
19Michael SauerDR7320508/07/87Sartell, MN185.4211
20Mark IsherwoodDR7218301/31/89Abbotsford, BC182.8814
21Shayne BrownDL7319802/20/89Stony Plain, AB185.4215
22Jordan BendfeldDR7523002/09/88Ledue, AB190.509
23Ryan HolfeldGL7116606/29/89LeRoy, SK180.349
24Matt KeetleyGR7418904/27/86Medicine Hat, AB187.9616
\n", "
" ], "text/plain": [ " Name Pos. L/R Height Weight Birthday Hometown \\\n", "0 Brennan Bosch C R 68 173 02/14/88 Martensville, SK \n", "1 Scott Wasden C R 73 188 01/04/88 Westbank, BC \n", "2 Colton Grant LW L 69 177 03/20/89 Standard, AB \n", "3 Darren Helm LW L 72 182 01/21/87 St. Andrews, MB \n", "4 Derek Dorsett RW L 71 178 12/20/86 Kindersley, SK \n", "5 Daine Todd C R 70 173 01/10/87 Red Deer, AB \n", "6 Tyler Swystun RW R 71 185 01/15/88 Cochrane, AB \n", "7 Matt Lowry C R 72 186 03/02/88 Neepawa, MB \n", "8 Kevin Undershute LW L 72 178 04/12/87 Medicine Hat, AB \n", "9 Jerrid Sauer RW R 71 196 09/12/87 Medicine Hat, AB \n", "10 Tyler Ennis C L 69 160 10/06/89 Edmonton, AB \n", "11 Jordan Hickmott C R 72 183 04/11/90 Mission BC \n", "12 Jakub Rumpel RW R 68 166 01/27/87 Hrnciarovce, SLO \n", "13 Bretton Cameron C R 71 168 01/26/89 Didsbury, AB \n", "14 Chris Stevens LW L 70 197 08/20/86 Dawson Creek, BC \n", "15 Gord Baldwin D L 77 205 03/01/87 Winnipeg, MB \n", "16 David Schlemko D L 73 195 05/07/87 Edmonton, AB \n", "17 Trever Glass D L 72 190 01/22/88 Cochrane, AB \n", "18 Kris Russell D L 70 177 05/02/87 Caroline, AB \n", "19 Michael Sauer D R 73 205 08/07/87 Sartell, MN \n", "20 Mark Isherwood D R 72 183 01/31/89 Abbotsford, BC \n", "21 Shayne Brown D L 73 198 02/20/89 Stony Plain, AB \n", "22 Jordan Bendfeld D R 75 230 02/09/88 Ledue, AB \n", "23 Ryan Holfeld G L 71 166 06/29/89 LeRoy, SK \n", "24 Matt Keetley G R 74 189 04/27/86 Medicine Hat, AB \n", "\n", " heightcm hometownLength \n", "0 172.72 16 \n", "1 185.42 12 \n", "2 175.26 12 \n", "3 182.88 15 \n", "4 180.34 14 \n", "5 177.80 12 \n", "6 180.34 12 \n", "7 182.88 11 \n", "8 182.88 16 \n", "9 180.34 16 \n", "10 175.26 12 \n", "11 182.88 10 \n", "12 172.72 16 \n", "13 180.34 12 \n", "14 177.80 16 \n", "15 195.58 12 \n", "16 185.42 12 \n", "17 182.88 12 \n", "18 177.80 12 \n", "19 185.42 11 \n", "20 182.88 14 \n", "21 185.42 15 \n", "22 190.50 9 \n", "23 180.34 9 \n", "24 187.96 16 " ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "medicineHat = pd.read_csv('https://raw.githubusercontent.com/zacharski/machine-learning/master/data/medicineHatTigers.csv')\n", "medicineHat['heightcm'] = medicineHat['Height'] * 2.54\n", "medicineHat['hometownLength'] = medicineHat['Hometown'].str.len()\n", "medicineHat\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's explore this data a bit. (Some of these are screwy examples but they illustrate a point)\n", "\n", "

Task 4: Can you create a scatter plot showing the correlation between height in inches and height in cm?

\n", "\n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Task 5: A scatter plot showing the correlation between a person's height in inches and the number of characters in the hometown

\n", "\n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Task 6: A scatter plot showing the correlation between a person's height in cm and their weight.

\n", "\n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "

Task 7: Which of these has the best correlation? Which shows no correlation?

\n", "As you can see, if the scatter plot is on a straight line it has perfect correlation.\n", "\n", "And if dots are scattered all over the place than there is likely no correlation. \n", "\n", "\n", "Let's look at some other lines:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## negative correlation has a line going downhill\n", "\n", "#### the relationship of hair length to a person's height" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZcAAAEWCAYAAACqitpwAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XuYnHV99/H3h02ABQMBEi3hkEBbtuKJ6Cr44AGRGlEe\nSa1WrVJBKNX2EUGNJdarog9aNFbFam0RFTwXaIxoLw22gjyooBuCRsB4QE4bDgFZCLDIEr7PH7/f\nhnuHmdl7Z+/Z2Zl8Xtc118x9/H1/9+k791kRgZmZWZV26HQAZmbWe5xczMysck4uZmZWOScXMzOr\nnJOLmZlVzsnFzMwq5+QCSHq9pEs6Hcc4Sf2SvinpXkkXdjqeRiQtkRSS5uTmb0t6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tre5b0AuDlwHmSPhoRXyhRhlml\nfFjMut0lwFvHG/KDJWtdSTpkBuklTGVsAeZNL7Qp+S5wwvgVapL2nKT/tcBb8h4Kkg5SeqHcYuCO\niPgM6RDhM9sZtFkjTi7W7U4BBvNJ7euAek++PRV4u6SfAX8EPO5ps3WcA3yn3gn9doiI75AeeT+U\nD8+9c5JBziU97v9qST8H/p20V3ME6d0f64HXkM43mc04PxXZel7eGxiNiJD0WuB1EXFsp+My62U+\n52Lbg2cBn1Q6ETNCeqe6mbWR91zMzKxyPudiZmaVc3IxM7PKObmYmVnlnFzMzKxyTi5mZla5/w8T\nEFSkmXs5IgAAAABJRU5ErkJggg==\n", "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "height =[62, 64, 65, 68, 69, 70, 67, 65, 72, 73, 74]\n", "hairLength = [7, 10, 6, 4, 5, 4, 5, 8, 1, 1, 3]\n", "cm = [173, 185, 175, 183, 180, 196]\n", "people = DataFrame({'height': height, 'hairLength': hairLength})\n", "\n", "plt.scatter(people['height'], people['hairLength'])\n", "\n", "\n", "xlab = 'Amount Spent on Makeup [in Yen]'\n", "ylab = 'Amount Spent on Clothes [in Yen]'\n", "title = 'Weight and calories in 1 to 3 yr. old children'\n", "\n", "# Add axis labels\n", "plt.xlabel(\"Height in Inches\")\n", "plt.ylabel(\"Hair Length in Inches\")\n", "\n", "\n", "# Add title\n", "plt.title(\"Comparison of an Individual's Height to the Length of their Hair\")\n", "\n", "\n", "# Show plot\n", "plt.show()\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "So The taller someone is, the shorter their hair.\n", "

Task 7: A question

\n", "Do you think correlation means causation? This means that Do you think as a person gets taller somehow that causes a perons's hair to be shorter?\n", "\n", "\n", "\n", "\n", "\n", "\n", "## The Effects of Alcohol on the Dexterity Score\n", "#### a strong negative correlation" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAA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cMeypGPz/O+W9JXc\n7zPAIcClkqZ1taARsRj4v6RHWiPpHElXSvojcGUu/5dVwy6TdHNextMK4tkln53sL2nPvPx35mXa\nratYrDX5DML6o4uAv0n6ag+m2Qd4NemxyYuBSyLiAKWXJ50KnJHHG0N6JPyuwE2SXgmcQHpS6P6S\nNgX+KKny1ND9gL0i4oHqwiSNAr4CvAZ4CviNpIkR8XlJbwbOymcA3bkD2L2qew/gkIjokHRozbi7\nA28CXg4skvTdqnjGkp5J9YGIuEvSt4FvRkTlruvBdcRiLcZnENbv5CfR/pB8ZF2nv+b3YrwA/BOo\n7OAXkJJCxYyIWBsR95MSye7AW4ET8mNKbgW2ASpH3LfVJodsf+Dm/CC51cDVpHc19JRqumdHREcn\n4/4qIl7IVW/LWfcI6BGkZ/W8PyLuyv3+DHxS0ieAnbqYp7UwJwjrry4g1eVXv+9gNfk3LWkQsEnV\nsBeqPq+t6l7L+mfStc+eCdJO+tSI2Df/7Vz13oHn+7QU3RvH+g+g66q86mVcw7rlepr0YLtDKgMj\n4kfAkUAf/a7bAAABBElEQVQH8Ot8VmO2HicI65ci4klgBilJVDxIqtKBtPMb2otZHy1pUG6X2AVY\nRHqw40fzI9OR9Ko6XsRzG/BGSdsqveb2WOCWngSSX+70NeDbPVuEf/Mi8L9JZ0Hvy/PeBVgcEd8i\nnV38Rx/LsAHIbRDWn50PfKyq+wfAdZLuAq6nd0f3D5N27lsCH4mIf0m6hFQNdUd+rPQKunnFY0Qs\nlTQFuIl0BvKriKjnkcy7SpoPbAY8C3wrIq7oxXLUxvN8bnS/ITfe7wEcL2kV6Y1kX+5rGTbw+Gmu\nZmZWyFVMZmZWyAnCzMwKOUGYmVkhJwgzMyvkBGFmZoWcIMzMrJAThJmZFfofUpgTaesaImwAAAAA\nSUVORK5CYII=\n", "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "drinks = list(range(11))\n", "dexterity = [96, 96, 90, 63, 65, 50, 47, 46, 18, 17, 9]\n", "drinking = DataFrame({'drinks': drinks, 'dexterity': dexterity})\n", "\n", "plt.scatter(drinking['drinks'], drinking['dexterity'])\n", "\n", "\n", "\n", "# Add axis labels\n", "plt.xlabel(\"Number of Drinks\")\n", "plt.ylabel(\"Dexterity Score\")\n", "\n", "\n", "# Add title\n", "plt.title(\"The effects of alcohol consumption on dexterity\")\n", "\n", "\n", "# Show plot\n", "plt.show()\n", "\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Numeric Represenstation of the Strength of the Correlation\n", "\n", "\n", "So far we've looked at correlations visually. The more a scatter plot looks like a straight line the stronger the correlation. If the line goes up from left to right it is a positive correlation. If it goes down it is a negative correlation. We can also determine correlation using a number...\n", "\n", "## Pearson Correlation Coefficient\n", "\n", "The Pearson Correlation Coefficient ranges from -1 to 1.\n", "1 is perfect positive correlation, -1 is perfect negative. The formula is as follows:\n", "\n", "$$r=\\frac{\\sum_{i=1}^n(x_i - \\bar{x})(y_i-\\bar{y})}{\\sqrt{\\sum_{i=1}^n(x_i - \\bar{x})} \\sqrt{\\sum_{i=1}^n(y_i - \\bar{y})}}$$\n", "\n", "Let me say immediately that you don't need to know that formula for this class. Should you dive deeper into Data Science you will need to interpret and apply formulas like this, but the good news is that these formulas always look a lot harder than they actually are. (Take it from me -- I had zero real math classes in high school and none in college (I have a Bachelor of Fine Arts degree))\n", "\n", "Anyway, let's ignore the formula and think that a number near 1 means a positive correlation; 0 means no correlation, and near -1 means a strong negative correlation. \n", "\n", "### Japanese ladies expensives on makeup and clothes\n", "Let's go back to our first example.\n", "First here is the data:" ] }, { "cell_type": "code", "execution_count": 77, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
clothesmakeup
Ms A70003000
Ms B80005000
Ms C2500012000
Ms D50002000
Ms E120007000
Ms F3000015000
Ms G100005000
Ms H150006000
Ms I200008000
Ms J1800010000
\n", "
" ], "text/plain": [ " clothes makeup\n", "Ms A 7000 3000\n", "Ms B 8000 5000\n", "Ms C 25000 12000\n", "Ms D 5000 2000\n", "Ms E 12000 7000\n", "Ms F 30000 15000\n", "Ms G 10000 5000\n", "Ms H 15000 6000\n", "Ms I 20000 8000\n", "Ms J 18000 10000" ] }, "execution_count": 77, "metadata": {}, "output_type": "execute_result" } ], "source": [ "monthly" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And our Scatter plot looked like this:" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYcAAAD8CAYAAACcjGjIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFtZJREFUeJzt3W2MnfWZ3/HvtbZLZjeB4WHWtcdO7SyuJShaHI6Qt46q\nNHR33Gi1dhBKveoWr5bCSqAoaSNXnkTq7r7C1LuhQlXYsiXFUDbgEmdAYVmX2JG2L4rpOEMyPE2Z\nFig+GOwFBm/bEbKdqy/O/8CZuR3m6Yxnzvj7kY7Of677/p9zHbD9m/vp3JGZSJLU6hcWugFJ0uJj\nOEiSKgwHSVKF4SBJqjAcJEkVhoMkqcJwkCRVGA6SpArDQZJUsXyhG5itK664ItetW7fQbUhSRzl6\n9OhfZ2bPVOt1bDisW7eOwcHBhW5DkjpKRLw+nfXcrSRJqjAcJEkVhoMkqcJwkCRVGA6SpIopwyEi\nPhERz0bETyLihYj4o1K/LCKejohXyvOlLXP6I2I0IkYioq+lfl1EDJdl90RElPpFEfFoqR+JiHXt\n/6iS1NkGhups2XOY9bufZMuewwwM1eftva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SBJqjAcJEkVhoMkqcJwkCRVGA6SpArDQZJUYThIkir+PzRofEzkatT/\nAAAAAElFTkSuQmCC\n", "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Import package\n", "import matplotlib.pyplot as plt\n", "\n", "# Build Scatter plot\n", "plt.scatter(monthly['makeup'], monthly['clothes'])\n", "\n", "\n", "# Show plot\n", "plt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "So that looks like a pretty strong positive correlation. To compute Pearson on this data we do:" ] }, { "cell_type": "code", "execution_count": 80, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
clothesmakeup
clothes1.000000.96802
makeup0.968021.00000
\n", "
" ], "text/plain": [ " clothes makeup\n", "clothes 1.00000 0.96802\n", "makeup 0.96802 1.00000" ] }, "execution_count": 80, "metadata": {}, "output_type": "execute_result" } ], "source": [ "monthly.corr()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "So we have a nice table with 1s on the diagonal. The diagonal states the obvious: clothes expenditures are perfectly correlated with clothes expenditures and makeup expenditures are perfectly correlated with makeup expenditures. \n", "\n", "The other cells are the interesting ones and they show that the correlation between clothes and makeup is very strong at 0.96802.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's look at the correlation between the number of drinks and dexterity: " ] }, { "cell_type": "code", "execution_count": 83, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
dexteritydrinks
dexterity1.000000-0.979237
drinks-0.9792371.000000
\n", "
" ], "text/plain": [ " dexterity drinks\n", "dexterity 1.000000 -0.979237\n", "drinks -0.979237 1.000000" ] }, "execution_count": 83, "metadata": {}, "output_type": "execute_result" } ], "source": [ "drinking.corr()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "So -0.97923 indicates a very strong negative correlation" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "

Task 8: School Music Program: a case study

\n", "\n", "We are interested in seeing whether a relationship exists between music performance\n", "grades and students' individual Iowa Test of Basic Skills (ITBS) scores. Let's load in the data" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
BandMathLanguageScience
Student
13220215220
24240210225
33210250235
42215230210
54260240220
63230270250
74240240220
84259220240
93245230250
104280270230
115300260220
122230250225
133250245235
144275235210
153200260220
162200255250
174290250220
183250230240
194270245250
204260270230
213260270260
224270250230
235310260260
242170250220
\n", "
" ], "text/plain": [ " Band Math Language Science\n", "Student \n", "1 3 220 215 220\n", "2 4 240 210 225\n", "3 3 210 250 235\n", "4 2 215 230 210\n", "5 4 260 240 220\n", "6 3 230 270 250\n", "7 4 240 240 220\n", "8 4 259 220 240\n", "9 3 245 230 250\n", "10 4 280 270 230\n", "11 5 300 260 220\n", "12 2 230 250 225\n", "13 3 250 245 235\n", "14 4 275 235 210\n", "15 3 200 260 220\n", "16 2 200 255 250\n", "17 4 290 250 220\n", "18 3 250 230 240\n", "19 4 270 245 250\n", "20 4 260 270 230\n", "21 3 260 270 260\n", "22 4 270 250 230\n", "23 5 310 260 260\n", "24 2 170 250 220" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "musicFile = \"https://raw.githubusercontent.com/zacharski/machine-learning/master/data/musicITBS.csv\"\n", "music = pd.read_csv(musicFile)\n", "music.set_index('Student', inplace=True)\n", "\n", "music" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We want to know what test score (math, language, science) that the music performance grade is most highly correlated with. Write code that computes the correlation table. Also, for the most highly correlated pair, please draw a scatter plot. For example, if science is most highly correlated with band draw that scatter plot.\n" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [], "source": [ "# Your code here\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Using a scatter plot graph the strongest association\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Task 9: What do you think?

\n", "\n", "1. Is knowing a person's music performance grade a good predictor for that person's score in math? language? science?\n", "\n", "2. Does this study offer support for an argument not to eliminate the music program at our high school because it improves math scores?\n", "\n", "3. Does this study offer support for an argument that eliminating the music program will have no effect on language scores?" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.1" } }, "nbformat": 4, "nbformat_minor": 1 }