Skip to content

Instantly share code, notes, and snippets.

@asterios-pantousas
Created January 24, 2021 20:51
Show Gist options
  • Save asterios-pantousas/702806784b1a5836c500695370643c82 to your computer and use it in GitHub Desktop.
Save asterios-pantousas/702806784b1a5836c500695370643c82 to your computer and use it in GitHub Desktop.
Created on Skills Network Labs
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"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",
"# SVM (Support Vector Machines)\n",
"\n",
"Estimated time needed: **15** minutes\n",
"\n",
"## Objectives\n",
"\n",
"After completing this lab you will be able to:\n",
"\n",
"- Use scikit-learn to Support Vector Machine to classify\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In this notebook, you will use SVM (Support Vector Machines) to build and train a model using human cell records, and classify cells to whether the samples are benign or malignant.\n",
"\n",
"SVM works by mapping data to a high-dimensional feature space so that data points can be categorized, even when the data are not otherwise linearly separable. A separator between the categories is found, then the data is transformed in such a way that the separator could be drawn as a hyperplane. Following this, characteristics of new data can be used to predict the group to which a new record should belong.\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=\"#load_dataset\">Load the Cancer data</a></li>\n",
" <li><a href=\"#modeling\">Modeling</a></li>\n",
" <li><a href=\"#evaluation\">Evaluation</a></li>\n",
" <li><a href=\"#practice\">Practice</a></li>\n",
" </ol>\n",
"</div>\n",
"<br>\n",
"<hr>\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Collecting scikit-learn==0.23.1\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/d9/3a/eb8d7bbe28f4787d140bb9df685b7d5bf6115c0e2a969def4027144e98b6/scikit_learn-0.23.1-cp36-cp36m-manylinux1_x86_64.whl (6.8MB)\n",
"\u001b[K |████████████████████████████████| 6.9MB 5.8MB/s eta 0:00:01 |███▉ | 829kB 6.7MB/s eta 0:00:01\n",
"\u001b[?25hCollecting threadpoolctl>=2.0.0 (from scikit-learn==0.23.1)\n",
" Downloading https://files.pythonhosted.org/packages/f7/12/ec3f2e203afa394a149911729357aa48affc59c20e2c1c8297a60f33f133/threadpoolctl-2.1.0-py3-none-any.whl\n",
"Requirement already satisfied: scipy>=0.19.1 in /home/jupyterlab/conda/envs/python/lib/python3.6/site-packages (from scikit-learn==0.23.1) (1.5.4)\n",
"Requirement already satisfied: numpy>=1.13.3 in /home/jupyterlab/conda/envs/python/lib/python3.6/site-packages (from scikit-learn==0.23.1) (1.19.4)\n",
"Collecting joblib>=0.11 (from scikit-learn==0.23.1)\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/34/5b/bd0f0fb5564183884d8e35b81d06d7ec06a20d1a0c8b4c407f1554691dce/joblib-1.0.0-py3-none-any.whl (302kB)\n",
"\u001b[K |████████████████████████████████| 307kB 7.8MB/s eta 0:00:01\n",
"\u001b[?25hInstalling collected packages: threadpoolctl, joblib, scikit-learn\n",
" Found existing installation: scikit-learn 0.20.1\n",
" Uninstalling scikit-learn-0.20.1:\n",
" Successfully uninstalled scikit-learn-0.20.1\n",
"Successfully installed joblib-1.0.0 scikit-learn-0.23.1 threadpoolctl-2.1.0\n"
]
}
],
"source": [
"!pip install scikit-learn==0.23.1"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import pylab as pl\n",
"import numpy as np\n",
"import scipy.optimize as opt\n",
"from sklearn import preprocessing\n",
"from sklearn.model_selection import train_test_split\n",
"%matplotlib inline \n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"<h2 id=\"load_dataset\">Load the Cancer data</h2>\n",
"The example is based on a dataset that is publicly available from the UCI Machine Learning Repository (Asuncion and Newman, 2007)[http://mlearn.ics.uci.edu/MLRepository.html]. The dataset consists of several hundred human cell sample records, each of which contains the values of a set of cell characteristics. The fields in each record are:\n",
"\n",
"| Field name | Description |\n",
"| ----------- | --------------------------- |\n",
"| ID | Clump thickness |\n",
"| Clump | Clump thickness |\n",
"| UnifSize | Uniformity of cell size |\n",
"| UnifShape | Uniformity of cell shape |\n",
"| MargAdh | Marginal adhesion |\n",
"| SingEpiSize | Single epithelial cell size |\n",
"| BareNuc | Bare nuclei |\n",
"| BlandChrom | Bland chromatin |\n",
"| NormNucl | Normal nucleoli |\n",
"| Mit | Mitoses |\n",
"| Class | Benign or malignant |\n",
"\n",
"<br>\n",
"<br>\n",
"\n",
"For the purposes of this example, we're using a dataset that has a relatively small number of predictors in each record. To download the data, we will use `!wget` to download it from IBM Object Storage. \n",
"\n",
"**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": "code",
"execution_count": 3,
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"--2021-01-24 20:42:30-- https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-ML0101EN-SkillsNetwork/labs/Module%203/data/cell_samples.csv\n",
"Resolving cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud (cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud)... 169.63.118.104\n",
"Connecting to cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud (cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud)|169.63.118.104|:443... connected.\n",
"HTTP request sent, awaiting response... 200 OK\n",
"Length: 19975 (20K) [text/csv]\n",
"Saving to: ‘cell_samples.csv’\n",
"\n",
"cell_samples.csv 100%[===================>] 19.51K --.-KB/s in 0.002s \n",
"\n",
"2021-01-24 20:42:30 (9.57 MB/s) - ‘cell_samples.csv’ saved [19975/19975]\n",
"\n"
]
}
],
"source": [
"#Click here and press Shift+Enter\n",
"!wget -O cell_samples.csv https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-ML0101EN-SkillsNetwork/labs/Module%203/data/cell_samples.csv"
]
},
{
"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": 4,
"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>ID</th>\n",
" <th>Clump</th>\n",
" <th>UnifSize</th>\n",
" <th>UnifShape</th>\n",
" <th>MargAdh</th>\n",
" <th>SingEpiSize</th>\n",
" <th>BareNuc</th>\n",
" <th>BlandChrom</th>\n",
" <th>NormNucl</th>\n",
" <th>Mit</th>\n",
" <th>Class</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1000025</td>\n",
" <td>5</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>1</td>\n",
" <td>3</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1002945</td>\n",
" <td>5</td>\n",
" <td>4</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>7</td>\n",
" <td>10</td>\n",
" <td>3</td>\n",
" <td>2</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>1015425</td>\n",
" <td>3</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" <td>3</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>1016277</td>\n",
" <td>6</td>\n",
" <td>8</td>\n",
" <td>8</td>\n",
" <td>1</td>\n",
" <td>3</td>\n",
" <td>4</td>\n",
" <td>3</td>\n",
" <td>7</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>1017023</td>\n",
" <td>4</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>3</td>\n",
" <td>2</td>\n",
" <td>1</td>\n",
" <td>3</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" ID Clump UnifSize UnifShape MargAdh SingEpiSize BareNuc \\\n",
"0 1000025 5 1 1 1 2 1 \n",
"1 1002945 5 4 4 5 7 10 \n",
"2 1015425 3 1 1 1 2 2 \n",
"3 1016277 6 8 8 1 3 4 \n",
"4 1017023 4 1 1 3 2 1 \n",
"\n",
" BlandChrom NormNucl Mit Class \n",
"0 3 1 1 2 \n",
"1 3 2 1 2 \n",
"2 3 1 1 2 \n",
"3 3 7 1 2 \n",
"4 3 1 1 2 "
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cell_df = pd.read_csv(\"cell_samples.csv\")\n",
"cell_df.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The ID field contains the patient identifiers. The characteristics of the cell samples from each patient are contained in fields Clump to Mit. The values are graded from 1 to 10, with 1 being the closest to benign.\n",
"\n",
"The Class field contains the diagnosis, as confirmed by separate medical procedures, as to whether the samples are benign (value = 2) or malignant (value = 4).\n",
"\n",
"Lets look at the distribution of the classes based on Clump thickness and Uniformity of cell size:\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAEGCAYAAABiq/5QAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAAsTAAALEwEAmpwYAAAhKklEQVR4nO3df3Rc9Xnn8fdjS4pHYInEFq2LWY2TxUUCE4GFjovdYn4Y5xwcIBzajQO74Ci42yInKSGBpCf8yGlzUpJNSEObXTfCuEktSJ1ACCVgnMIGKIksYweMpphSxsaNWo8FqyaMiCTr2T9mJGvkH/o1c++V7ud1js7VPB7Nffydq4+uvjO6X3N3REQkPmaF3YCIiARLwS8iEjMKfhGRmFHwi4jEjIJfRCRmysJuYDzmz5/vyWQy7DZERKaVnTt3HnL3mtH1aRH8yWSSjo6OsNsQEZlWzGzfseqa6hERiRkFv4hIzCj4RURiZlrM8R9Lf38/Bw4c4J133gm7lRllzpw5LFy4kPLy8rBbEZESmbbBf+DAAebOnUsymcTMwm5nRnB3uru7OXDgAIsWLQq7HREpkZJN9ZjZfWZ20Mz2jKi9x8yeNLNX89t3T/bx33nnHebNm6fQLyIzY968ebH4LSqTybJjRxeZTDbUPlKpbjZv3kMq1R1qH1ERlfGIyvHx6KOv8bGPPcGjj75W1Mct5Rn//cC9wN+OqN0G/Njdv2Rmt+Vv3zrZHSj0iy8OY9rWlqK5+QkqKmbR1zdIa+tq1q6tC7yPDRu2c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/YTBzNYAB919Z9i9REQZcB7wTXc/l9xixEX5VX66yc9dXwksAn4LOMnMrgu3q5lLwR8AMysnF/p/5+7fD7ufEC0HrjCzNPAAcLGZfSfclkJ1ADjg7kO/AW4l94Mgji4FXnf3jLv3A98HLgi5pyj4DzNbAJDfHizGgyr4S8zMjNwcbsrdvxp2P2Fy98+6+0J3T5J74e4f3T22Z3Xu/u/AG2b22/nSJUBniC2FaT+wzMwq898zlxDTF7pHeQS4Pv/59cAPivGgZcV4EDmh5cB/B14ys9352ufc/bHwWpII2QD8nZlVAP8KrAu5n1C4+8/MbCvwArl3wu0iZpduMLM2YCUw38wOAHcAXwK+a2bN5H44/n5R9qVLNoiIxIumekREYkbBLyISMwp+EZGYUfCLiMSMgl9EJGYU/CKAmf2mmT1gZq+ZWaeZPWZmi0deKVFkptD7+CX28n8w9BCw2d0/nK81AL8RZl8ipaIzfhG4COh39/89VHD33cAbQ7fN7AYzu3fE7UfNbGX+81+Z2V+Y2U4z225mTWb2tJn9q5ldMeLrf2Bmj5vZK2Z2R0D/N5GjKPhF4GxgKheOOwl42t2XAr8E/gxYBXwI+MKI+zUB1wINwO+bWeMU9ikyaZrqEZm6PuDx/OcvAb92934zewlIjrjfk+7eDWBm3wdWAB1BNioCOuMXAXgZWDrGfQYo/H4ZuSxgvx+59skg8GsAdx+k8ORq9PVRdL0UCYWCXwT+EXiXmd04VDCz84HaEfdJAw1mNsvMTic3bTNRq/JrqCbIraT03ORbFpk8Bb/EXv5s/UPkgvk1M3sZuJPCpf+eA14nN5XzFXJXkZyoZ4FvA7uB77m7pnkkFLo6p0gAzOwGcguJt4Tdi4jO+EVEYkZn/CIiMaMzfhGRmFHwi4jEjIJfRCRmFPwiIjGj4BcRiZn/D4jvLygcakNpAAAAAElFTkSuQmCC\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"ax = cell_df[cell_df['Class'] == 4][0:50].plot(kind='scatter', x='Clump', y='UnifSize', color='DarkBlue', label='malignant');\n",
"cell_df[cell_df['Class'] == 2][0:50].plot(kind='scatter', x='Clump', y='UnifSize', color='Yellow', label='benign', ax=ax);\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Data pre-processing and selection\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Lets first look at columns data types:\n"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0 1\n",
"1 10\n",
"2 2\n",
"3 4\n",
"4 1\n",
" ..\n",
"694 2\n",
"695 1\n",
"696 3\n",
"697 4\n",
"698 5\n",
"Name: BareNuc, Length: 683, dtype: int64"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cell_df.dtypes\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"It looks like the **BareNuc** column includes some values that are not numerical. We can drop those rows:\n"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"ID int64\n",
"Clump int64\n",
"UnifSize int64\n",
"UnifShape int64\n",
"MargAdh int64\n",
"SingEpiSize int64\n",
"BareNuc int64\n",
"BlandChrom int64\n",
"NormNucl int64\n",
"Mit int64\n",
"Class int64\n",
"dtype: object"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cell_df = cell_df[pd.to_numeric(cell_df['BareNuc'], errors='coerce').notnull()]\n",
"cell_df['BareNuc'] = cell_df['BareNuc'].astype('int')\n",
"cell_df.dtypes\n"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[ 5, 1, 1, 1, 2, 1, 3, 1, 1],\n",
" [ 5, 4, 4, 5, 7, 10, 3, 2, 1],\n",
" [ 3, 1, 1, 1, 2, 2, 3, 1, 1],\n",
" [ 6, 8, 8, 1, 3, 4, 3, 7, 1],\n",
" [ 4, 1, 1, 3, 2, 1, 3, 1, 1]])"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"feature_df = cell_df[['Clump', 'UnifSize', 'UnifShape', 'MargAdh', 'SingEpiSize', 'BareNuc', 'BlandChrom', 'NormNucl', 'Mit']]\n",
"X = np.asarray(feature_df)\n",
"X[0:5]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We want the model to predict the value of Class (that is, benign (=2) or malignant (=4)). As this field can have one of only two possible values, we need to change its measurement level to reflect this.\n"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([2, 2, 2, 2, 2])"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cell_df['Class'] = cell_df['Class'].astype('int')\n",
"y = np.asarray(cell_df['Class'])\n",
"y [0:5]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Train/Test dataset\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Okay, we split our dataset into train and test set:\n"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Train set: (546, 9) (546,)\n",
"Test set: (137, 9) (137,)\n"
]
}
],
"source": [
"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": {},
"source": [
"<h2 id=\"modeling\">Modeling (SVM with Scikit-learn)</h2>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The SVM algorithm offers a choice of kernel functions for performing its processing. Basically, mapping data into a higher dimensional space is called kernelling. The mathematical function used for the transformation is known as the kernel function, and can be of different types, such as:\n",
"\n",
"```\n",
"1.Linear\n",
"2.Polynomial\n",
"3.Radial basis function (RBF)\n",
"4.Sigmoid\n",
"```\n",
"\n",
"Each of these functions has its characteristics, its pros and cons, and its equation, but as there's no easy way of knowing which function performs best with any given dataset, we usually choose different functions in turn and compare the results. Let's just use the default, RBF (Radial Basis Function) for this lab.\n"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"SVC()"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from sklearn import svm\n",
"clf = svm.SVC(kernel='rbf')\n",
"clf.fit(X_train, y_train) "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"After being fitted, the model can then be used to predict new values:\n"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([2, 4, 2, 4, 2])"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"yhat = clf.predict(X_test)\n",
"yhat [0:5]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2 id=\"evaluation\">Evaluation</h2>\n"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.metrics import classification_report, confusion_matrix\n",
"import itertools"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
"def plot_confusion_matrix(cm, classes,\n",
" normalize=False,\n",
" title='Confusion matrix',\n",
" cmap=plt.cm.Blues):\n",
" \"\"\"\n",
" This function prints and plots the confusion matrix.\n",
" Normalization can be applied by setting `normalize=True`.\n",
" \"\"\"\n",
" if normalize:\n",
" cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n",
" print(\"Normalized confusion matrix\")\n",
" else:\n",
" print('Confusion matrix, without normalization')\n",
"\n",
" print(cm)\n",
"\n",
" plt.imshow(cm, interpolation='nearest', cmap=cmap)\n",
" plt.title(title)\n",
" plt.colorbar()\n",
" tick_marks = np.arange(len(classes))\n",
" plt.xticks(tick_marks, classes, rotation=45)\n",
" plt.yticks(tick_marks, classes)\n",
"\n",
" fmt = '.2f' if normalize else 'd'\n",
" thresh = cm.max() / 2.\n",
" for i, j in itertools.product(range(cm.shape[0]), range(cm.shape[1])):\n",
" plt.text(j, i, format(cm[i, j], fmt),\n",
" horizontalalignment=\"center\",\n",
" color=\"white\" if cm[i, j] > thresh else \"black\")\n",
"\n",
" plt.tight_layout()\n",
" plt.ylabel('True label')\n",
" plt.xlabel('Predicted label')"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" precision recall f1-score support\n",
"\n",
" 2 1.00 0.94 0.97 90\n",
" 4 0.90 1.00 0.95 47\n",
"\n",
" accuracy 0.96 137\n",
" macro avg 0.95 0.97 0.96 137\n",
"weighted avg 0.97 0.96 0.96 137\n",
"\n",
"Confusion matrix, without normalization\n",
"[[85 5]\n",
" [ 0 47]]\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAVMAAAEmCAYAAADfpHMGAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAAsTAAALEwEAmpwYAAAp6klEQVR4nO3dd5xcZdnG8d+1m0BCChASWugKxBAkQOiCIBZABFQQFHxFrK8FFRUbLwj2DtIUEGlSREGRIFUiRWpCQDpIqAmQhJZAKEnu94/nGZism5nZnTM7M7vXl898duacM2fu3bD3PuWc51ZEYGZm9elodgBmZv2Bk6mZWQGcTM3MCuBkamZWACdTM7MCOJmamRXAydSaStJQSX+T9Lyk8+s4z/6SLi8ytmaRtL2k+5odh/WMfJ2p1ULSR4BDgHHAPGA68IOIuK7O834U+CKwbUQsrDfOVicpgPUj4sFmx2LFcsvUqpJ0CHA08ENgFWAt4ARgzwJOvzZw/0BIpLWQNKjZMVgvRYQffiz1ASwPzAf2qXDMsqRkOzM/jgaWzft2BB4Hvgo8DcwCPp73HQm8CryWP+M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arxa0tnAvyV1SvqZpFsk3SHpM5AuKZJ0nKS7JU0mLSZC3jdF0qT8fBdJ0yTdLumqXEL5s6S1RKdL2l7SGEl/zp9xi6Tt8ntXknS5pNsk/ZZ0/3xFkv4iaaqkuyR9usu+X+RYrpI0Jm97k6RL83uuzStMWT/kO6Cs4SQNIt2nXirgtyUwISJm5IT0fERsIWlZ4HpJl5Pubd8Q2BhYBbgbOLXLeccAJwM75HONiohn8spN8yPi5/m4s4FfRcR1uaTIZcBbSDWZrouIo/JF9kskx6U4KH/GUOAWSX+OiLnAMGBaRHxV0uH53F8ATgI+GxEPSNoKOAF4Ry9+jNbinEytkYZKmp6fX0taXX5b0orzM/L2dwNvLY2HAssD65Pqxp8TEYuAmZL+0c35twauKZ0rIp5ZShzvBMaXVVweKWlE/owP5PdOllTLrZ8HS3p/fr5mjnUuadm98/L2s4ALJA3P3+/5ZZ+9bA2fYW3IydQaaUFETCzfkJPKi+WbSLWSLuty3G6kUh+VqIZjIA1nbRMRC7qJpea7ViTtSErM20TES5KmAEOWcnjkz32u68/A+iePmVqzXQb8r6TBAJI2kDQMuAbYL4+prgbs1M17bwDeLmnd/N5Refs8UmG7kstJXW7ycRPz02tIJZeRtCupYmglywPP5kQ6jtQyLukASq3rj5CGD14AZkjaJ3+GJG1S5TOsTTmZWrOdQhoPnSbpTuC3pB7ThcADwL+BE4F/dn1jRMwmjXNeIOl23uhm/w14f2kCCjgYmJQnuO7mjasKjgR2kDSNNNzwaJVYLwUGSboD+B5wY9m+F0kr7U8ljYkelbfvD3wix3cXqbyz9UO+N9/MrABumZqZFcDJ1MysAE6mZmYFcDI1MyuAk6mZWQGcTM3MCuBkamZWgP8HpKn7/Mv2YUkAAAAASUVORK5CYII=\n",
"text/plain": [
"<Figure size 432x288 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# Compute confusion matrix\n",
"cnf_matrix = confusion_matrix(y_test, yhat, labels=[2,4])\n",
"np.set_printoptions(precision=2)\n",
"\n",
"print (classification_report(y_test, yhat))\n",
"\n",
"# Plot non-normalized confusion matrix\n",
"plt.figure()\n",
"plot_confusion_matrix(cnf_matrix, classes=['Benign(2)','Malignant(4)'],normalize= False, title='Confusion matrix')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can also easily use the **f1_score** from sklearn library:\n"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.9639038982104676"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from sklearn.metrics import f1_score\n",
"f1_score(y_test, yhat, average='weighted') "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Lets try jaccard index for accuracy:\n"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.9444444444444444"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from sklearn.metrics import jaccard_score\n",
"jaccard_score(y_test, yhat,pos_label=2)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2 id=\"practice\">Practice</h2>\n",
"Can you rebuild the model, but this time with a __linear__ kernel? You can use __kernel='linear'__ option, when you define the svm. How the accuracy changes with the new kernel function?\n"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Avg F1-score: 0.9639\n",
"Jaccard score: 0.9444\n"
]
}
],
"source": [
"# write your code here\n",
"clf2 = svm.SVC(kernel='linear')\n",
"clf2.fit(X_train, y_train) \n",
"yhat2 = clf2.predict(X_test)\n",
"print(\"Avg F1-score: %.4f\" % f1_score(y_test, yhat2, average='weighted'))\n",
"print(\"Jaccard score: %.4f\" % jaccard_score(y_test, yhat2,pos_label=2))\n",
"\n",
"#this is more accurate\n",
"#clf4 = svm.SVC(kernel='poly')\n",
"#clf4.fit(X_train, y_train) \n",
"#yhat4 = clf4.predict(X_test)\n",
"#print(\"Avg F1-score: %.4f\" % f1_score(y_test, yhat4, average='weighted'))\n",
"#print(\"Jaccard score: %.4f\" % jaccard_score(y_test, yhat4,pos_label=2))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<details><summary>Click here for the solution</summary>\n",
"\n",
"```python\n",
"clf2 = svm.SVC(kernel='linear')\n",
"clf2.fit(X_train, y_train) \n",
"yhat2 = clf2.predict(X_test)\n",
"print(\"Avg F1-score: %.4f\" % f1_score(y_test, yhat2, average='weighted'))\n",
"print(\"Jaccard score: %.4f\" % jaccard_score(y_test, yhat2,pos_label=2))\n",
"\n",
"```\n",
"\n",
"</details>\n"
]
},
{
"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",
"| 2021-01-21 | 2.2 | Lakshmi | Updated sklearn library |\n",
"| 2020-11-03 | 2.1 | Lakshmi | Updated 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"
]
}
],
"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.12"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment