Created
March 23, 2021 02:56
-
-
Save HandcartCactus/93033039e56cd78d6eb83442dd08e173 to your computer and use it in GitHub Desktop.
IrisSVC with TabPy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import tabpy_client\n", | |
"import matplotlib.pyplot as plt\n", | |
"import pandas as pd\n", | |
"import numpy as np\n", | |
"from sklearn import model_selection\n", | |
"from sklearn.svm import SVC\n", | |
"from sklearn import metrics" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"REDO_TRAIN_TEST = False\n", | |
"TEST_TO_TRAIN = 0.20 # n_test/n_all" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 16, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"df = pd.read_csv('data/iris_whole.csv')\n", | |
"\n", | |
"cdict = {k:v for v,k in enumerate(df['species'].unique())}\n", | |
"inv_cdict = {v:k for v,k in enumerate(df['species'].unique())}\n", | |
"\n", | |
"convert = lambda x: cdict[x]\n", | |
"df['species_class'] = list(map(convert, df['species']))\n", | |
"\n", | |
"df.to_csv('data/iris_enriched.csv', index=True)\n", | |
"\n", | |
"if REDO_TRAIN_TEST:\n", | |
" train,test = model_selection.train_test_split(df, test_size=TEST_TO_TRAIN)\n", | |
" train.to_csv('data/iris_train.csv', index=True)\n", | |
" test.to_csv('data/iris_test.csv', index=True)\n", | |
"else:\n", | |
" train = pd.read_csv('data/iris_train.csv')\n", | |
" test = pd.read_csv('data/iris_test.csv')\n", | |
"\n", | |
"train_x = train[[\"sepal_length\", \"sepal_width\", \"petal_length\", \"petal_width\"]]\n", | |
"train_y = train['species_class']\n", | |
"\n", | |
"test_x = test[[\"sepal_length\", \"sepal_width\", \"petal_length\", \"petal_width\"]]\n", | |
"test_y = test['species_class']" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"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>sepal_length</th>\n", | |
" <th>sepal_width</th>\n", | |
" <th>petal_length</th>\n", | |
" <th>petal_width</th>\n", | |
" <th>species</th>\n", | |
" <th>species_class</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>5.1</td>\n", | |
" <td>3.5</td>\n", | |
" <td>1.4</td>\n", | |
" <td>0.2</td>\n", | |
" <td>setosa</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>4.9</td>\n", | |
" <td>3.0</td>\n", | |
" <td>1.4</td>\n", | |
" <td>0.2</td>\n", | |
" <td>setosa</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>4.7</td>\n", | |
" <td>3.2</td>\n", | |
" <td>1.3</td>\n", | |
" <td>0.2</td>\n", | |
" <td>setosa</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>4.6</td>\n", | |
" <td>3.1</td>\n", | |
" <td>1.5</td>\n", | |
" <td>0.2</td>\n", | |
" <td>setosa</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>5.0</td>\n", | |
" <td>3.6</td>\n", | |
" <td>1.4</td>\n", | |
" <td>0.2</td>\n", | |
" <td>setosa</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>...</th>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>145</th>\n", | |
" <td>6.7</td>\n", | |
" <td>3.0</td>\n", | |
" <td>5.2</td>\n", | |
" <td>2.3</td>\n", | |
" <td>virginica</td>\n", | |
" <td>2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>146</th>\n", | |
" <td>6.3</td>\n", | |
" <td>2.5</td>\n", | |
" <td>5.0</td>\n", | |
" <td>1.9</td>\n", | |
" <td>virginica</td>\n", | |
" <td>2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>147</th>\n", | |
" <td>6.5</td>\n", | |
" <td>3.0</td>\n", | |
" <td>5.2</td>\n", | |
" <td>2.0</td>\n", | |
" <td>virginica</td>\n", | |
" <td>2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>148</th>\n", | |
" <td>6.2</td>\n", | |
" <td>3.4</td>\n", | |
" <td>5.4</td>\n", | |
" <td>2.3</td>\n", | |
" <td>virginica</td>\n", | |
" <td>2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>149</th>\n", | |
" <td>5.9</td>\n", | |
" <td>3.0</td>\n", | |
" <td>5.1</td>\n", | |
" <td>1.8</td>\n", | |
" <td>virginica</td>\n", | |
" <td>2</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"<p>150 rows × 6 columns</p>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" sepal_length sepal_width petal_length petal_width species \\\n", | |
"0 5.1 3.5 1.4 0.2 setosa \n", | |
"1 4.9 3.0 1.4 0.2 setosa \n", | |
"2 4.7 3.2 1.3 0.2 setosa \n", | |
"3 4.6 3.1 1.5 0.2 setosa \n", | |
"4 5.0 3.6 1.4 0.2 setosa \n", | |
".. ... ... ... ... ... \n", | |
"145 6.7 3.0 5.2 2.3 virginica \n", | |
"146 6.3 2.5 5.0 1.9 virginica \n", | |
"147 6.5 3.0 5.2 2.0 virginica \n", | |
"148 6.2 3.4 5.4 2.3 virginica \n", | |
"149 5.9 3.0 5.1 1.8 virginica \n", | |
"\n", | |
" species_class \n", | |
"0 0 \n", | |
"1 0 \n", | |
"2 0 \n", | |
"3 0 \n", | |
"4 0 \n", | |
".. ... \n", | |
"145 2 \n", | |
"146 2 \n", | |
"147 2 \n", | |
"148 2 \n", | |
"149 2 \n", | |
"\n", | |
"[150 rows x 6 columns]" | |
] | |
}, | |
"execution_count": 4, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"df" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"120\n" | |
] | |
}, | |
{ | |
"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>Unnamed: 0</th>\n", | |
" <th>sepal_length</th>\n", | |
" <th>sepal_width</th>\n", | |
" <th>petal_length</th>\n", | |
" <th>petal_width</th>\n", | |
" <th>species</th>\n", | |
" <th>species_class</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>64</td>\n", | |
" <td>5.6</td>\n", | |
" <td>2.9</td>\n", | |
" <td>3.6</td>\n", | |
" <td>1.3</td>\n", | |
" <td>versicolor</td>\n", | |
" <td>1</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>28</td>\n", | |
" <td>5.2</td>\n", | |
" <td>3.4</td>\n", | |
" <td>1.4</td>\n", | |
" <td>0.2</td>\n", | |
" <td>setosa</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>59</td>\n", | |
" <td>5.2</td>\n", | |
" <td>2.7</td>\n", | |
" <td>3.9</td>\n", | |
" <td>1.4</td>\n", | |
" <td>versicolor</td>\n", | |
" <td>1</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>49</td>\n", | |
" <td>5.0</td>\n", | |
" <td>3.3</td>\n", | |
" <td>1.4</td>\n", | |
" <td>0.2</td>\n", | |
" <td>setosa</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>103</td>\n", | |
" <td>6.3</td>\n", | |
" <td>2.9</td>\n", | |
" <td>5.6</td>\n", | |
" <td>1.8</td>\n", | |
" <td>virginica</td>\n", | |
" <td>2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>5</th>\n", | |
" <td>45</td>\n", | |
" <td>4.8</td>\n", | |
" <td>3.0</td>\n", | |
" <td>1.4</td>\n", | |
" <td>0.3</td>\n", | |
" <td>setosa</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>6</th>\n", | |
" <td>112</td>\n", | |
" <td>6.8</td>\n", | |
" <td>3.0</td>\n", | |
" <td>5.5</td>\n", | |
" <td>2.1</td>\n", | |
" <td>virginica</td>\n", | |
" <td>2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>7</th>\n", | |
" <td>139</td>\n", | |
" <td>6.9</td>\n", | |
" <td>3.1</td>\n", | |
" <td>5.4</td>\n", | |
" <td>2.1</td>\n", | |
" <td>virginica</td>\n", | |
" <td>2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>8</th>\n", | |
" <td>21</td>\n", | |
" <td>5.1</td>\n", | |
" <td>3.7</td>\n", | |
" <td>1.5</td>\n", | |
" <td>0.4</td>\n", | |
" <td>setosa</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>9</th>\n", | |
" <td>106</td>\n", | |
" <td>4.9</td>\n", | |
" <td>2.5</td>\n", | |
" <td>4.5</td>\n", | |
" <td>1.7</td>\n", | |
" <td>virginica</td>\n", | |
" <td>2</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" Unnamed: 0 sepal_length sepal_width petal_length petal_width \\\n", | |
"0 64 5.6 2.9 3.6 1.3 \n", | |
"1 28 5.2 3.4 1.4 0.2 \n", | |
"2 59 5.2 2.7 3.9 1.4 \n", | |
"3 49 5.0 3.3 1.4 0.2 \n", | |
"4 103 6.3 2.9 5.6 1.8 \n", | |
"5 45 4.8 3.0 1.4 0.3 \n", | |
"6 112 6.8 3.0 5.5 2.1 \n", | |
"7 139 6.9 3.1 5.4 2.1 \n", | |
"8 21 5.1 3.7 1.5 0.4 \n", | |
"9 106 4.9 2.5 4.5 1.7 \n", | |
"\n", | |
" species species_class \n", | |
"0 versicolor 1 \n", | |
"1 setosa 0 \n", | |
"2 versicolor 1 \n", | |
"3 setosa 0 \n", | |
"4 virginica 2 \n", | |
"5 setosa 0 \n", | |
"6 virginica 2 \n", | |
"7 virginica 2 \n", | |
"8 setosa 0 \n", | |
"9 virginica 2 " | |
] | |
}, | |
"execution_count": 5, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"print(len(train.index))\n", | |
"train.head(10)\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"30\n" | |
] | |
}, | |
{ | |
"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>Unnamed: 0</th>\n", | |
" <th>sepal_length</th>\n", | |
" <th>sepal_width</th>\n", | |
" <th>petal_length</th>\n", | |
" <th>petal_width</th>\n", | |
" <th>species</th>\n", | |
" <th>species_class</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>6</td>\n", | |
" <td>4.6</td>\n", | |
" <td>3.4</td>\n", | |
" <td>1.4</td>\n", | |
" <td>0.3</td>\n", | |
" <td>setosa</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>0</td>\n", | |
" <td>5.1</td>\n", | |
" <td>3.5</td>\n", | |
" <td>1.4</td>\n", | |
" <td>0.2</td>\n", | |
" <td>setosa</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>16</td>\n", | |
" <td>5.4</td>\n", | |
" <td>3.9</td>\n", | |
" <td>1.3</td>\n", | |
" <td>0.4</td>\n", | |
" <td>setosa</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>89</td>\n", | |
" <td>5.5</td>\n", | |
" <td>2.5</td>\n", | |
" <td>4.0</td>\n", | |
" <td>1.3</td>\n", | |
" <td>versicolor</td>\n", | |
" <td>1</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>136</td>\n", | |
" <td>6.3</td>\n", | |
" <td>3.4</td>\n", | |
" <td>5.6</td>\n", | |
" <td>2.4</td>\n", | |
" <td>virginica</td>\n", | |
" <td>2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>5</th>\n", | |
" <td>13</td>\n", | |
" <td>4.3</td>\n", | |
" <td>3.0</td>\n", | |
" <td>1.1</td>\n", | |
" <td>0.1</td>\n", | |
" <td>setosa</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>6</th>\n", | |
" <td>146</td>\n", | |
" <td>6.3</td>\n", | |
" <td>2.5</td>\n", | |
" <td>5.0</td>\n", | |
" <td>1.9</td>\n", | |
" <td>virginica</td>\n", | |
" <td>2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>7</th>\n", | |
" <td>66</td>\n", | |
" <td>5.6</td>\n", | |
" <td>3.0</td>\n", | |
" <td>4.5</td>\n", | |
" <td>1.5</td>\n", | |
" <td>versicolor</td>\n", | |
" <td>1</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>8</th>\n", | |
" <td>125</td>\n", | |
" <td>7.2</td>\n", | |
" <td>3.2</td>\n", | |
" <td>6.0</td>\n", | |
" <td>1.8</td>\n", | |
" <td>virginica</td>\n", | |
" <td>2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>9</th>\n", | |
" <td>57</td>\n", | |
" <td>4.9</td>\n", | |
" <td>2.4</td>\n", | |
" <td>3.3</td>\n", | |
" <td>1.0</td>\n", | |
" <td>versicolor</td>\n", | |
" <td>1</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" Unnamed: 0 sepal_length sepal_width petal_length petal_width \\\n", | |
"0 6 4.6 3.4 1.4 0.3 \n", | |
"1 0 5.1 3.5 1.4 0.2 \n", | |
"2 16 5.4 3.9 1.3 0.4 \n", | |
"3 89 5.5 2.5 4.0 1.3 \n", | |
"4 136 6.3 3.4 5.6 2.4 \n", | |
"5 13 4.3 3.0 1.1 0.1 \n", | |
"6 146 6.3 2.5 5.0 1.9 \n", | |
"7 66 5.6 3.0 4.5 1.5 \n", | |
"8 125 7.2 3.2 6.0 1.8 \n", | |
"9 57 4.9 2.4 3.3 1.0 \n", | |
"\n", | |
" species species_class \n", | |
"0 setosa 0 \n", | |
"1 setosa 0 \n", | |
"2 setosa 0 \n", | |
"3 versicolor 1 \n", | |
"4 virginica 2 \n", | |
"5 setosa 0 \n", | |
"6 virginica 2 \n", | |
"7 versicolor 1 \n", | |
"8 virginica 2 \n", | |
"9 versicolor 1 " | |
] | |
}, | |
"execution_count": 6, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"print(len(test.index))\n", | |
"test.head(10)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# C-Support Vector Classification, good for this problem.\n", | |
"# may be impractical beyond tens of thousands of samples.\n", | |
"linear_svc = SVC(kernel='linear')\n", | |
"linear_svc = linear_svc.fit(train_x, train_y)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"The accuracy of the linear SVC is 96.667%\n" | |
] | |
} | |
], | |
"source": [ | |
"prediction=linear_svc.predict(test_x)\n", | |
"accuracy = metrics.accuracy_score(prediction,test_y)\n", | |
"print(f'The accuracy of the linear SVC is {accuracy:0.3%}')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"def svc_predict(sepal_length, sepal_width, petal_length, petal_width):\n", | |
" features = np.column_stack([sepal_length,sepal_width,petal_length,petal_width])\n", | |
" return list(linear_svc.predict(features))\n", | |
"\n", | |
"def correct(pred,actual):\n", | |
" return [1*(x==y) for x,y in zip(pred,actual)]\n", | |
" " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 13, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"[(1, True), (0, True), (1, True), (0, True), (2, True), (0, True), (2, True), (2, True), (0, True), (2, True), (2, True), (2, True), (0, True), (0, True), (1, True), (2, True), (2, True), (0, True), (2, True), (2, True), (1, True), (1, True), (0, True), (2, True), (0, True), (2, True), (2, False), (1, True), (0, True), (1, True), (0, True), (2, True), (1, True), (1, True), (2, True), (1, True), (2, True), (1, True), (0, True), (0, True), (1, True), (2, True), (2, True), (1, True), (1, True), (0, True), (1, True), (1, True), (0, True), (2, True), (2, True), (1, True), (1, True), (0, True), (0, True), (2, True), (2, True), (1, True), (0, True), (1, True), (0, True), (2, True), (2, True), (0, True), (1, True), (2, True), (1, True), (1, True), (2, True), (2, True), (1, True), (0, True), (0, True), (1, True), (0, True), (1, True), (2, True), (2, True), (1, True), (1, True), (0, True), (0, True), (0, True), (1, True), (2, False), (2, True), (2, True), (0, True), (1, True), (0, True), (2, True), (2, True), (2, True), (1, True), (0, True), (0, True), (0, True), (0, True), (0, True), (0, True), (1, True), (1, True), (2, True), (1, True), (1, True), (2, True), (1, True), (0, True), (0, True), (1, True), (0, True), (2, True), (1, True), (0, True), (2, True), (0, True), (0, True), (2, True), (1, True), (2, True)]\n", | |
"0.9833333333333333\n" | |
] | |
} | |
], | |
"source": [ | |
"preds = svc_predict(\n", | |
" list(train['sepal_length']),\n", | |
" list(train['sepal_width']),\n", | |
" list(train['petal_length']),\n", | |
" list(train['petal_width']),\n", | |
")\n", | |
"acc = correct(preds, list(train_y))\n", | |
"\n", | |
"print([(x,bool(y)) for x,y in zip(preds, acc)])\n", | |
"print(np.mean(acc))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 11, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"myport = 9004\n", | |
"connection = tabpy_client.Client(f'http://localhost:{myport}')\n", | |
"\n", | |
"connection.deploy(\n", | |
" 'SVCPredict',\n", | |
" svc_predict,\n", | |
" \"Use a C-Support SVM to predict species of flower. Input order: sepal_length, sepal_width, petal_length, petal_width\",\n", | |
" override=True # force-updates the server if it's already running on that port\n", | |
")\n", | |
"\n", | |
"connection.deploy(\n", | |
" 'WasCorrect',\n", | |
" correct,\n", | |
" \"1 if correct, 0 if incorrect. Input Order: Prediction, Actual \",\n", | |
" override=True # force-updates the server if it's already running on that port\n", | |
")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"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.8.5" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment