Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Created on Skills Network Labs
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"<center>\n",
" <img src=\"https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/Logos/organization_logo/organization_logo.png\" width=\"300\" alt=\"cognitiveclass.ai logo\" />\n",
"</center>\n",
"\n",
"# K-Nearest Neighbors\n",
"\n",
"Estimated time needed: **25** minutes\n",
"\n",
"## Objectives\n",
"\n",
"After completing this lab you will be able to:\n",
"\n",
"- Use K Nearest neighbors to classify data\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"In this Lab you will load a customer dataset, fit the data, and use K-Nearest Neighbors to predict a data point. But what is **K-Nearest Neighbors**?\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"**K-Nearest Neighbors** is an algorithm for supervised learning. Where the data is 'trained' with data points corresponding to their classification. Once a point is to be predicted, it takes into account the 'K' nearest points to it to determine it's classification.\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"### Here's an visualization of the K-Nearest Neighbors algorithm.\n",
"\n",
"<img src=\"https://ibm.box.com/shared/static/mgkn92xck0z05v7yjq8pqziukxvc2461.png\">\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"In this case, we have data points of Class A and B. We want to predict what the star (test data point) is. If we consider a k value of 3 (3 nearest data points) we will obtain a prediction of Class B. Yet if we consider a k value of 6, we will obtain a prediction of Class A.\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"In this sense, it is important to consider the value of k. But hopefully from this diagram, you should get a sense of what the K-Nearest Neighbors algorithm is. It considers the 'K' Nearest Neighbors (points) when it predicts the classification of the test point.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h1>Table of contents</h1>\n",
"\n",
"<div class=\"alert alert-block alert-info\" style=\"margin-top: 20px\">\n",
" <ol>\n",
" <li><a href=\"#about_dataset\">About the dataset</a></li>\n",
" <li><a href=\"#visualization_analysis\">Data Visualization and Analysis</a></li>\n",
" <li><a href=\"#classification\">Classification</a></li>\n",
" </ol>\n",
"</div>\n",
"<br>\n",
"<hr>\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"Lets load required libraries\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import pandas as pd\n",
"import numpy as np\n",
"from sklearn import preprocessing\n",
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"<div id=\"about_dataset\">\n",
" <h2>About the dataset</h2>\n",
"</div>\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"Imagine a telecommunications provider has segmented its customer base by service usage patterns, categorizing the customers into four groups. If demographic data can be used to predict group membership, the company can customize offers for individual prospective customers. It is a classification problem. That is, given the dataset, with predefined labels, we need to build a model to be used to predict class of a new or unknown case. \n",
"\n",
"The example focuses on using demographic data, such as region, age, and marital, to predict usage patterns. \n",
"\n",
"The target field, called **custcat**, has four possible values that correspond to the four customer groups, as follows:\n",
" 1- Basic Service\n",
" 2- E-Service\n",
" 3- Plus Service\n",
" 4- Total Service\n",
"\n",
"Our objective is to build a classifier, to predict the class of unknown cases. We will use a specific type of classification called K nearest neighbour.\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"Lets download the dataset. To download the data, we will use !wget to download it from IBM Object Storage.\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"--2020-11-22 00:50:39-- https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-ML0101EN-SkillsNetwork/labs/Module%203/data/teleCust1000t.csv\n",
"Resolving cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud (cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud)... 67.228.254.196\n",
"Connecting to cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud (cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud)|67.228.254.196|:443... connected.\n",
"HTTP request sent, awaiting response... 200 OK\n",
"Length: 36047 (35K) [text/csv]\n",
"Saving to: ‘teleCust1000t.csv’\n",
"\n",
"teleCust1000t.csv 100%[===================>] 35.20K --.-KB/s in 0.02s \n",
"\n",
"2020-11-22 00:50:39 (1.79 MB/s) - ‘teleCust1000t.csv’ saved [36047/36047]\n",
"\n"
]
}
],
"source": [
"!wget -O teleCust1000t.csv https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-ML0101EN-SkillsNetwork/labs/Module%203/data/teleCust1000t.csv"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Did you know?** When it comes to Machine Learning, you will likely be working with large datasets. As a business, where can you host your data? IBM is offering a unique opportunity for businesses, with 10 Tb of IBM Cloud Object Storage: [Sign up now for free](http://cocl.us/ML0101EN-IBM-Offer-CC)\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"### Load Data From CSV File\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>region</th>\n",
" <th>tenure</th>\n",
" <th>age</th>\n",
" <th>marital</th>\n",
" <th>address</th>\n",
" <th>income</th>\n",
" <th>ed</th>\n",
" <th>employ</th>\n",
" <th>retire</th>\n",
" <th>gender</th>\n",
" <th>reside</th>\n",
" <th>custcat</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>2</td>\n",
" <td>13</td>\n",
" <td>44</td>\n",
" <td>1</td>\n",
" <td>9</td>\n",
" <td>64.0</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>3</td>\n",
" <td>11</td>\n",
" <td>33</td>\n",
" <td>1</td>\n",
" <td>7</td>\n",
" <td>136.0</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>6</td>\n",
" <td>4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>3</td>\n",
" <td>68</td>\n",
" <td>52</td>\n",
" <td>1</td>\n",
" <td>24</td>\n",
" <td>116.0</td>\n",
" <td>1</td>\n",
" <td>29</td>\n",
" <td>0.0</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>2</td>\n",
" <td>33</td>\n",
" <td>33</td>\n",
" <td>0</td>\n",
" <td>12</td>\n",
" <td>33.0</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>2</td>\n",
" <td>23</td>\n",
" <td>30</td>\n",
" <td>1</td>\n",
" <td>9</td>\n",
" <td>30.0</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>4</td>\n",
" <td>3</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" region tenure age marital address income ed employ retire gender \\\n",
"0 2 13 44 1 9 64.0 4 5 0.0 0 \n",
"1 3 11 33 1 7 136.0 5 5 0.0 0 \n",
"2 3 68 52 1 24 116.0 1 29 0.0 1 \n",
"3 2 33 33 0 12 33.0 2 0 0.0 1 \n",
"4 2 23 30 1 9 30.0 1 2 0.0 0 \n",
"\n",
" reside custcat \n",
"0 2 1 \n",
"1 6 4 \n",
"2 2 3 \n",
"3 1 1 \n",
"4 4 3 "
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df = pd.read_csv('teleCust1000t.csv')\n",
"df.head()"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"<div id=\"visualization_analysis\">\n",
" <h2>Data Visualization and Analysis</h2> \n",
"</div>\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"#### Let’s see how many of each class is in our data set\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"data": {
"text/plain": [
"3 281\n",
"1 266\n",
"4 236\n",
"2 217\n",
"Name: custcat, dtype: int64"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df['custcat'].value_counts()"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"#### 281 Plus Service, 266 Basic-service, 236 Total Service, and 217 E-Service customers\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can easily explore your data using visualization techniques:\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[<AxesSubplot:title={'center':'income'}>]], dtype=object)"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYMAAAEICAYAAAC9E5gJAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAASIUlEQVR4nO3dfbBcdX3H8feHYMES5aFgJk2iN9SUEWTqwy3qoPam0IKihNpi41AbKk7qFDva2qlBOq39g05sp452kDqpMEaxXFKQISPDKJN6q51qkSBPAVOiBAjEpCIIUUsb/PaPPddu0nuTu7m7e3fh/Zq5s2d/+ztnP3tY7ueesw9JVSFJem47bK4DSJLmnmUgSbIMJEmWgSQJy0CShGUgScIy0LNMki1JxuY6hzRs4ucMJEkeGUiSLAM9uyTZnuTMJB9OsiHJZ5I81Zw+Gm2btyTJ55P8Z5LHklzejB+W5M+SPJhkd7P+0c1tI0kqye8leTjJ40nek+SXk9yV5InJ7bTdz7uS3NfM/WKSl/R3j0gzYxno2excYBw4BtgITP7Cnwd8AXgQGAEWNfMALmx+lgMnAvMn12vzGmAZ8NvAx4BLgTOBU4C3J/mV5n7OAz4EvA04AfgqcE03H6DULb5moGeVJNuBdwOvB15fVWc24ycDm6vq+UleR6scFlbV3v3W3wRcX1VXNNdPAu4Bng8sBh4AFlfVI83tjwF/UFXXNtevB75aVR9L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ivfoA303qXzreBS+c6z37ZXk/rkOwu4I7m583AZ4G7m/GNwMK2dS5tHstWevxuhQPkPpHWOyruBLZM7lfg54BNwP3N5XGDlLvJ8bPAY8DRbWMDt79pldVO4H9o/fV20aHsX2CU1i+ybwOX03yTQJ9zb6N1nn3yOf7JZu5vNs+fO4HbgbfORe5pMnf8nBiEfd2Mfxp4z35zu7qv/ToKSdJQniaSJHWZZSBJsgwkSZaBJAnLQJKEZSBJwjKQJAH/C+ch7ZFQjClTAAAAAElFTkSuQmCC\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"df.hist(column='income', bins=50)"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"### Feature set\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"Lets define feature sets, X:\n"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Index(['region', 'tenure', 'age', 'marital', 'address', 'income', 'ed',\n",
" 'employ', 'retire', 'gender', 'reside', 'custcat'],\n",
" dtype='object')"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.columns"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To use scikit-learn library, we have to convert the Pandas data frame to a Numpy array:\n"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"data": {
"text/plain": [
"array([[ 2., 13., 44., 1., 9., 64., 4., 5., 0., 0., 2.],\n",
" [ 3., 11., 33., 1., 7., 136., 5., 5., 0., 0., 6.],\n",
" [ 3., 68., 52., 1., 24., 116., 1., 29., 0., 1., 2.],\n",
" [ 2., 33., 33., 0., 12., 33., 2., 0., 0., 1., 1.],\n",
" [ 2., 23., 30., 1., 9., 30., 1., 2., 0., 0., 4.]])"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"X = df[['region', 'tenure','age', 'marital', 'address', 'income', 'ed', 'employ','retire', 'gender', 'reside']] .values #.astype(float)\n",
"X[0:5]\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"What are our labels?\n"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"data": {
"text/plain": [
"array([1, 4, 3, 1, 3])"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"y = df['custcat'].values\n",
"y[0:5]"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"## Normalize Data\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"Data Standardization give data zero mean and unit variance, it is good practice, especially for algorithms such as KNN which is based on distance of cases:\n"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"data": {
"text/plain": [
"array([[-0.02696767, -1.055125 , 0.18450456, 1.0100505 , -0.25303431,\n",
" -0.12650641, 1.0877526 , -0.5941226 , -0.22207644, -1.03459817,\n",
" -0.23065004],\n",
" [ 1.19883553, -1.14880563, -0.69181243, 1.0100505 , -0.4514148 ,\n",
" 0.54644972, 1.9062271 , -0.5941226 , -0.22207644, -1.03459817,\n",
" 2.55666158],\n",
" [ 1.19883553, 1.52109247, 0.82182601, 1.0100505 , 1.23481934,\n",
" 0.35951747, -1.36767088, 1.78752803, -0.22207644, 0.96655883,\n",
" -0.23065004],\n",
" [-0.02696767, -0.11831864, -0.69181243, -0.9900495 , 0.04453642,\n",
" -0.41625141, -0.54919639, -1.09029981, -0.22207644, 0.96655883,\n",
" -0.92747794],\n",
" [-0.02696767, -0.58672182, -0.93080797, 1.0100505 , -0.25303431,\n",
" -0.44429125, -1.36767088, -0.89182893, -0.22207644, -1.03459817,\n",
" 1.16300577]])"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"X = preprocessing.StandardScaler().fit(X).transform(X.astype(float))\n",
"X[0:5]"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"### Train Test Split\n",
"\n",
"Out of Sample Accuracy is the percentage of correct predictions that the model makes on data that that the model has NOT been trained on. Doing a train and test on the same dataset will most likely have low out-of-sample accuracy, due to the likelihood of being over-fit.\n",
"\n",
"It is important that our models have a high, out-of-sample accuracy, because the purpose of any model, of course, is to make correct predictions on unknown data. So how can we improve out-of-sample accuracy? One way is to use an evaluation approach called Train/Test Split.\n",
"Train/Test Split involves splitting the dataset into training and testing sets respectively, which are mutually exclusive. After which, you train with the training set and test with the testing set. \n",
"\n",
"This will provide a more accurate evaluation on out-of-sample accuracy because the testing dataset is not part of the dataset that have been used to train the data. It is more realistic for real world problems.\n"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Train set: (800, 11) (800,)\n",
"Test set: (200, 11) (200,)\n"
]
}
],
"source": [
"from sklearn.model_selection import train_test_split\n",
"X_train, X_test, y_train, y_test = train_test_split( X, y, test_size=0.2, random_state=4)\n",
"print ('Train set:', X_train.shape, y_train.shape)\n",
"print ('Test set:', X_test.shape, y_test.shape)"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"<div id=\"classification\">\n",
" <h2>Classification</h2>\n",
"</div>\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"<h3>K nearest neighbor (KNN)</h3>\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"#### Import library\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"Classifier implementing the k-nearest neighbors vote.\n"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [],
"source": [
"from sklearn.neighbors import KNeighborsClassifier"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"### Training\n",
"\n",
"Lets start the algorithm with k=4 for now:\n"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"data": {
"text/plain": [
"KNeighborsClassifier(algorithm='auto', leaf_size=30, metric='minkowski',\n",
" metric_params=None, n_jobs=None, n_neighbors=4, p=2,\n",
" weights='uniform')"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"k = 4\n",
"#Train Model and Predict \n",
"neigh = KNeighborsClassifier(n_neighbors = k).fit(X_train,y_train)\n",
"neigh"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"### Predicting\n",
"\n",
"we can use the model to predict the test set:\n"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"data": {
"text/plain": [
"array([1, 1, 3, 2, 4])"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"yhat = neigh.predict(X_test)\n",
"yhat[0:5]"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"### Accuracy evaluation\n",
"\n",
"In multilabel classification, **accuracy classification score** is a function that computes subset accuracy. This function is equal to the jaccard_similarity_score function. Essentially, it calculates how closely the actual labels and predicted labels are matched in the test set.\n"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Train set Accuracy: 0.5475\n",
"Test set Accuracy: 0.32\n"
]
}
],
"source": [
"from sklearn import metrics\n",
"print(\"Train set Accuracy: \", metrics.accuracy_score(y_train, neigh.predict(X_train)))\n",
"print(\"Test set Accuracy: \", metrics.accuracy_score(y_test, yhat))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Practice\n",
"\n",
"Can you build the model again, but this time with k=6?\n"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Train set Accuracy: 0.51625\n",
"Test set Accuracy: 0.31\n"
]
}
],
"source": [
"# write your code here\n",
"\n",
"\n",
"k = 6\n",
"neigh6 = KNeighborsClassifier(n_neighbors = k).fit(X_train,y_train)\n",
"yhat6 = neigh6.predict(X_test)\n",
"print(\"Train set Accuracy: \", metrics.accuracy_score(y_train, neigh6.predict(X_train)))\n",
"print(\"Test set Accuracy: \", metrics.accuracy_score(y_test, yhat6))\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Double-click **here** for the solution.\n",
"\n",
"<!-- Your answer is below:\n",
" \n",
" \n",
"k = 6\n",
"neigh6 = KNeighborsClassifier(n_neighbors = k).fit(X_train,y_train)\n",
"yhat6 = neigh6.predict(X_test)\n",
"print(\"Train set Accuracy: \", metrics.accuracy_score(y_train, neigh6.predict(X_train)))\n",
"print(\"Test set Accuracy: \", metrics.accuracy_score(y_test, yhat6))\n",
"\n",
"-->\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"#### What about other K?\n",
"\n",
"K in KNN, is the number of nearest neighbors to examine. It is supposed to be specified by the User. So, how can we choose right value for K?\n",
"The general solution is to reserve a part of your data for testing the accuracy of the model. Then chose k =1, use the training part for modeling, and calculate the accuracy of prediction using all samples in your test set. Repeat this process, increasing the k, and see which k is the best for your model.\n",
"\n",
"We can calculate the accuracy of KNN for different Ks.\n"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"data": {
"text/plain": [
"array([0.3 , 0.29 , 0.315, 0.32 , 0.315, 0.31 , 0.335, 0.325, 0.34 ])"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Ks = 10\n",
"mean_acc = np.zeros((Ks-1))\n",
"std_acc = np.zeros((Ks-1))\n",
"\n",
"for n in range(1,Ks):\n",
" \n",
" #Train Model and Predict \n",
" neigh = KNeighborsClassifier(n_neighbors = n).fit(X_train,y_train)\n",
" yhat=neigh.predict(X_test)\n",
" mean_acc[n-1] = metrics.accuracy_score(y_test, yhat)\n",
"\n",
" \n",
" std_acc[n-1]=np.std(yhat==y_test)/np.sqrt(yhat.shape[0])\n",
"\n",
"mean_acc"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"#### Plot model accuracy for Different number of Neighbors\n"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAagAAAEYCAYAAAAJeGK1AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAABCaUlEQVR4nO3deZxbdb3/8dfnnCSzdrpOS+nOUimlLcu0VRYBWQSt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TOD55KKfCeB3BPsmZfP61gKvAheljkmwiv2xwO+T5fglwdJSZJwzBBikqi8lD93b4aGfVdWdqtpKsF7ehORxH7gv+fNvgeOT4T9EVf+UPH5Ph/Lfl/HzX4C7ReRyoKumztEENcNMqwEh+N12VE+wkrcZwKwKbUrZTQTrlf0q41iC5Aev5EKbmf04mZ/e/YzbPu3/Fjqu/6UEb6RXq+qTmXeIyEkE20t0RXopf2/+k2Bl8FSTmQPsSG5l0p3enjPzd+DR/XtANmugpV+3ql4pIrMJap3LReRIVd2acW4U6Lht+RbgYuBZEdmqqpkDRsqT15gBzGpQpmSp6jbgfoLmt5R1wDHJn88i2NG3rz4vIk6yX+og4G3gSeAqCbY7QUQmS++b8v0VOFFERiSb6i4kaD7Liqq+RVDLmZO8vQtYKyKfT5ZBRGRGh2u2A7tF5KPJQxdk+XQOkOq7uwh4UVV3AttF5ITk8S92V34ROVhV/6qq1wGNdN687h3a11JT5X2HYCXs34rIkRl3TQZWZll2009ZDcqUup8CczNu3w48KiKvEgw06K5205O3Cd6IRxH05bSKyB0Eb7DLkjWzBuDsnh5EVTeLyD8CiwhqNo+r6qN9LMsPCVazTrkYuE1E/pkgfBcSbBaX6TLgdhFpJtiPa2cWz9MMTBWRpcnzz08e/zJBP1wlPa9S/l/JoeFC8HtvVyZVbRaR90TkEFVd3eG+xSLyFeAxETkZaAKiqro5i3KbfsxWMzemnxGR6tSgAxG5Fhitqt8scLEQkXOAY1T1n3s571vAriLd8sbsR1aDMqb/+XSy5hYC1gOXFLY4AVV9WIL9g3qzA/hNnotjSoDVoIwxxhQlGyRhjDGmKFlAGWOMKUoWUMYYY4qSBZQxxpiiZAFljDGmKFlAGWOMKUr/H49jqQ+l901nAAAAAElFTkSuQmCC\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plt.plot(range(1,Ks),mean_acc,'g')\n",
"plt.fill_between(range(1,Ks),mean_acc - 1 * std_acc,mean_acc + 1 * std_acc, alpha=0.10)\n",
"plt.fill_between(range(1,Ks),mean_acc - 3 * std_acc,mean_acc + 3 * std_acc, alpha=0.10,color=\"green\")\n",
"plt.legend(('Accuracy ', '+/- 1xstd','+/- 3xstd'))\n",
"plt.ylabel('Accuracy ')\n",
"plt.xlabel('Number of Neighbors (K)')\n",
"plt.tight_layout()\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The best accuracy was with 0.34 with k= 9\n"
]
}
],
"source": [
"print( \"The best accuracy was with\", mean_acc.max(), \"with k=\", mean_acc.argmax()+1) "
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"<h2>Want to learn more?</h2>\n",
"\n",
"IBM SPSS Modeler is a comprehensive analytics platform that has many machine learning algorithms. It has been designed to bring predictive intelligence to decisions made by individuals, by groups, by systems – by your enterprise as a whole. A free trial is available through this course, available here: <a href=\"https://www.ibm.com/analytics/spss-statistics-software\">SPSS Modeler</a>\n",
"\n",
"Also, you can use Watson Studio to run these notebooks faster with bigger datasets. Watson Studio is IBM's leading cloud solution for data scientists, built by data scientists. With Jupyter notebooks, RStudio, Apache Spark and popular libraries pre-packaged in the cloud, Watson Studio enables data scientists to collaborate on their projects without having to install anything. Join the fast-growing community of Watson Studio users today with a free account at <a href=\"https://www.ibm.com/cloud/watson-studio\">Watson Studio</a>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Thank you for completing this lab!\n",
"\n",
"## Author\n",
"\n",
"Saeed Aghabozorgi\n",
"\n",
"### Other Contributors\n",
"\n",
"<a href=\"https://www.linkedin.com/in/joseph-s-50398b136/\" target=\"_blank\">Joseph Santarcangelo</a>\n",
"\n",
"## Change Log\n",
"\n",
"| Date (YYYY-MM-DD) | Version | Changed By | Change Description |\n",
"| ----------------- | ------- | ---------- | ---------------------------------- |\n",
"| 2020-11-20 | 2.3 | Lakshmi | Removed unused imports |\n",
"| 2020-11-17 | 2.2 | Lakshmi | Changed plot function of KNN |\n",
"| 2020-11-03 | 2.1 | Lakshmi | Changed URL of csv |\n",
"| 2020-08-27 | 2.0 | Lavanya | Moved lab to course repo in GitLab |\n",
"| | | | |\n",
"| | | | |\n",
"\n",
"## <h3 align=\"center\"> © IBM Corporation 2020. All rights reserved. <h3/>\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python",
"language": "python",
"name": "conda-env-python-py"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.11"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment