{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [] }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" } }, "cells": [ { "cell_type": "markdown", "metadata": { "id": "_6IjlSbqz21Z" }, "source": [ "# Ансамбли моделей" ] }, { "cell_type": "code", "metadata": { "id": "FOqDrFJdJYEX" }, "source": [ "import numpy as np\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "import seaborn as sns\n", "sns.set(context=\"notebook\", style=\"white\", rc={\"axes.axisbelow\": False, 'figure.figsize':(11.7,8.27)})\n", "\n", "from sklearn import tree\n", "from sklearn.neighbors import KNeighborsClassifier\n", "from sklearn.linear_model import LogisticRegression" ], "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "metadata": { "id": "yMrxYJt7rDpj" }, "source": [ "## Dataset" ] }, { "cell_type": "code", "metadata": { "id": "DW-U4oVVuMsV", "colab": { "base_uri": "https://localhost:8080/", "height": 206 }, "outputId": "8ef74b63-88f6-48f9-9d71-eed8a0e8027c" }, "source": [ "df = sns.load_dataset('iris')\n", "df.head()" ], "execution_count": null, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ " sepal_length sepal_width petal_length petal_width species\n", "0 5.1 3.5 1.4 0.2 setosa\n", "1 4.9 3.0 1.4 0.2 setosa\n", "2 4.7 3.2 1.3 0.2 setosa\n", "3 4.6 3.1 1.5 0.2 setosa\n", "4 5.0 3.6 1.4 0.2 setosa" ], "text/html": [ "\n", "
| \n", " | sepal_length | \n", "sepal_width | \n", "petal_length | \n", "petal_width | \n", "species | \n", "
|---|---|---|---|---|---|
| 0 | \n", "5.1 | \n", "3.5 | \n", "1.4 | \n", "0.2 | \n", "setosa | \n", "
| 1 | \n", "4.9 | \n", "3.0 | \n", "1.4 | \n", "0.2 | \n", "setosa | \n", "
| 2 | \n", "4.7 | \n", "3.2 | \n", "1.3 | \n", "0.2 | \n", "setosa | \n", "
| 3 | \n", "4.6 | \n", "3.1 | \n", "1.5 | \n", "0.2 | \n", "setosa | \n", "
| 4 | \n", "5.0 | \n", "3.6 | \n", "1.4 | \n", "0.2 | \n", "setosa | \n", "
| \n", " | sepal_length | \n", "sepal_width | \n", "species | \n", "
|---|---|---|---|
| 0 | \n", "5.1 | \n", "3.5 | \n", "0 | \n", "
| 1 | \n", "4.9 | \n", "3.0 | \n", "0 | \n", "
| 2 | \n", "4.7 | \n", "3.2 | \n", "0 | \n", "
| 3 | \n", "4.6 | \n", "3.1 | \n", "0 | \n", "
| 4 | \n", "5.0 | \n", "3.6 | \n", "0 | \n", "
| ... | \n", "... | \n", "... | \n", "... | \n", "
| 145 | \n", "6.7 | \n", "3.0 | \n", "2 | \n", "
| 146 | \n", "6.3 | \n", "2.5 | \n", "2 | \n", "
| 147 | \n", "6.5 | \n", "3.0 | \n", "2 | \n", "
| 148 | \n", "6.2 | \n", "3.4 | \n", "2 | \n", "
| 149 | \n", "5.9 | \n", "3.0 | \n", "2 | \n", "
150 rows × 3 columns
\n", "DecisionTreeClassifier()In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
DecisionTreeClassifier()
DecisionTreeClassifier(max_leaf_nodes=2)In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
DecisionTreeClassifier(max_leaf_nodes=2)
DecisionTreeClassifier(max_depth=5)In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
DecisionTreeClassifier(max_depth=5)
RandomForestClassifier(max_depth=5, n_estimators=400)In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
RandomForestClassifier(max_depth=5, n_estimators=400)