{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "from sklearn.linear_model import LogisticRegression\n", "from sklearn.model_selection import train_test_split\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | species | \n", "island | \n", "bill_length_mm | \n", "bill_depth_mm | \n", "flipper_length_mm | \n", "body_mass_g | \n", "year | \n", "
---|---|---|---|---|---|---|---|
0 | \n", "Adelie | \n", "Torgersen | \n", "39.1 | \n", "18.7 | \n", "181.0 | \n", "3750.0 | \n", "2007 | \n", "
1 | \n", "Adelie | \n", "Torgersen | \n", "39.5 | \n", "17.4 | \n", "186.0 | \n", "3800.0 | \n", "2007 | \n", "
2 | \n", "Adelie | \n", "Torgersen | \n", "40.3 | \n", "18.0 | \n", "195.0 | \n", "3250.0 | \n", "2007 | \n", "
3 | \n", "Adelie | \n", "Torgersen | \n", "36.7 | \n", "19.3 | \n", "193.0 | \n", "3450.0 | \n", "2007 | \n", "
4 | \n", "Adelie | \n", "Torgersen | \n", "39.3 | \n", "20.6 | \n", "190.0 | \n", "3650.0 | \n", "2007 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
269 | \n", "Gentoo | \n", "Biscoe | \n", "47.2 | \n", "13.7 | \n", "214.0 | \n", "4925.0 | \n", "2009 | \n", "
270 | \n", "Gentoo | \n", "Biscoe | \n", "46.8 | \n", "14.3 | \n", "215.0 | \n", "4850.0 | \n", "2009 | \n", "
271 | \n", "Gentoo | \n", "Biscoe | \n", "50.4 | \n", "15.7 | \n", "222.0 | \n", "5750.0 | \n", "2009 | \n", "
272 | \n", "Gentoo | \n", "Biscoe | \n", "45.2 | \n", "14.8 | \n", "212.0 | \n", "5200.0 | \n", "2009 | \n", "
273 | \n", "Gentoo | \n", "Biscoe | \n", "49.9 | \n", "16.1 | \n", "213.0 | \n", "5400.0 | \n", "2009 | \n", "
274 rows × 7 columns
\n", "\n", " | bill_length_mm | \n", "bill_depth_mm | \n", "flipper_length_mm | \n", "body_mass_g | \n", "year | \n", "
---|---|---|---|---|---|
0 | \n", "39.1 | \n", "18.7 | \n", "181.0 | \n", "3750.0 | \n", "2007 | \n", "
1 | \n", "39.5 | \n", "17.4 | \n", "186.0 | \n", "3800.0 | \n", "2007 | \n", "
2 | \n", "40.3 | \n", "18.0 | \n", "195.0 | \n", "3250.0 | \n", "2007 | \n", "
3 | \n", "36.7 | \n", "19.3 | \n", "193.0 | \n", "3450.0 | \n", "2007 | \n", "
4 | \n", "39.3 | \n", "20.6 | \n", "190.0 | \n", "3650.0 | \n", "2007 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
269 | \n", "47.2 | \n", "13.7 | \n", "214.0 | \n", "4925.0 | \n", "2009 | \n", "
270 | \n", "46.8 | \n", "14.3 | \n", "215.0 | \n", "4850.0 | \n", "2009 | \n", "
271 | \n", "50.4 | \n", "15.7 | \n", "222.0 | \n", "5750.0 | \n", "2009 | \n", "
272 | \n", "45.2 | \n", "14.8 | \n", "212.0 | \n", "5200.0 | \n", "2009 | \n", "
273 | \n", "49.9 | \n", "16.1 | \n", "213.0 | \n", "5400.0 | \n", "2009 | \n", "
274 rows × 5 columns
\n", "\n", " | species | \n", "island | \n", "bill_length_mm | \n", "bill_depth_mm | \n", "flipper_length_mm | \n", "body_mass_g | \n", "year | \n", "
---|---|---|---|---|---|---|---|
0 | \n", "Adelie | \n", "Torgersen | \n", "39.1 | \n", "18.7 | \n", "181.0 | \n", "3750.0 | \n", "2007 | \n", "
1 | \n", "Adelie | \n", "Torgersen | \n", "39.5 | \n", "17.4 | \n", "186.0 | \n", "3800.0 | \n", "2007 | \n", "
2 | \n", "Adelie | \n", "Torgersen | \n", "40.3 | \n", "18.0 | \n", "195.0 | \n", "3250.0 | \n", "2007 | \n", "
3 | \n", "Adelie | \n", "Torgersen | \n", "36.7 | \n", "19.3 | \n", "193.0 | \n", "3450.0 | \n", "2007 | \n", "
4 | \n", "Adelie | \n", "Torgersen | \n", "39.3 | \n", "20.6 | \n", "190.0 | \n", "3650.0 | \n", "2007 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
269 | \n", "Gentoo | \n", "Biscoe | \n", "47.2 | \n", "13.7 | \n", "214.0 | \n", "4925.0 | \n", "2009 | \n", "
270 | \n", "Gentoo | \n", "Biscoe | \n", "46.8 | \n", "14.3 | \n", "215.0 | \n", "4850.0 | \n", "2009 | \n", "
271 | \n", "Gentoo | \n", "Biscoe | \n", "50.4 | \n", "15.7 | \n", "222.0 | \n", "5750.0 | \n", "2009 | \n", "
272 | \n", "Gentoo | \n", "Biscoe | \n", "45.2 | \n", "14.8 | \n", "212.0 | \n", "5200.0 | \n", "2009 | \n", "
273 | \n", "Gentoo | \n", "Biscoe | \n", "49.9 | \n", "16.1 | \n", "213.0 | \n", "5400.0 | \n", "2009 | \n", "
274 rows × 7 columns
\n", "\n", " | bill_length_mm | \n", "bill_depth_mm | \n", "flipper_length_mm | \n", "body_mass_g | \n", "year | \n", "species_Adelie | \n", "species_Gentoo | \n", "island_Biscoe | \n", "island_Dream | \n", "island_Torgersen | \n", "
---|---|---|---|---|---|---|---|---|---|---|
27 | \n", "37.9 | \n", "18.6 | \n", "172.0 | \n", "3150.0 | \n", "2007 | \n", "1 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "
19 | \n", "37.8 | \n", "18.3 | \n", "174.0 | \n", "3400.0 | \n", "2007 | \n", "1 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "
121 | \n", "40.2 | \n", "17.0 | \n", "176.0 | \n", "3450.0 | \n", "2009 | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "
30 | \n", "37.2 | \n", "18.1 | \n", "178.0 | \n", "3900.0 | \n", "2007 | \n", "1 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "
29 | \n", "39.5 | \n", "16.7 | \n", "178.0 | \n", "3250.0 | \n", "2007 | \n", "1 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
216 | \n", "49.8 | \n", "16.8 | \n", "230.0 | \n", "5700.0 | \n", "2008 | \n", "0 | \n", "1 | \n", "1 | \n", "0 | \n", "0 | \n", "
184 | \n", "59.6 | \n", "17.0 | \n", "230.0 | \n", "6050.0 | \n", "2007 | \n", "0 | \n", "1 | \n", "1 | \n", "0 | \n", "0 | \n", "
226 | \n", "48.6 | \n", "16.0 | \n", "230.0 | \n", "5800.0 | \n", "2008 | \n", "0 | \n", "1 | \n", "1 | \n", "0 | \n", "0 | \n", "
264 | \n", "51.5 | \n", "16.3 | \n", "230.0 | \n", "5500.0 | \n", "2009 | \n", "0 | \n", "1 | \n", "1 | \n", "0 | \n", "0 | \n", "
214 | \n", "54.3 | \n", "15.7 | \n", "231.0 | \n", "5650.0 | \n", "2008 | \n", "0 | \n", "1 | \n", "1 | \n", "0 | \n", "0 | \n", "
274 rows × 10 columns
\n", "\n", " | flipper_length_mm | \n", "
---|---|
27 | \n", "172.0 | \n", "
19 | \n", "174.0 | \n", "
121 | \n", "176.0 | \n", "
30 | \n", "178.0 | \n", "
29 | \n", "178.0 | \n", "
... | \n", "... | \n", "
216 | \n", "230.0 | \n", "
184 | \n", "230.0 | \n", "
226 | \n", "230.0 | \n", "
264 | \n", "230.0 | \n", "
214 | \n", "231.0 | \n", "
274 rows × 1 columns
\n", "LogisticRegression()In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
LogisticRegression()