From a9403a4a04309f1b310206204ae6580356dd3e90 Mon Sep 17 00:00:00 2001 From: Benedict Collings <61722366+bmcollings@users.noreply.github.com> Date: Tue, 5 Sep 2023 16:29:24 +1200 Subject: [PATCH] add ensemble method notebook --- code/Ensemble-methods-random-forests.ipynb | 905 +++++++++++++++++++++ 1 file changed, 905 insertions(+) create mode 100644 code/Ensemble-methods-random-forests.ipynb diff --git a/code/Ensemble-methods-random-forests.ipynb b/code/Ensemble-methods-random-forests.ipynb new file mode 100644 index 0000000..0e700cc --- /dev/null +++ b/code/Ensemble-methods-random-forests.ipynb @@ -0,0 +1,905 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 79, + "id": "165d67d2-a6e4-4143-a7b2-e40386af4442", + "metadata": {}, + "outputs": [], + "source": [ + "# import libraries\n", + "import seaborn as sns\n", + "import pandas as pd\n", + "import numpy as np\n" + ] + }, + { + "cell_type": "markdown", + "id": "58a0e2bc-94b0-4814-a72f-333f4417334d", + "metadata": {}, + "source": [ + "## Load Penguins dataset" + ] + }, + { + "cell_type": "code", + "execution_count": 80, + "id": "e6186217-2de4-48eb-b448-e2b4a35a4025", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + " | bill_length_mm | \n", + "bill_depth_mm | \n", + "flipper_length_mm | \n", + "body_mass_g | \n", + "
---|---|---|---|---|
0 | \n", + "39.1 | \n", + "18.7 | \n", + "181.0 | \n", + "3750.0 | \n", + "
1 | \n", + "39.5 | \n", + "17.4 | \n", + "186.0 | \n", + "3800.0 | \n", + "
2 | \n", + "40.3 | \n", + "18.0 | \n", + "195.0 | \n", + "3250.0 | \n", + "
4 | \n", + "36.7 | \n", + "19.3 | \n", + "193.0 | \n", + "3450.0 | \n", + "
5 | \n", + "39.3 | \n", + "20.6 | \n", + "190.0 | \n", + "3650.0 | \n", + "
... | \n", + "... | \n", + "... | \n", + "... | \n", + "... | \n", + "
338 | \n", + "47.2 | \n", + "13.7 | \n", + "214.0 | \n", + "4925.0 | \n", + "
340 | \n", + "46.8 | \n", + "14.3 | \n", + "215.0 | \n", + "4850.0 | \n", + "
341 | \n", + "50.4 | \n", + "15.7 | \n", + "222.0 | \n", + "5750.0 | \n", + "
342 | \n", + "45.2 | \n", + "14.8 | \n", + "212.0 | \n", + "5200.0 | \n", + "
343 | \n", + "49.9 | \n", + "16.1 | \n", + "213.0 | \n", + "5400.0 | \n", + "
342 rows × 4 columns
\n", + "RandomForestClassifier(max_depth=7)In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
RandomForestClassifier(max_depth=7)