ibnummuhammad commited on
Commit
dc9fbf8
1 Parent(s): a663bf1

Format code

Browse files
Files changed (1) hide show
  1. penguins_binary_classification.ipynb +328 -10
penguins_binary_classification.ipynb CHANGED
@@ -6,7 +6,11 @@
6
  "metadata": {},
7
  "outputs": [],
8
  "source": [
9
- "import pandas as pd"
 
 
 
 
10
  ]
11
  },
12
  {
@@ -396,7 +400,7 @@
396
  {
397
  "data": {
398
  "text/plain": [
399
- "<seaborn.axisgrid.PairGrid at 0x1573343e0>"
400
  ]
401
  },
402
  "execution_count": 5,
@@ -428,12 +432,6 @@
428
  "metadata": {},
429
  "outputs": [],
430
  "source": [
431
- "import pandas as pd\n",
432
- "import numpy as np\n",
433
- "from sklearn.linear_model import LogisticRegression\n",
434
- "from sklearn.model_selection import train_test_split\n",
435
- "import matplotlib.pyplot as plt\n",
436
- "\n",
437
  "# One-hot encode the categorical data and sort by flipper_length_mm\n",
438
  "df_dummy = pd.get_dummies(df, dtype=int).sort_values(\n",
439
  " by=\"flipper_length_mm\", ascending=True\n",
@@ -876,6 +874,7 @@
876
  "outputs": [],
877
  "source": [
878
  "# Select the features and the target variable\n",
 
879
  "X = df_dummy[[\"flipper_length_mm\"]]\n",
880
  "Y = df_dummy[\"species_Gentoo\"]"
881
  ]
@@ -1482,6 +1481,325 @@
1482
  "cell_type": "code",
1483
  "execution_count": 15,
1484
  "metadata": {},
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1485
  "outputs": [],
1486
  "source": [
1487
  "X_gentoo = df_dummy[df_dummy[\"species_Gentoo\"] == 1][\"flipper_length_mm\"].values\n",
@@ -1490,7 +1808,7 @@
1490
  },
1491
  {
1492
  "cell_type": "code",
1493
- "execution_count": 16,
1494
  "metadata": {},
1495
  "outputs": [
1496
  {
@@ -1512,7 +1830,7 @@
1512
  },
1513
  {
1514
  "cell_type": "code",
1515
- "execution_count": 17,
1516
  "metadata": {},
1517
  "outputs": [
1518
  {
 
6
  "metadata": {},
7
  "outputs": [],
8
  "source": [
9
+ "import pandas as pd\n",
10
+ "import numpy as np\n",
11
+ "from sklearn.linear_model import LogisticRegression\n",
12
+ "from sklearn.model_selection import train_test_split\n",
13
+ "import matplotlib.pyplot as plt"
14
  ]
15
  },
16
  {
 
400
  {
401
  "data": {
402
  "text/plain": [
403
+ "<seaborn.axisgrid.PairGrid at 0x166cf13d0>"
404
  ]
405
  },
406
  "execution_count": 5,
 
432
  "metadata": {},
433
  "outputs": [],
434
  "source": [
 
 
 
 
 
 
435
  "# One-hot encode the categorical data and sort by flipper_length_mm\n",
436
  "df_dummy = pd.get_dummies(df, dtype=int).sort_values(\n",
437
  " by=\"flipper_length_mm\", ascending=True\n",
 
874
  "outputs": [],
875
  "source": [
876
  "# Select the features and the target variable\n",
877
+ "# X = df_dummy[[\"bill_length_mm\", \"bill_depth_mm\", \"flipper_length_mm\", \"body_mass_g\"]]\n",
878
  "X = df_dummy[[\"flipper_length_mm\"]]\n",
879
  "Y = df_dummy[\"species_Gentoo\"]"
880
  ]
 
1481
  "cell_type": "code",
1482
  "execution_count": 15,
1483
  "metadata": {},
1484
+ "outputs": [
1485
+ {
1486
+ "data": {
1487
+ "text/plain": [
1488
+ "array([[4.83683797e-10],\n",
1489
+ " [5.49019745e-10],\n",
1490
+ " [6.23181265e-10],\n",
1491
+ " [7.07360515e-10],\n",
1492
+ " [8.02910687e-10],\n",
1493
+ " [9.11367764e-10],\n",
1494
+ " [1.03447521e-09],\n",
1495
+ " [1.17421200e-09],\n",
1496
+ " [1.33282441e-09],\n",
1497
+ " [1.51286217e-09],\n",
1498
+ " [1.71721940e-09],\n",
1499
+ " [1.94918119e-09],\n",
1500
+ " [2.21247635e-09],\n",
1501
+ " [2.51133738e-09],\n",
1502
+ " [2.85056853e-09],\n",
1503
+ " [3.23562297e-09],\n",
1504
+ " [3.67269053e-09],\n",
1505
+ " [4.16879712e-09],\n",
1506
+ " [4.73191772e-09],\n",
1507
+ " [5.37110458e-09],\n",
1508
+ " [6.09663273e-09],\n",
1509
+ " [6.92016513e-09],\n",
1510
+ " [7.85494018e-09],\n",
1511
+ " [8.91598454e-09],\n",
1512
+ " [1.01203546e-08],\n",
1513
+ " [1.14874109e-08],\n",
1514
+ " [1.30391289e-08],\n",
1515
+ " [1.48004528e-08],\n",
1516
+ " [1.67996962e-08],\n",
1517
+ " [1.90689970e-08],\n",
1518
+ " [2.16448348e-08],\n",
1519
+ " [2.45686163e-08],\n",
1520
+ " [2.78873419e-08],\n",
1521
+ " [3.16543606e-08],\n",
1522
+ " [3.59302276e-08],\n",
1523
+ " [4.07836781e-08],\n",
1524
+ " [4.62927322e-08],\n",
1525
+ " [5.25459484e-08],\n",
1526
+ " [5.96438483e-08],\n",
1527
+ " [6.77005315e-08],\n",
1528
+ " [7.68455104e-08],\n",
1529
+ " [8.72257916e-08],\n",
1530
+ " [9.90082397e-08],\n",
1531
+ " [1.12382259e-07],\n",
1532
+ " [1.27562839e-07],\n",
1533
+ " [1.44794009e-07],\n",
1534
+ " [1.64352763e-07],\n",
1535
+ " [1.86553510e-07],\n",
1536
+ " [2.11753130e-07],\n",
1537
+ " [2.40356711e-07],\n",
1538
+ " [2.72824057e-07],\n",
1539
+ " [3.09677086e-07],\n",
1540
+ " [3.51508214e-07],\n",
1541
+ " [3.98989882e-07],\n",
1542
+ " [4.52885362e-07],\n",
1543
+ " [5.14061030e-07],\n",
1544
+ " [5.83500290e-07],\n",
1545
+ " [6.62319386e-07],\n",
1546
+ " [7.51785341e-07],\n",
1547
+ " [8.53336326e-07],\n",
1548
+ " [9.68604782e-07],\n",
1549
+ " [1.09944365e-06],\n",
1550
+ " [1.24795618e-06],\n",
1551
+ " [1.41652971e-06],\n",
1552
+ " [1.60787407e-06],\n",
1553
+ " [1.82506510e-06],\n",
1554
+ " [2.07159416e-06],\n",
1555
+ " [2.35142419e-06],\n",
1556
+ " [2.66905344e-06],\n",
1557
+ " [3.02958776e-06],\n",
1558
+ " [3.43882269e-06],\n",
1559
+ " [3.90333663e-06],\n",
1560
+ " [4.43059653e-06],\n",
1561
+ " [5.02907796e-06],\n",
1562
+ " [5.70840132e-06],\n",
1563
+ " [6.47948648e-06],\n",
1564
+ " [7.35472828e-06],\n",
1565
+ " [8.34819579e-06],\n",
1566
+ " [9.47585837e-06],\n",
1567
+ " [1.07558424e-05],\n",
1568
+ " [1.22087225e-05],\n",
1569
+ " [1.38578524e-05],\n",
1570
+ " [1.57297400e-05],\n",
1571
+ " [1.78544734e-05],\n",
1572
+ " [2.02662046e-05],\n",
1573
+ " [2.30036981e-05],\n",
1574
+ " [2.61109537e-05],\n",
1575
+ " [2.96379136e-05],\n",
1576
+ " [3.36412647e-05],\n",
1577
+ " [3.81853491e-05],\n",
1578
+ " [4.33431978e-05],\n",
1579
+ " [4.91977037e-05],\n",
1580
+ " [5.58429524e-05],\n",
1581
+ " [6.33857334e-05],\n",
1582
+ " [7.19472545e-05],\n",
1583
+ " [8.16650872e-05],\n",
1584
+ " [9.26953747e-05],\n",
1585
+ " [1.05215337e-04],\n",
1586
+ " [1.19426115e-04],\n",
1587
+ " [1.35555993e-04],\n",
1588
+ " [1.53864063e-04],\n",
1589
+ " [1.74644372e-04],\n",
1590
+ " [1.98230635e-04],\n",
1591
+ " [2.25001581e-04],\n",
1592
+ " [2.55387005e-04],\n",
1593
+ " [2.89874650e-04],\n",
1594
+ " [3.29017999e-04],\n",
1595
+ " [3.73445113e-04],\n",
1596
+ " [4.23868652e-04],\n",
1597
+ " [4.81097232e-04],\n",
1598
+ " [5.46048301e-04],\n",
1599
+ " [6.19762725e-04],\n",
1600
+ " [7.03421310e-04],\n",
1601
+ " [7.98363516e-04],\n",
1602
+ " [9.06108645e-04],\n",
1603
+ " [1.02837982e-03],\n",
1604
+ " [1.16713111e-03],\n",
1605
+ " [1.32457821e-03],\n",
1606
+ " [1.50323311e-03],\n",
1607
+ " [1.70594325e-03],\n",
1608
+ " [1.93593574e-03],\n",
1609
+ " [2.19686721e-03],\n",
1610
+ " [2.49288000e-03],\n",
1611
+ " [2.82866541e-03],\n",
1612
+ " [3.20953483e-03],\n",
1613
+ " [3.64149966e-03],\n",
1614
+ " [4.13136080e-03],\n",
1615
+ " [4.68680897e-03],\n",
1616
+ " [5.31653669e-03],\n",
1617
+ " [6.03036307e-03],\n",
1618
+ " [6.83937256e-03],\n",
1619
+ " [7.75606864e-03],\n",
1620
+ " [8.79454350e-03],\n",
1621
+ " [9.97066455e-03],\n",
1622
+ " [1.13022784e-02],\n",
1623
+ " [1.28094325e-02],\n",
1624
+ " [1.45146145e-02],\n",
1625
+ " [1.64430081e-02],\n",
1626
+ " [1.86227643e-02],\n",
1627
+ " [2.10852837e-02],\n",
1628
+ " [2.38655076e-02],\n",
1629
+ " [2.70022090e-02],\n",
1630
+ " [3.05382771e-02],\n",
1631
+ " [3.45209812e-02],\n",
1632
+ " [3.90022003e-02],\n",
1633
+ " [4.40385993e-02],\n",
1634
+ " [4.96917253e-02],\n",
1635
+ " [5.60279978e-02],\n",
1636
+ " [6.31185556e-02],\n",
1637
+ " [7.10389212e-02],\n",
1638
+ " [7.98684382e-02],\n",
1639
+ " [8.96894320e-02],\n",
1640
+ " [1.00586046e-01],\n",
1641
+ " [1.12642703e-01],\n",
1642
+ " [1.25942160e-01],\n",
1643
+ " [1.40563116e-01],\n",
1644
+ " [1.56577391e-01],\n",
1645
+ " [1.74046679e-01],\n",
1646
+ " [1.93018968e-01],\n",
1647
+ " [2.13524721e-01],\n",
1648
+ " [2.35573007e-01],\n",
1649
+ " [2.59147794e-01],\n",
1650
+ " [2.84204676e-01],\n",
1651
+ " [3.10668348e-01],\n",
1652
+ " [3.38431114e-01],\n",
1653
+ " [3.67352732e-01],\n",
1654
+ " [3.97261785e-01],\n",
1655
+ " [4.27958707e-01],\n",
1656
+ " [4.59220422e-01],\n",
1657
+ " [4.90806432e-01],\n",
1658
+ " [5.22466015e-01],\n",
1659
+ " [5.53946110e-01],\n",
1660
+ " [5.84999352e-01],\n",
1661
+ " [6.15391729e-01],\n",
1662
+ " [6.44909362e-01],\n",
1663
+ " [6.73364020e-01],\n",
1664
+ " [7.00597089e-01],\n",
1665
+ " [7.26481903e-01],\n",
1666
+ " [7.50924455e-01],\n",
1667
+ " [7.73862649e-01],\n",
1668
+ " [7.95264337e-01],\n",
1669
+ " [8.15124447e-01],\n",
1670
+ " [8.33461489e-01],\n",
1671
+ " [8.50313747e-01],\n",
1672
+ " [8.65735415e-01],\n",
1673
+ " [8.79792851e-01],\n",
1674
+ " [8.92561134e-01],\n",
1675
+ " [9.04120984e-01],\n",
1676
+ " [9.14556122e-01],\n",
1677
+ " [9.23951065e-01],\n",
1678
+ " [9.32389359e-01],\n",
1679
+ " [9.39952202e-01],\n",
1680
+ " [9.46717418e-01],\n",
1681
+ " [9.52758747e-01],\n",
1682
+ " [9.58145375e-01],\n",
1683
+ " [9.62941690e-01],\n",
1684
+ " [9.67207184e-01],\n",
1685
+ " [9.70996498e-01],\n",
1686
+ " [9.74359553e-01],\n",
1687
+ " [9.77341750e-01],\n",
1688
+ " [9.79984217e-01],\n",
1689
+ " [9.82324087e-01],\n",
1690
+ " [9.84394778e-01],\n",
1691
+ " [9.86226294e-01],\n",
1692
+ " [9.87845508e-01],\n",
1693
+ " [9.89276439e-01],\n",
1694
+ " [9.90540522e-01],\n",
1695
+ " [9.91656852e-01],\n",
1696
+ " [9.92642421e-01],\n",
1697
+ " [9.93512327e-01],\n",
1698
+ " [9.94279975e-01],\n",
1699
+ " [9.94957252e-01],\n",
1700
+ " [9.95554695e-01],\n",
1701
+ " [9.96081635e-01],\n",
1702
+ " [9.96546328e-01],\n",
1703
+ " [9.96956081e-01],\n",
1704
+ " [9.97317350e-01],\n",
1705
+ " [9.97635843e-01],\n",
1706
+ " [9.97916603e-01],\n",
1707
+ " [9.98164082e-01],\n",
1708
+ " [9.98382211e-01],\n",
1709
+ " [9.98574461e-01],\n",
1710
+ " [9.98743894e-01],\n",
1711
+ " [9.98893211e-01],\n",
1712
+ " [9.99024796e-01],\n",
1713
+ " [9.99140750e-01],\n",
1714
+ " [9.99242927e-01],\n",
1715
+ " [9.99332963e-01],\n",
1716
+ " [9.99412296e-01],\n",
1717
+ " [9.99482200e-01],\n",
1718
+ " [9.99543792e-01],\n",
1719
+ " [9.99598061e-01],\n",
1720
+ " [9.99645877e-01],\n",
1721
+ " [9.99688006e-01],\n",
1722
+ " [9.99725125e-01],\n",
1723
+ " [9.99757828e-01],\n",
1724
+ " [9.99786642e-01],\n",
1725
+ " [9.99812028e-01],\n",
1726
+ " [9.99834393e-01],\n",
1727
+ " [9.99854099e-01],\n",
1728
+ " [9.99871459e-01],\n",
1729
+ " [9.99886755e-01],\n",
1730
+ " [9.99900230e-01],\n",
1731
+ " [9.99912102e-01],\n",
1732
+ " [9.99922561e-01],\n",
1733
+ " [9.99931776e-01],\n",
1734
+ " [9.99939895e-01],\n",
1735
+ " [9.99947047e-01],\n",
1736
+ " [9.99953349e-01],\n",
1737
+ " [9.99958900e-01],\n",
1738
+ " [9.99963791e-01],\n",
1739
+ " [9.99968100e-01],\n",
1740
+ " [9.99971896e-01],\n",
1741
+ " [9.99975240e-01],\n",
1742
+ " [9.99978187e-01],\n",
1743
+ " [9.99980783e-01],\n",
1744
+ " [9.99983070e-01],\n",
1745
+ " [9.99985084e-01],\n",
1746
+ " [9.99986859e-01],\n",
1747
+ " [9.99988423e-01],\n",
1748
+ " [9.99989801e-01],\n",
1749
+ " [9.99991015e-01],\n",
1750
+ " [9.99992084e-01],\n",
1751
+ " [9.99993026e-01],\n",
1752
+ " [9.99993856e-01],\n",
1753
+ " [9.99994587e-01],\n",
1754
+ " [9.99995231e-01],\n",
1755
+ " [9.99995799e-01],\n",
1756
+ " [9.99996299e-01],\n",
1757
+ " [9.99996739e-01],\n",
1758
+ " [9.99997127e-01],\n",
1759
+ " [9.99997469e-01],\n",
1760
+ " [9.99997770e-01],\n",
1761
+ " [9.99998036e-01],\n",
1762
+ " [9.99998269e-01],\n",
1763
+ " [9.99998475e-01],\n",
1764
+ " [9.99998657e-01],\n",
1765
+ " [9.99998817e-01],\n",
1766
+ " [9.99998957e-01],\n",
1767
+ " [9.99999082e-01],\n",
1768
+ " [9.99999191e-01],\n",
1769
+ " [9.99999287e-01],\n",
1770
+ " [9.99999372e-01],\n",
1771
+ " [9.99999447e-01],\n",
1772
+ " [9.99999513e-01],\n",
1773
+ " [9.99999571e-01],\n",
1774
+ " [9.99999622e-01],\n",
1775
+ " [9.99999667e-01],\n",
1776
+ " [9.99999706e-01],\n",
1777
+ " [9.99999741e-01],\n",
1778
+ " [9.99999772e-01],\n",
1779
+ " [9.99999799e-01],\n",
1780
+ " [9.99999823e-01],\n",
1781
+ " [9.99999844e-01],\n",
1782
+ " [9.99999863e-01],\n",
1783
+ " [9.99999879e-01],\n",
1784
+ " [9.99999893e-01],\n",
1785
+ " [9.99999906e-01],\n",
1786
+ " [9.99999917e-01],\n",
1787
+ " [9.99999927e-01]])"
1788
+ ]
1789
+ },
1790
+ "execution_count": 15,
1791
+ "metadata": {},
1792
+ "output_type": "execute_result"
1793
+ }
1794
+ ],
1795
+ "source": [
1796
+ "Y_predicted"
1797
+ ]
1798
+ },
1799
+ {
1800
+ "cell_type": "code",
1801
+ "execution_count": 16,
1802
+ "metadata": {},
1803
  "outputs": [],
1804
  "source": [
1805
  "X_gentoo = df_dummy[df_dummy[\"species_Gentoo\"] == 1][\"flipper_length_mm\"].values\n",
 
1808
  },
1809
  {
1810
  "cell_type": "code",
1811
+ "execution_count": 17,
1812
  "metadata": {},
1813
  "outputs": [
1814
  {
 
1830
  },
1831
  {
1832
  "cell_type": "code",
1833
+ "execution_count": 18,
1834
  "metadata": {},
1835
  "outputs": [
1836
  {