{ "cells": [ { "cell_type": "code", "execution_count": 1, "source": [ "# let's set things up\r\n", "import matplotlib as mpl\r\n", "import matplotlib.pyplot as plt\r\n", "import numpy as np\r\n", "import pandas as pd\r\n", "import seaborn as sns\r\n", "from sklearn.datasets import load_iris\r\n", "\r\n", "%matplotlib inline\r\n", "plt.style.use('default')\r\n", "sns.set()" ], "outputs": [], "metadata": {} }, { "cell_type": "code", "execution_count": 2, "source": [ "# get the iris dataset\r\n", "iris = load_iris()\r\n", "df_iris = pd.DataFrame(iris.data, columns=iris.feature_names)\r\n", "df_iris['target'] = iris.target\r\n", "df_iris['species'] = df_iris['target'].map({0:iris.target_names[0],1:iris.target_names[1],2:iris.target_names[2]})\r\n", "df_iris.drop('target', axis=1, inplace=True)\r\n", "\r\n", "# print(type(iris))\r\n", "df_iris.head()" ], "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ " sepal length (cm) sepal width (cm) petal length (cm) petal width (cm) \\\n", "0 5.1 3.5 1.4 0.2 \n", "1 4.9 3.0 1.4 0.2 \n", "2 4.7 3.2 1.3 0.2 \n", "3 4.6 3.1 1.5 0.2 \n", "4 5.0 3.6 1.4 0.2 \n", "\n", " species \n", "0 setosa \n", "1 setosa \n", "2 setosa \n", "3 setosa \n", "4 setosa " ], "text/html": [ "
\n", " | sepal length (cm) | \n", "sepal width (cm) | \n", "petal length (cm) | \n", "petal width (cm) | \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", "