{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Iris Classification" ] }, { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [], "source": [ "# dataset\n", "from sklearn import datasets\n", "# plot\n", "import seaborn as sns\n", "sns.set_style(\"darkgrid\")\n", "import matplotlib.pyplot as plt\n", "# data manipulation\n", "import pandas as pd\n", "import numpy as np\n", "# To display image in the jupyter notebook cell\n", "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question\n", "\n", "In the last section, we learn about perceptron. How to use it to classify data? To answer this question, let's look at an example first: there is a data set which consists of two species of Iris. Our questions are: \n", "\n", "- How to classify those two species? \n", "- When given a new Iris, how to predict which Iris category it belongs to?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Data Set\n", "\n", "The data set we will use is modified from the Iris dataset which can be found on the [UCI Machine Learning Repository](https://archive.ics.uci.edu/ml/datasets/Iris/). It consists of 50 samples from each of **two species** of Iris (Iris setosa, Iris virginica). **Two features** were measured from each sample: the length of the sepals and petals, in centimeters." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's get a close look at the dataset." ] }, { "cell_type": "code", "execution_count": 37, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | sepal length (cm) | \n", "petal length (cm) | \n", "target_class | \n", "
---|---|---|---|
0 | \n", "5.1 | \n", "1.4 | \n", "1 | \n", "
1 | \n", "4.9 | \n", "1.4 | \n", "1 | \n", "
2 | \n", "4.7 | \n", "1.3 | \n", "1 | \n", "
3 | \n", "4.6 | \n", "1.5 | \n", "1 | \n", "
4 | \n", "5.0 | \n", "1.4 | \n", "1 | \n", "