Skip to content

Instantly share code, notes, and snippets.

@depindersharma
Created February 2, 2020 10:36
Show Gist options
  • Save depindersharma/0d813b4b036245bc6b4383ddf57aec20 to your computer and use it in GitHub Desktop.
Save depindersharma/0d813b4b036245bc6b4383ddf57aec20 to your computer and use it in GitHub Desktop.
Created on Cognitive Class Labs
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<a href=\"https://www.bigdatauniversity.com\"><img src=\"https://ibm.box.com/shared/static/cw2c7r3o20w9zn8gkecaeyjhgw3xdgbj.png\" width=\"400\" align=\"center\"></a>\n",
"\n",
"<h1 align=center><font size=\"5\"> SVM (Support Vector Machines)</font></h1>"
]
},
{
"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."
]
},
{
"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>"
]
},
{
"cell_type": "code",
"execution_count": 1,
"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",
"__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)"
]
},
{
"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-02-01 19:06:32-- https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/ML0101ENv3/labs/cell_samples.csv\n",
"Resolving s3-api.us-geo.objectstorage.softlayer.net (s3-api.us-geo.objectstorage.softlayer.net)... 67.228.254.196\n",
"Connecting to s3-api.us-geo.objectstorage.softlayer.net (s3-api.us-geo.objectstorage.softlayer.net)|67.228.254.196|:443... connected.\n",
"HTTP request sent, awaiting response... 200 OK\n",
"Length: 20675 (20K) [text/csv]\n",
"Saving to: ‘cell_samples.csv’\n",
"\n",
"cell_samples.csv 100%[===================>] 20.19K --.-KB/s in 0.02s \n",
"\n",
"2020-02-01 19:06:32 (954 KB/s) - ‘cell_samples.csv’ saved [20675/20675]\n",
"\n"
]
}
],
"source": [
"#Click here and press Shift+Enter\n",
"!wget -O cell_samples.csv https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/ML0101ENv3/labs/cell_samples.csv"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"### Load Data From CSV File "
]
},
{
"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>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": 3,
"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:"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAEGCAYAAABiq/5QAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3dfXRU9b3v8fcXkpSJkmgh9nLEm6G9UsODRohZHKFHVJCuK1Xrsr2leq/SKF2tQVtrq21Xfeg6p8vj8bb2aG/vpY3IaUu0Bx9LfUB6dFWtbQhCFTIHrHVATrmHIXpzqolNQr73j5k8AoY8zN472Z/XWqw988tk7y+/2fnkl9/M7J+5OyIiEh8Twi5ARESCpeAXEYkZBb+ISMwo+EVEYkbBLyISMwVhF3Aspk6d6slkMuwyRETGlK1btx5097KB7WMi+JPJJI2NjWGXISIyppjZniO1a6pHRCRmFPwiIjGj4BcRiZkxMcd/JB0dHezbt4/33nsv7FLGlUmTJjF9+nQKCwvDLkVE8mTMBv++ffuYPHkyyWQSMwu7nHHB3Wlubmbfvn3MmDEj7HJEJE/yNtVjZveZ2QEz29Gn7YNm9oyZvZbbnjjc/b/33ntMmTJFoT+KzIwpU6bE5q+oTKaVLVv2k8m0hlpHKtXMunU7SKWaQ60jCqLSF1E4NzZufJ2rr36ajRtfH/V953PEfz9wL/BPfdpuBn7l7neY2c25+zcN9wAK/dEXlz6tr09RU/M0RUUTaG/voq5uGStWVARex+rVm7n33u0992trK7nnniWB1xEFUemLKJwbc+euZceO7C+/urpXmTt3Cq+8snLU9p+3Eb+7/xp4a0DzxcC63O11wCX5Or7I0WQyrdTUPE1bW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xeN7MmM3vCzGb2vVKiyHih9/FL7OU+LPQIsM7dP5NrqwQ+FGphInmiEb8InAt0uPv/7m5w9+3Am933zewqM7u3z/2NZrY4d/sdM/t7M9tqZpvNrNrMnjOzP5rZRX2+/zEze8rMdpnZrYH970QGUPCLwBxgJBeNOw54zt3nA38G/hZYCnwS+Hafx1UDlwOVwKfMrGoExxQZNk31iIxcO/BU7varwF/cvcPMXgWSfR73jLs3A5jZw8AioDHIQkVAI34RgJ3A/EEe00n/n5e+SwJ2eO+1T7qAvwC4exf9B1cDr4+i66VIKBT8IvAvwAfM7JruBjM7Cyjv85g0UGlmE8zsFLLTNkO1NLeGaoLsSkovjqBmkWFT8Evs5UbrnyQbzK+b2U7gNvov+/ci8AbZqZy7yF5BcqheAH4CbAcecndN80godHVOkQCY2ZYRTzgAAAA2SURBVFVkFxGvDbsWEY34RURiRiN+EZGY0YhfRCRmFPwiIjGj4BcRiRkFv4hIzCj4RURi5v8DIiJIkAYBN7sAAAAASUVORK5CYII=\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"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Lets first look at columns data types:"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"ID int64\n",
"Clump int64\n",
"UnifSize int64\n",
"UnifShape int64\n",
"MargAdh int64\n",
"SingEpiSize int64\n",
"BareNuc object\n",
"BlandChrom int64\n",
"NormNucl int64\n",
"Mit int64\n",
"Class int64\n",
"dtype: object"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cell_df.dtypes"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"It looks like the __BareNuc__ column includes some values that are not numerical. We can drop those rows:"
]
},
{
"cell_type": "code",
"execution_count": 6,
"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": 6,
"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"
]
},
{
"cell_type": "code",
"execution_count": 7,
"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": 7,
"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."
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([2, 2, 2, 2, 2])"
]
},
"execution_count": 8,
"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"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Okay, we split our dataset into train and test set:"
]
},
{
"cell_type": "code",
"execution_count": 9,
"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>"
]
},
{
"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",
" 1.Linear\n",
" 2.Polynomial\n",
" 3.Radial basis function (RBF)\n",
" 4.Sigmoid\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."
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/jupyterlab/conda/envs/python/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
" \"avoid this warning.\", FutureWarning)\n"
]
},
{
"data": {
"text/plain": [
"SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0,\n",
" decision_function_shape='ovr', degree=3, gamma='auto_deprecated',\n",
" kernel='rbf', max_iter=-1, probability=False, random_state=None,\n",
" shrinking=True, tol=0.001, verbose=False)"
]
},
"execution_count": 10,
"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:"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([2, 4, 2, 4, 2])"
]
},
"execution_count": 11,
"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>"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.metrics import classification_report, confusion_matrix\n",
"import itertools"
]
},
{
"cell_type": "code",
"execution_count": 13,
"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": 14,
"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",
" micro avg 0.96 0.96 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": "iVBORw0KGgoAAAANSUhEUgAAAaQAAAEXCAYAAADiEjDuAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3dd5ydVbn28d+VBEzoJRAhdAQRUQJEjoJyUJAjRUCRZgPhyGvvIioHu3CsgIgKimJDEEUiiIA5osihNwVBOggEQpEeSsL1/rHWwGZOMnvPZGb2M9nXl8/+zH7KXs+aJMw9q91LtomIiOi2cd2uQEREBCQgRUREQyQgRUREIyQgRUREIyQgRUREI0zodgUiImL0jF9mTXvunI7v95x7zrT9uhGs0jMSkCIieojnzuF5L9yj4/sfv+Lbk0ewOs+RgBQR0VMEauZoTQJSREQvESB1uxbzlYAUEdFr0kKKiIhGSAspIiK6L2NIERHRFGkhRURE10kwbny3azFfCUgREb0mXXYREdEI6bKLiIjua+6khmbWKiIiRkbfwthOX50UKX1Y0tWSrpJ0gqSJklaQdLak6+vX5duVk4AUEdFrNK7zV7uipKnAB4DptjcCxgN7AQcBM22vB8ysxwNKQIqI6Cka1oBUTQAmSZoALAHcCewCHF+vHw/s2q6QBKSIiF4zTp2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RA7sA2FLSCwAkLSFpfeBaYG1J69b79l7A52cC766fHS9pGeBhSuunz5nAfi1jU1MlrQz8GXiDpEmSlqZ0D7azNDCrZtx+S79ru0saV+u8DvCP+ux392XolrS+pCU7eE7EsEsLKWIAtu+pLY0TJD2vnj7Y9nWSDgBOl3Qv8Bdgo/kU8UHgGEn7A/OAd9s+X9J5dVr1GXUc6UXA+bWF9gjwVtuXSToRuAK4ldKt2M5/UXZsvZUyJtYa+P4B/AmYArzL9uOSvk8ZW7pM5eH3ALt29qcTMbySOigiIhohXXYREdEICUgREdEICUgREdEICUgREdEICUgREdEICUgREdEICUgREdEI/x+xG7mXtCON6QAAAABJRU5ErkJggg==\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:"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.9639038982104676"
]
},
"execution_count": 15,
"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:"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.9635036496350365"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from sklearn.metrics import jaccard_similarity_score\n",
"jaccard_similarity_score(y_test, yhat)"
]
},
{
"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?"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"# write your code here\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Double-click __here__ for the solution.\n",
"\n",
"<!-- Your answer is below:\n",
" \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_similarity_score(y_test, yhat2))\n",
"\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=\"http://cocl.us/ML0101EN-SPSSModeler\">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://cocl.us/ML0101EN_DSX\">Watson Studio</a>\n",
"\n",
"<h3>Thanks for completing this lesson!</h3>\n",
"\n",
"<h4>Author: <a href=\"https://ca.linkedin.com/in/saeedaghabozorgi\">Saeed Aghabozorgi</a></h4>\n",
"<p><a href=\"https://ca.linkedin.com/in/saeedaghabozorgi\">Saeed Aghabozorgi</a>, PhD is a Data Scientist in IBM with a track record of developing enterprise level applications that substantially increases clients’ ability to turn data into actionable knowledge. He is a researcher in data mining field and expert in developing advanced analytic methods like machine learning and statistical modelling on large datasets.</p>\n",
"\n",
"<hr>\n",
"\n",
"<p>Copyright &copy; 2018 <a href=\"https://cocl.us/DX0108EN_CC\">Cognitive Class</a>. This notebook and its source code are released under the terms of the <a href=\"https://bigdatauniversity.com/mit-license/\">MIT License</a>.</p>"
]
}
],
"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.7"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment