diff --git a/labs07/gapminder.csv b/labs07/gapminder.csv new file mode 100644 index 0000000..534a004 --- /dev/null +++ b/labs07/gapminder.csv @@ -0,0 +1,177 @@ +,female_BMI,male_BMI,gdp,population,under5mortality,life_expectancy,fertility +Afghanistan,21.07402,20.62058,1311.0,26528741.0,110.4,52.8,6.2 +Albania,25.65726,26.44657,8644.0,2968026.0,17.9,76.8,1.76 +Algeria,26.368409999999997,24.5962,12314.0,34811059.0,29.5,75.5,2.73 +Angola,23.48431,22.25083,7103.0,19842251.0,192.0,56.7,6.43 +Antigua and Barbuda,27.50545,25.76602,25736.0,85350.0,10.9,75.5,2.16 +Argentina,27.46523,27.5017,14646.0,40381860.0,15.4,75.4,2.24 +Armenia,27.1342,25.355420000000002,7383.0,2975029.0,20.0,72.3,1.4 +Australia,26.87777,27.56373,41312.0,21370348.0,5.2,81.6,1.96 +Austria,25.09414,26.467409999999997,43952.0,8331465.0,4.6,80.4,1.41 +Azerbaijan,27.50879,25.65117,14365.0,8868713.0,43.3,69.2,1.99 +Bahamas,29.13948,27.24594,24373.0,348587.0,14.5,72.2,1.89 +Bahrain,28.790940000000003,27.83721,42507.0,1115777.0,9.4,77.6,2.23 +Bangladesh,20.54531,20.39742,2265.0,148252473.0,55.9,68.3,2.38 +Barbados,29.221690000000002,26.384390000000003,16075.0,277315.0,15.4,75.3,1.83 +Belarus,26.641859999999998,26.16443,14488.0,9526453.0,7.2,70.0,1.42 +Belgium,25.1446,26.75915,41641.0,10779155.0,4.7,79.6,1.82 +Belize,29.81663,27.02255,8293.0,306165.0,20.1,70.7,2.91 +Benin,23.74026,22.41835,1646.0,8973525.0,116.3,59.7,5.27 +Bhutan,22.88243,22.8218,5663.0,694990.0,48.1,70.7,2.51 +Bolivia,26.8633,24.43335,5066.0,9599916.0,52.0,71.2,3.48 +Bosnia and Herzegovina,26.35874,26.611629999999998,9316.0,3839749.0,8.1,77.5,1.22 +Botswana,26.09156,22.129839999999998,13858.0,1967866.0,63.8,53.2,2.86 +Brazil,25.99113,25.78623,13906.0,194769696.0,18.6,73.2,1.9 +Brunei,22.892310000000002,24.18179,72351.0,380786.0,9.0,76.9,2.1 +Bulgaria,25.51574,26.542859999999997,15368.0,7513646.0,13.7,73.2,1.43 +Burkina Faso,21.63031,21.27157,1358.0,14709011.0,130.4,58.0,6.04 +Burundi,21.27927,21.50291,723.0,8821795.0,108.6,59.1,6.48 +Cambodia,21.69608,20.80496,2442.0,13933660.0,51.5,66.1,3.05 +Cameroon,24.9527,23.681729999999998,2571.0,19570418.0,113.8,56.6,5.17 +Canada,26.698290000000004,27.4521,41468.0,33363256.0,5.8,80.8,1.68 +Cape Verde,24.96136,23.515220000000003,6031.0,483824.0,28.4,70.4,2.57 +Chad,21.95424,21.485689999999998,1753.0,11139740.0,168.0,54.3,6.81 +Chile,27.92807,27.015420000000002,18698.0,16645940.0,8.9,78.5,1.89 +China,22.91041,22.92176,7880.0,1326690636.0,18.5,73.4,1.53 +Colombia,26.22529,24.94041,10489.0,44901660.0,19.7,76.2,2.43 +Comoros,22.444329999999997,22.06131,1440.0,665414.0,91.2,67.1,5.05 +"Congo, Dem. Rep.",21.6677,19.86692,607.0,61809278.0,124.5,57.5,6.45 +"Congo, Rep.",23.10824,21.87134,5022.0,3832771.0,72.6,58.8,5.1 +Costa Rica,27.03497,26.47897,12219.0,4429506.0,10.3,79.8,1.91 +Cote d'Ivoire,23.82088,22.56469,2854.0,19261647.0,116.9,55.4,4.91 +Croatia,25.17882,26.596290000000003,21873.0,4344151.0,5.9,76.2,1.43 +Cuba,26.576140000000002,25.06867,17765.0,11290239.0,6.3,77.6,1.5 +Cyprus,25.92587,27.41899,35828.0,1077010.0,4.2,80.0,1.49 +Denmark,25.106270000000002,26.13287,45017.0,5495302.0,4.3,78.9,1.89 +Djibouti,24.38177,23.38403,2502.0,809639.0,81.0,61.8,3.76 +Ecuador,27.062690000000003,25.58841,9244.0,14447600.0,26.8,74.7,2.73 +Egypt,30.099970000000003,26.732429999999997,9974.0,78976122.0,31.4,70.2,2.95 +El Salvador,27.84092,26.36751,7450.0,6004199.0,21.6,73.7,2.32 +Equatorial Guinea,24.528370000000002,23.7664,40143.0,686223.0,118.4,57.5,5.31 +Eritrea,21.082320000000003,20.885089999999998,1088.0,4500638.0,60.4,60.1,5.16 +Estonia,25.185979999999997,26.264459999999996,24743.0,1339941.0,5.5,74.2,1.62 +Ethiopia,20.71463,20.247,931.0,83079608.0,86.9,60.0,5.19 +Fiji,29.339409999999997,26.53078,7129.0,843206.0,24.0,64.9,2.74 +Finland,25.58418,26.733390000000004,42122.0,5314170.0,3.3,79.6,1.85 +France,24.82949,25.853289999999998,37505.0,62309529.0,4.3,81.1,1.97 +Gabon,25.95121,24.0762,15800.0,1473741.0,68.0,61.7,4.28 +Gambia,24.82101,21.65029,1566.0,1586749.0,87.4,65.7,5.8 +Georgia,26.45014,25.54942,5900.0,4343290.0,19.3,71.8,1.79 +Germany,25.73903,27.165090000000003,41199.0,80665906.0,4.4,80.0,1.37 +Ghana,24.33014,22.842470000000002,2907.0,23115919.0,79.9,62.0,4.19 +Greece,24.92026,26.33786,32197.0,11161755.0,4.9,80.2,1.46 +Grenada,27.31948,25.179879999999997,12116.0,103934.0,13.5,70.8,2.28 +Guatemala,26.84324,25.29947,6960.0,14106687.0,36.9,71.2,4.12 +Guinea,22.45206,22.52449,1230.0,10427356.0,121.0,57.1,5.34 +Guinea-Bissau,22.92809,21.64338,1326.0,1561293.0,127.6,53.6,5.25 +Guyana,26.470190000000002,23.68465,5208.0,748096.0,41.9,65.0,2.74 +Haiti,23.27785,23.66302,1600.0,9705130.0,83.3,61.0,3.5 +Honduras,26.73191,25.10872,4391.0,7259470.0,26.5,71.8,3.27 +"Hong Kong, China",23.71046,25.057470000000002,46635.0,6910384.0,3.06,82.49,1.04 +Hungary,25.97839,27.115679999999998,23334.0,10050699.0,7.2,73.9,1.33 +Iceland,26.02599,27.206870000000002,42294.0,310033.0,2.7,82.4,2.12 +India,21.31478,20.95956,3901.0,1197070109.0,65.6,64.7,2.64 +Indonesia,22.986929999999997,21.85576,7856.0,235360765.0,36.2,69.4,2.48 +Iran,27.236079999999998,25.310029999999998,15955.0,72530693.0,21.4,73.1,1.88 +Iraq,28.411170000000002,26.71017,11616.0,29163327.0,38.3,66.6,4.34 +Ireland,26.62176,27.65325,47713.0,4480145.0,4.5,80.1,2.0 +Israel,27.301920000000003,27.13151,28562.0,7093808.0,4.9,80.6,2.92 +Italy,24.79289,26.4802,37475.0,59319234.0,4.1,81.5,1.39 +Jamaica,27.22601,24.00421,8951.0,2717344.0,18.9,75.1,2.39 +Japan,21.87088,23.50004,34800.0,127317900.0,3.4,82.5,1.34 +Jordan,29.218009999999996,27.47362,10897.0,6010035.0,22.1,76.9,3.59 +Kazakhstan,26.65065,26.290779999999998,18797.0,15915966.0,25.9,67.1,2.51 +Kenya,23.06181,21.592579999999998,2358.0,38244442.0,71.0,60.8,4.76 +Kiribati,31.30769,29.2384,1803.0,98437.0,64.5,61.5,3.13 +Kuwait,31.161859999999997,29.172109999999996,91966.0,2705290.0,11.3,77.3,2.68 +Latvia,25.615129999999997,26.45693,20977.0,2144215.0,10.5,72.4,1.5 +Lebanon,27.70471,27.20117,14158.0,4109389.0,11.3,77.8,1.57 +Lesotho,26.780520000000003,21.90157,2041.0,1972194.0,114.2,44.5,3.34 +Liberia,23.21679,21.89537,588.0,3672782.0,100.9,59.9,5.19 +Libya,29.19874,26.54164,29853.0,6123022.0,18.8,75.6,2.64 +Lithuania,26.01424,26.86102,23223.0,3219802.0,8.2,72.1,1.42 +Luxembourg,26.09326,27.434040000000003,95001.0,485079.0,2.8,81.0,1.63 +"Macao, China",24.895039999999998,25.713820000000002,80191.0,507274.0,6.72,79.32,0.94 +"Macedonia, FYR",25.37646,26.34473,10872.0,2055266.0,11.8,74.5,1.47 +Madagascar,20.73501,21.403470000000002,1528.0,19926798.0,66.7,62.2,4.79 +Malawi,22.91455,22.034679999999998,674.0,13904671.0,101.1,52.4,5.78 +Malaysia,25.448320000000002,24.73069,19968.0,27197419.0,8.0,74.5,2.05 +Maldives,26.4132,23.219910000000002,12029.0,321026.0,16.0,78.5,2.38 +Mali,23.07655,21.78881,1602.0,14223403.0,148.3,58.5,6.82 +Malta,27.04993,27.683609999999998,27872.0,406392.0,6.6,80.7,1.38 +Mauritania,26.26476,22.62295,3356.0,3414552.0,103.0,67.9,4.94 +Mauritius,26.09824,25.15669,14615.0,1238013.0,15.8,72.9,1.58 +Mexico,28.737509999999997,27.42468,15826.0,114972821.0,17.9,75.4,2.35 +"Micronesia, Fed. Sts.",31.28402,28.10315,3197.0,104472.0,43.1,68.0,3.59 +Moldova,27.05617,24.2369,3890.0,4111168.0,17.6,70.4,1.49 +Mongolia,25.71375,24.88385,7563.0,2629666.0,34.8,64.8,2.37 +Montenegro,25.70186,26.55412,14183.0,619740.0,8.1,76.0,1.72 +Morocco,26.223090000000003,25.63182,6091.0,31350544.0,35.8,73.3,2.44 +Mozambique,23.317339999999998,21.93536,864.0,22994867.0,114.4,54.0,5.54 +Myanmar,22.47733,21.44932,2891.0,51030006.0,87.2,59.4,2.05 +Namibia,25.14988,22.65008,8169.0,2115703.0,62.2,59.1,3.36 +Nepal,20.72814,20.76344,1866.0,26325183.0,50.7,68.4,2.9 +Netherlands,25.47269,26.01541,47388.0,16519862.0,4.8,80.3,1.77 +New Zealand,27.36642,27.768929999999997,32122.0,4285380.0,6.4,80.3,2.12 +Nicaragua,27.57259,25.77291,4060.0,5594524.0,28.1,77.0,2.72 +Niger,21.95958,21.21958,843.0,15085130.0,141.3,58.0,7.59 +Nigeria,23.674020000000002,23.03322,4684.0,151115683.0,140.9,59.2,6.02 +Norway,25.73772,26.934240000000003,65216.0,4771633.0,3.6,80.8,1.96 +Oman,26.66535,26.241090000000003,47799.0,2652281.0,11.9,76.2,2.89 +Pakistan,23.44986,22.299139999999998,4187.0,163096985.0,95.5,64.1,3.58 +Panama,27.67758,26.26959,14033.0,3498679.0,21.0,77.3,2.61 +Papua New Guinea,25.77189,25.015060000000002,1982.0,6540267.0,69.7,58.6,4.07 +Paraguay,25.90523,25.54223,6684.0,6047131.0,25.7,74.0,3.06 +Peru,25.98511,24.770410000000002,9249.0,28642048.0,23.2,78.2,2.58 +Philippines,23.4671,22.872629999999997,5332.0,90297115.0,33.4,69.8,3.26 +Poland,25.918870000000002,26.6738,19996.0,38525752.0,6.7,75.4,1.33 +Portugal,26.183020000000003,26.68445,27747.0,10577458.0,4.1,79.4,1.36 +Puerto Rico,30.2212,28.378040000000002,35855.0,3728126.0,8.78,77.0,1.69 +Qatar,28.912509999999997,28.13138,126076.0,1388962.0,9.5,77.9,2.2 +Romania,25.22425,25.41069,18032.0,20741669.0,16.1,73.2,1.34 +Russia,27.21272,26.01131,22506.0,143123163.0,13.5,67.9,1.49 +Rwanda,22.07156,22.55453,1173.0,9750314.0,78.3,64.1,5.06 +Samoa,33.659079999999996,30.42475,5731.0,183440.0,18.8,72.3,4.43 +Sao Tome and Principe,24.88216,23.51233,2673.0,163595.0,61.0,66.0,4.41 +Saudi Arabia,29.598779999999998,27.884320000000002,44189.0,26742842.0,18.1,78.3,2.97 +Senegal,24.30968,21.927429999999998,2162.0,12229703.0,75.8,63.5,5.11 +Serbia,25.669970000000003,26.51495,12522.0,9109535.0,8.0,74.3,1.41 +Seychelles,27.973740000000003,25.56236,20065.0,91634.0,14.2,72.9,2.28 +Sierra Leone,23.93364,22.53139,1289.0,5521838.0,179.1,53.6,5.13 +Singapore,22.86642,23.83996,65991.0,4849641.0,2.8,80.6,1.28 +Slovak Republic,26.323729999999998,26.92717,24670.0,5396710.0,8.8,74.9,1.31 +Slovenia,26.582140000000003,27.43983,30816.0,2030599.0,3.7,78.7,1.43 +Solomon Islands,28.8762,27.159879999999998,1835.0,503410.0,33.1,62.3,4.36 +Somalia,22.66607,21.969170000000002,615.0,9132589.0,168.5,52.6,7.06 +South Africa,29.4803,26.85538,12263.0,50348811.0,66.1,53.4,2.54 +Spain,26.30554,27.49975,34676.0,45817016.0,5.0,81.1,1.42 +Sri Lanka,23.11717,21.96671,6907.0,19949553.0,11.7,74.0,2.32 +Sudan,23.16132,22.40484,3246.0,34470138.0,84.7,65.5,4.79 +Suriname,27.749859999999998,25.49887,13470.0,506657.0,26.4,70.2,2.41 +Swaziland,28.448859999999996,23.16969,5887.0,1153750.0,112.2,45.1,3.7 +Sweden,25.1466,26.37629,43421.0,9226333.0,3.2,81.1,1.92 +Switzerland,24.07242,26.20195,55020.0,7646542.0,4.7,82.0,1.47 +Syria,28.87418,26.919690000000003,6246.0,20097057.0,16.5,76.1,3.17 +Tajikistan,23.84799,23.77966,2001.0,7254072.0,56.2,69.6,3.7 +Tanzania,23.0843,22.47792,2030.0,42844744.0,72.4,60.4,5.54 +Thailand,24.38577,23.008029999999998,12216.0,66453255.0,15.6,73.9,1.48 +Timor-Leste,21.50694,20.59082,1486.0,1030915.0,70.2,69.9,6.48 +Togo,22.73858,21.87875,1219.0,6052937.0,96.4,57.5,4.88 +Tonga,34.25969,30.99563,4748.0,102816.0,17.0,70.3,4.01 +Trinidad and Tobago,28.27587,26.396690000000003,30875.0,1315372.0,24.9,71.7,1.8 +Tunisia,27.93706,25.15699,9938.0,10408091.0,19.4,76.8,2.04 +Turkey,28.247490000000003,26.703709999999997,16454.0,70344357.0,22.2,77.8,2.15 +Turkmenistan,24.66154,25.24796,8877.0,4917541.0,63.9,67.2,2.48 +Uganda,22.48126,22.35833,1437.0,31014427.0,89.3,56.0,6.34 +Ukraine,26.23317,25.42379,8762.0,46028476.0,12.9,67.8,1.38 +United Arab Emirates,29.614009999999997,28.053590000000003,73029.0,6900142.0,9.1,75.6,1.95 +United Kingdom,26.944490000000002,27.392490000000002,37739.0,61689620.0,5.6,79.7,1.87 +United States,28.343590000000003,28.456979999999998,50384.0,304473143.0,7.7,78.3,2.07 +Uruguay,26.593040000000002,26.39123,15317.0,3350832.0,13.0,76.0,2.11 +Uzbekistan,25.43432,25.32054,3733.0,26952719.0,49.2,69.6,2.46 +Vanuatu,28.458759999999998,26.78926,2944.0,225335.0,28.2,63.4,3.61 +Venezuela,28.134079999999997,27.445,17911.0,28116716.0,17.1,74.2,2.53 +Vietnam,21.065,20.9163,4085.0,86589342.0,26.2,74.1,1.86 +West Bank and Gaza,29.026429999999998,26.5775,3564.0,3854667.0,24.7,74.1,4.38 +Zambia,23.05436,20.68321,3039.0,13114579.0,94.9,51.1,5.88 +Zimbabwe,24.645220000000002,22.0266,1286.0,13495462.0,98.3,47.3,3.85 diff --git a/labs07/sklearn.ipynb b/labs07/sklearn.ipynb new file mode 100644 index 0000000..c21dcbb --- /dev/null +++ b/labs07/sklearn.ipynb @@ -0,0 +1,485 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "source": [ + "# Analiza danych w Pythonie: sklearn\n", + "\n", + "### Tomasz Dwojak\n", + "\n", + "### 3 czerwca 2018" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "source": [ + " * Pierwsza część: pandas\n", + " * Druga część: sklearn" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "source": [ + "### Przypomnienie z UMZ\n", + " * przygotowanie i czyszczenie danych\n", + " * wybór i trening modelu\n", + " * tuning\n", + " * ewaluacja" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "outputs": [], + "source": [ + "import sklearn\n", + "import pandas as pd\n", + "import numpy as np" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "outputs": [], + "source": [ + "data = pd.read_csv(\"./gapminder.csv\", index_col=0)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "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", + "
female_BMImale_BMIgdppopulationunder5mortalitylife_expectancyfertility
Afghanistan21.0740220.620581311.026528741.0110.452.86.20
Albania25.6572626.446578644.02968026.017.976.81.76
Algeria26.3684124.5962012314.034811059.029.575.52.73
Angola23.4843122.250837103.019842251.0192.056.76.43
Antigua and Barbuda27.5054525.7660225736.085350.010.975.52.16
\n", + "
" + ], + "text/plain": [ + " female_BMI male_BMI gdp population \\\n", + "Afghanistan 21.07402 20.62058 1311.0 26528741.0 \n", + "Albania 25.65726 26.44657 8644.0 2968026.0 \n", + "Algeria 26.36841 24.59620 12314.0 34811059.0 \n", + "Angola 23.48431 22.25083 7103.0 19842251.0 \n", + "Antigua and Barbuda 27.50545 25.76602 25736.0 85350.0 \n", + "\n", + " under5mortality life_expectancy fertility \n", + "Afghanistan 110.4 52.8 6.20 \n", + "Albania 17.9 76.8 1.76 \n", + "Algeria 29.5 75.5 2.73 \n", + "Angola 192.0 56.7 6.43 \n", + "Antigua and Barbuda 10.9 75.5 2.16 " + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "outputs": [], + "source": [ + "y = data['life_expectancy']\n", + "X = data.drop('life_expectancy', axis=1)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "outputs": [], + "source": [ + "from sklearn.model_selection import train_test_split\n", + "train_X, test_X, train_y, test_y = \\\n", + " train_test_split(X, y, test_size=0.2, random_state=123, shuffle=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "LinearRegression(copy_X=True, fit_intercept=True, n_jobs=1, normalize=False)" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from sklearn.linear_model import LinearRegression\n", + "model = LinearRegression()\n", + "model.fit(X,y)" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "array([67.56279809, 76.25840076, 50.21126326, 59.21303855, 72.06348723])" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "predicted = model.predict(test_X)\n", + "predicted[:5]" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "RMSE: 3.5179543848147863\n" + ] + } + ], + "source": [ + "from sklearn.metrics import mean_squared_error\n", + "rmse = np.sqrt(mean_squared_error(predicted, test_y))\n", + "print(\"RMSE:\", rmse)" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "0.795295000468209" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + " r2 = model.score(test_X, test_y)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "source": [ + "#### API\n", + " * model\n", + " * `fix`\n", + " * `predict`" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "female_BMI: -1.18\n", + "male_BMI: 1.46\n", + "gdp: 5.11e-05\n", + "population: 7.21e-10\n", + "under5mortality: -0.159\n", + "fertility: 0.421\n" + ] + } + ], + "source": [ + "for p in zip(train_X.columns, model.coef_):\n", + " print(\"{}: {:.3}\".format(p[0], p[1]))" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/usr/lib/python3.6/site-packages/ipykernel_launcher.py:2: FutureWarning: reshape is deprecated and will raise in a subsequent release. Please use .values.reshape(...) instead\n", + " \n" + ] + }, + { + "data": { + "text/plain": [ + "LinearRegression(copy_X=True, fit_intercept=True, n_jobs=1, normalize=False)" + ] + }, + "execution_count": 36, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "model2 = LinearRegression()\n", + "model2.fit(train_X['male_BMI'].reshape(-1, 1), train_y)" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "0.5852413468462743" + ] + }, + "execution_count": 37, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "model2.intercept_" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/usr/lib/python3.6/site-packages/ipykernel_launcher.py:5: FutureWarning: reshape is deprecated and will raise in a subsequent release. Please use .values.reshape(...) instead\n", + " \"\"\"\n" + ] + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxv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fwPHAe0F9EekVuOg5417OOuaTkA3pklPMY8IaqPhB3068J/6ER+XdJsfuWr1TbJiKXEM4xX66q+7zqXz6SbZuqblTVoao6TFWHEQ6CZ6jqBx52NStp/h5/RfjEKCJyMlCFfxZ+AtJu23vABZGfLwI2F7tv+RCRIdFKMRGpBr5M+PzA88BXI3fzZQzpruQnFonIF4DfAxsJj3ogfNi+mvBZ6hrC1RJXqepOTzqZozTb9hBwGNAaaXtJVa8vfg9zl2rbVHVp3H22AKNV1TeBL81ntgL4BTAKOADcpqrPedLJHKXZtj3Ag4TTSp8AN6jqWk86mQMR+Szhk54VhAexC1T1bhH5NPBfhFNl64HJ0ZPaflXyAd0YY4wzJZ9yMcYY44wFdGOMCQgL6MYYExAW0I0xJiAsoBtjTEBYQDfGmICwgG6MMQFhAd0YYwLi/wM6kA1aREXRBwAAAABJRU5ErkJggg==\n", + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "from matplotlib import pyplot as plt\n", + "%matplotlib inline\n", + "\n", + "plt.scatter(train_X['male_BMI'], train_y,color='g')\n", + "plt.plot(train_X['male_BMI'], model2.predict(train_X['male_BMI'].reshape(-1, 1)),color='k')\n", + "\n", + "plt.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "celltoolbar": "Slideshow", + "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.5" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}