Files
sspai-100-hours-series-python/projects/machine-learning/sklearn_base.ipynb

1537 lines
72 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "markdown",
"source": [
"### Processing and transform features"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
}
},
{
"cell_type": "markdown",
"source": [
"#### Encode categorical features"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
}
},
{
"cell_type": "code",
"execution_count": 1,
"outputs": [
{
"data": {
"text/plain": " id gender\n0 1 male\n1 2 female",
"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>gender</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>1</td>\n <td>male</td>\n </tr>\n <tr>\n <th>1</th>\n <td>2</td>\n <td>female</td>\n </tr>\n </tbody>\n</table>\n</div>"
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"\n",
"import pandas as pd\n",
"from sklearn.preprocessing import LabelEncoder\n",
"\n",
"data = pd.DataFrame(dict(\n",
" id=[1, 2],\n",
" gender=[\"male\", \"female\"],\n",
"))\n",
"data.head()"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 2,
"outputs": [
{
"data": {
"text/plain": "array(['female', 'male'], dtype=object)"
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"\n",
"target = data[\"gender\"]\n",
"\n",
"encoder = LabelEncoder()\n",
"encoder.fit(target)\n",
"encoder.classes_"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 3,
"outputs": [
{
"data": {
"text/plain": "array([1, 0])"
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"encoder.transform(target)"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 4,
"outputs": [
{
"data": {
"text/plain": "(array([0, 1]), Index(['male', 'female'], dtype='object'))"
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pd.factorize(data[\"gender\"])"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 5,
"outputs": [
{
"data": {
"text/plain": " id is_female is_male\n0 1 0 1\n1 2 1 0",
"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>is_female</th>\n <th>is_male</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>1</td>\n <td>0</td>\n <td>1</td>\n </tr>\n <tr>\n <th>1</th>\n <td>2</td>\n <td>1</td>\n <td>0</td>\n </tr>\n </tbody>\n</table>\n</div>"
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pd.get_dummies(data, prefix=\"is\")"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 6,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[['male']\n",
" ['female']]\n",
"[array(['female', 'male'], dtype=object)]\n"
]
}
],
"source": [
"from sklearn.preprocessing import OneHotEncoder\n",
"\n",
"array = target.values.reshape(-1, 1)\n",
"print(array)\n",
"\n",
"encoder = OneHotEncoder(sparse=False)\n",
"encoder.fit(array)\n",
"print(encoder.categories_)"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 7,
"outputs": [
{
"data": {
"text/plain": "array([[0., 1.],\n [1., 0.]])"
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"encoder.transform(array)"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "markdown",
"source": [
"#### Scaling numerical features"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
}
},
{
"cell_type": "code",
"execution_count": 8,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"raw data mean: [-0.25 0.5 0.5 ]\n",
"raw data std: [1.47901995 0.5 1.11803399]\n"
]
}
],
"source": [
"import numpy as np\n",
"from sklearn.preprocessing import StandardScaler\n",
"\n",
"data = np.array([\n",
" [0, 0, 1],\n",
" [-1, 1, 0],\n",
" [-2, 0, 2],\n",
" [2, 1, -1],\n",
"])\n",
"print(f\"raw data mean: {data.mean(axis=0)}\")\n",
"print(f\"raw data std: {data.std(axis=0)}\")"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 9,
"outputs": [
{
"data": {
"text/plain": "array([[ 0.16903085, -1. , 0.4472136 ],\n [-0.50709255, 1. , -0.4472136 ],\n [-1.18321596, -1. , 1.34164079],\n [ 1.52127766, 1. , -1.34164079]])"
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"scaler = StandardScaler()\n",
"scaler.fit(data)\n",
"scaler.transform(data)"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 10,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Mean = [0. 0. 0.]\n",
"Std = [1. 1. 1.]\n"
]
}
],
"source": [
"scaled = scaler.fit_transform(data)\n",
"print(f\"Mean = {scaled.mean(axis=0)}\")\n",
"print(f\"Std = {scaled.std(axis=0)}\")"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 11,
"outputs": [
{
"data": {
"text/plain": "array([[0.5 , 0. , 0.66666667],\n [0.25 , 1. , 0.33333333],\n [0. , 0. , 1. ],\n [1. , 1. , 0. ]])"
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from sklearn.preprocessing import MinMaxScaler\n",
"\n",
"scaler = MinMaxScaler()\n",
"scaler.fit_transform(data)"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 12,
"outputs": [
{
"data": {
"text/plain": "array([[ 0. , 0. , 1. ],\n [-0.5 , 0.5 , 0. ],\n [-0.5 , 0. , 0.5 ],\n [ 0.5 , 0.25, -0.25]])"
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from sklearn.preprocessing import Normalizer\n",
"\n",
"scaler = Normalizer(norm=\"l1\")\n",
"scaler.fit_transform(data)"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "markdown",
"source": [
"### Split data"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
}
},
{
"cell_type": "code",
"execution_count": 13,
"outputs": [
{
"data": {
"text/plain": " sepal.length sepal.width petal.length petal.width variety\n0 5.1 3.5 1.4 0.2 Setosa\n1 4.9 3.0 1.4 0.2 Setosa\n2 4.7 3.2 1.3 0.2 Setosa\n3 4.6 3.1 1.5 0.2 Setosa\n4 5.0 3.6 1.4 0.2 Setosa",
"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>variety</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 </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 </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 </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 </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 </tr>\n </tbody>\n</table>\n</div>"
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"\n",
"import pathlib\n",
"\n",
"import pandas as pd\n",
"from sklearn.model_selection import train_test_split\n",
"\n",
"csvfile = pathlib.Path(\"../../data/iris.csv\")\n",
"iris = pd.read_csv(csvfile)\n",
"# iris[\"variety\"] = pd.factorize(iris[\"variety\"])[0]\n",
"iris.head()"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 14,
"outputs": [
{
"data": {
"text/plain": " sepal.length sepal.width petal.length petal.width\n0 5.1 3.5 1.4 0.2\n1 4.9 3.0 1.4 0.2\n2 4.7 3.2 1.3 0.2\n3 4.6 3.1 1.5 0.2\n4 5.0 3.6 1.4 0.2",
"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 </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 </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 </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 </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 </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 </tr>\n </tbody>\n</table>\n</div>"
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"X = iris.drop(\"variety\", axis=1)\n",
"X.head()"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 15,
"outputs": [],
"source": [
"y = iris[\"variety\"]"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 16,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"X_train shape: (105, 4)\n",
"X_test shape: (45, 4)\n",
"y_train shape: (105,)\n",
"y_test shape: (45,)\n"
]
}
],
"source": [
"# train:test = 7:3\n",
"\n",
"X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3)\n",
"print(f\"X_train shape: {X_train.shape}\")\n",
"print(f\"X_test shape: {X_test.shape}\")\n",
"print(f\"y_train shape: {y_train.shape}\")\n",
"print(f\"y_test shape: {y_test.shape}\")"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 17,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"X_train shape: (120, 4)\n",
"X_test shape: (30, 4)\n",
"y_train shape: (120,)\n",
"y_test shape: (30,)\n"
]
}
],
"source": [
"# train:test = 0.8:0.2\n",
"\n",
"X_train, X_test, y_train, y_test = train_test_split(X, y, train_size=0.8)\n",
"print(f\"X_train shape: {X_train.shape}\")\n",
"print(f\"X_test shape: {X_test.shape}\")\n",
"print(f\"y_train shape: {y_train.shape}\")\n",
"print(f\"y_test shape: {y_test.shape}\")"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 18,
"outputs": [],
"source": [
"X_train, X_test, y_train, y_test = train_test_split(\n",
" X,\n",
" y,\n",
" test_size=0.3,\n",
" random_state=233,\n",
")"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 19,
"outputs": [],
"source": [
"# train, validation, test\n",
"\n",
"X_train, X_, y_train, y_ = train_test_split(\n",
" X, y, test_size=0.3, random_state=233\n",
")\n",
"\n",
"X_val, X_test, y_val, y_test = train_test_split(\n",
" X_, y_, test_size=0.5, random_state=233\n",
")"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 20,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"X_train shape: (105, 4)\n",
"X_val shape: (22, 4)\n",
"X_test shape: (23, 4)\n",
"y_train shape: (105,)\n",
"y_val shape: (22,)\n",
"y_test shape: (23,)\n"
]
}
],
"source": [
"print(f\"X_train shape: {X_train.shape}\")\n",
"print(f\"X_val shape: {X_val.shape}\")\n",
"print(f\"X_test shape: {X_test.shape}\")\n",
"print(f\"y_train shape: {y_train.shape}\")\n",
"print(f\"y_val shape: {y_val.shape}\")\n",
"print(f\"y_test shape: {y_test.shape}\")"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "markdown",
"source": [
"## Grid Search\n"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
}
},
{
"cell_type": "code",
"execution_count": 21,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[ -63.76056336 182.20484712 32.45346758 70.87751298 351.51266014\n",
" -7.01893893 59.89221748 33.89847802 75.65454954 47.92124999]\n",
" [ 0.69419195 3.35562957 5.69461738 -152.93603272 187.21731051\n",
" -3.10092616 -2.3676087 -236.78609838 -22.06231977 -159.77767906]]\n"
]
}
],
"source": [
"from sklearn.datasets import make_classification\n",
"from sklearn.model_selection import GridSearchCV, train_test_split\n",
"from sklearn.pipeline import Pipeline\n",
"from sklearn.preprocessing import StandardScaler\n",
"from sklearn.svm import SVC\n",
"\n",
"X, y = make_classification(\n",
" n_samples=500,\n",
" n_classes=3,\n",
" n_features=10,\n",
" n_informative=6,\n",
" scale=None,\n",
" random_state=233,\n",
")\n",
"\n",
"print(X[:2])"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 22,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[0 0 1 0 2]\n"
]
}
],
"source": [
"print(y[:5])\n"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 23,
"outputs": [],
"source": [
"X_train, X_test, y_train, y_test = train_test_split(\n",
" X, y, test_size=0.25, random_state=233\n",
")"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 24,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Fitting 5 folds for each of 72 candidates, totalling 360 fits\n",
"[CV] END model__C=1, model__degree=3, model__gamma=0.001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=3, model__gamma=0.001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=3, model__gamma=0.001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=3, model__gamma=0.001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=3, model__gamma=0.001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=3, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=3, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=3, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=3, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=3, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=3, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=3, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=3, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=3, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=3, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=3, model__gamma=0.0001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=3, model__gamma=0.0001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=3, model__gamma=0.0001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=3, model__gamma=0.0001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=3, model__gamma=0.0001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=3, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=3, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=3, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=3, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=3, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=3, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=3, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=3, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=3, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=3, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=4, model__gamma=0.001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=4, model__gamma=0.001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=4, model__gamma=0.001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=4, model__gamma=0.001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=4, model__gamma=0.001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=4, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=4, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=4, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=4, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=4, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=4, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=4, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=4, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=4, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=4, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=4, model__gamma=0.0001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=4, model__gamma=0.0001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=4, model__gamma=0.0001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=4, model__gamma=0.0001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=4, model__gamma=0.0001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=4, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=4, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=4, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=4, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=4, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=4, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=4, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=4, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=4, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=4, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=5, model__gamma=0.001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=5, model__gamma=0.001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=5, model__gamma=0.001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=5, model__gamma=0.001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=5, model__gamma=0.001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=5, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=5, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=5, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=5, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=5, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=5, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=5, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=5, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=5, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=5, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=5, model__gamma=0.0001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=5, model__gamma=0.0001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=5, model__gamma=0.0001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=5, model__gamma=0.0001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=5, model__gamma=0.0001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=5, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=5, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=5, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=5, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=5, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=5, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=5, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=5, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=5, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1, model__degree=5, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=3, model__gamma=0.001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=3, model__gamma=0.001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=3, model__gamma=0.001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=3, model__gamma=0.001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=3, model__gamma=0.001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=3, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=3, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=3, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=3, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=3, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=3, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=3, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=3, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=3, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=3, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=3, model__gamma=0.0001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=3, model__gamma=0.0001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=3, model__gamma=0.0001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=3, model__gamma=0.0001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=3, model__gamma=0.0001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=3, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=3, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=3, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=3, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=3, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=3, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=3, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=3, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=3, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=3, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=4, model__gamma=0.001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=4, model__gamma=0.001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=4, model__gamma=0.001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=4, model__gamma=0.001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=4, model__gamma=0.001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=4, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=4, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=4, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=4, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=4, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=4, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=4, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=4, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=4, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=4, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=4, model__gamma=0.0001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=4, model__gamma=0.0001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=4, model__gamma=0.0001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=4, model__gamma=0.0001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=4, model__gamma=0.0001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=4, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=4, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=4, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=4, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=4, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=4, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=4, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=4, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=4, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=4, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=5, model__gamma=0.001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=5, model__gamma=0.001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=5, model__gamma=0.001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=5, model__gamma=0.001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=5, model__gamma=0.001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=5, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=5, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=5, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=5, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=5, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=5, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=5, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=5, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=5, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=5, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=5, model__gamma=0.0001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=5, model__gamma=0.0001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=5, model__gamma=0.0001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=5, model__gamma=0.0001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=5, model__gamma=0.0001, model__kernel=linear; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=5, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=5, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=5, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=5, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=5, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=5, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=5, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=5, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=5, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=10, model__degree=5, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=3, model__gamma=0.001, model__kernel=linear; total time= 0.2s\n",
"[CV] END model__C=100, model__degree=3, model__gamma=0.001, model__kernel=linear; total time= 0.2s\n",
"[CV] END model__C=100, model__degree=3, model__gamma=0.001, model__kernel=linear; total time= 0.3s\n",
"[CV] END model__C=100, model__degree=3, model__gamma=0.001, model__kernel=linear; total time= 0.2s\n",
"[CV] END model__C=100, model__degree=3, model__gamma=0.001, model__kernel=linear; total time= 0.4s\n",
"[CV] END model__C=100, model__degree=3, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=3, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=3, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=3, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=3, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=3, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=3, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=3, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=3, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=3, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=3, model__gamma=0.0001, model__kernel=linear; total time= 0.2s\n",
"[CV] END model__C=100, model__degree=3, model__gamma=0.0001, model__kernel=linear; total time= 0.2s\n",
"[CV] END model__C=100, model__degree=3, model__gamma=0.0001, model__kernel=linear; total time= 0.3s\n",
"[CV] END model__C=100, model__degree=3, model__gamma=0.0001, model__kernel=linear; total time= 0.2s\n",
"[CV] END model__C=100, model__degree=3, model__gamma=0.0001, model__kernel=linear; total time= 0.4s\n",
"[CV] END model__C=100, model__degree=3, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=3, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=3, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=3, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=3, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=3, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=3, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=3, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=3, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=3, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=4, model__gamma=0.001, model__kernel=linear; total time= 0.2s\n",
"[CV] END model__C=100, model__degree=4, model__gamma=0.001, model__kernel=linear; total time= 0.2s\n",
"[CV] END model__C=100, model__degree=4, model__gamma=0.001, model__kernel=linear; total time= 0.3s\n",
"[CV] END model__C=100, model__degree=4, model__gamma=0.001, model__kernel=linear; total time= 0.2s\n",
"[CV] END model__C=100, model__degree=4, model__gamma=0.001, model__kernel=linear; total time= 0.4s\n",
"[CV] END model__C=100, model__degree=4, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=4, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=4, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=4, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=4, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=4, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=4, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=4, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=4, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=4, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=4, model__gamma=0.0001, model__kernel=linear; total time= 0.2s\n",
"[CV] END model__C=100, model__degree=4, model__gamma=0.0001, model__kernel=linear; total time= 0.2s\n",
"[CV] END model__C=100, model__degree=4, model__gamma=0.0001, model__kernel=linear; total time= 0.3s\n",
"[CV] END model__C=100, model__degree=4, model__gamma=0.0001, model__kernel=linear; total time= 0.2s\n",
"[CV] END model__C=100, model__degree=4, model__gamma=0.0001, model__kernel=linear; total time= 0.4s\n",
"[CV] END model__C=100, model__degree=4, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=4, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=4, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=4, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=4, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=4, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=4, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=4, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=4, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=4, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=5, model__gamma=0.001, model__kernel=linear; total time= 0.2s\n",
"[CV] END model__C=100, model__degree=5, model__gamma=0.001, model__kernel=linear; total time= 0.2s\n",
"[CV] END model__C=100, model__degree=5, model__gamma=0.001, model__kernel=linear; total time= 0.3s\n",
"[CV] END model__C=100, model__degree=5, model__gamma=0.001, model__kernel=linear; total time= 0.2s\n",
"[CV] END model__C=100, model__degree=5, model__gamma=0.001, model__kernel=linear; total time= 0.4s\n",
"[CV] END model__C=100, model__degree=5, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=5, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=5, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=5, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=5, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=5, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=5, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=5, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=5, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=5, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=5, model__gamma=0.0001, model__kernel=linear; total time= 0.2s\n",
"[CV] END model__C=100, model__degree=5, model__gamma=0.0001, model__kernel=linear; total time= 0.2s\n",
"[CV] END model__C=100, model__degree=5, model__gamma=0.0001, model__kernel=linear; total time= 0.3s\n",
"[CV] END model__C=100, model__degree=5, model__gamma=0.0001, model__kernel=linear; total time= 0.2s\n",
"[CV] END model__C=100, model__degree=5, model__gamma=0.0001, model__kernel=linear; total time= 0.4s\n",
"[CV] END model__C=100, model__degree=5, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=5, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=5, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=5, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=5, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=5, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=5, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=5, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=5, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=100, model__degree=5, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=3, model__gamma=0.001, model__kernel=linear; total time= 1.7s\n",
"[CV] END model__C=1000, model__degree=3, model__gamma=0.001, model__kernel=linear; total time= 1.3s\n",
"[CV] END model__C=1000, model__degree=3, model__gamma=0.001, model__kernel=linear; total time= 2.3s\n",
"[CV] END model__C=1000, model__degree=3, model__gamma=0.001, model__kernel=linear; total time= 1.7s\n",
"[CV] END model__C=1000, model__degree=3, model__gamma=0.001, model__kernel=linear; total time= 2.0s\n",
"[CV] END model__C=1000, model__degree=3, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=3, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=3, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=3, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=3, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=3, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=3, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=3, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=3, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=3, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=3, model__gamma=0.0001, model__kernel=linear; total time= 1.5s\n",
"[CV] END model__C=1000, model__degree=3, model__gamma=0.0001, model__kernel=linear; total time= 1.2s\n",
"[CV] END model__C=1000, model__degree=3, model__gamma=0.0001, model__kernel=linear; total time= 2.2s\n",
"[CV] END model__C=1000, model__degree=3, model__gamma=0.0001, model__kernel=linear; total time= 2.0s\n",
"[CV] END model__C=1000, model__degree=3, model__gamma=0.0001, model__kernel=linear; total time= 2.5s\n",
"[CV] END model__C=1000, model__degree=3, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=3, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=3, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=3, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=3, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=3, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=3, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=3, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=3, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=3, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=4, model__gamma=0.001, model__kernel=linear; total time= 1.7s\n",
"[CV] END model__C=1000, model__degree=4, model__gamma=0.001, model__kernel=linear; total time= 1.3s\n",
"[CV] END model__C=1000, model__degree=4, model__gamma=0.001, model__kernel=linear; total time= 2.3s\n",
"[CV] END model__C=1000, model__degree=4, model__gamma=0.001, model__kernel=linear; total time= 1.8s\n",
"[CV] END model__C=1000, model__degree=4, model__gamma=0.001, model__kernel=linear; total time= 2.3s\n",
"[CV] END model__C=1000, model__degree=4, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=4, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=4, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=4, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=4, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=4, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=4, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=4, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=4, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=4, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=4, model__gamma=0.0001, model__kernel=linear; total time= 1.7s\n",
"[CV] END model__C=1000, model__degree=4, model__gamma=0.0001, model__kernel=linear; total time= 1.3s\n",
"[CV] END model__C=1000, model__degree=4, model__gamma=0.0001, model__kernel=linear; total time= 2.2s\n",
"[CV] END model__C=1000, model__degree=4, model__gamma=0.0001, model__kernel=linear; total time= 1.7s\n",
"[CV] END model__C=1000, model__degree=4, model__gamma=0.0001, model__kernel=linear; total time= 2.1s\n",
"[CV] END model__C=1000, model__degree=4, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=4, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=4, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=4, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=4, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=4, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=4, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=4, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=4, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=4, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=5, model__gamma=0.001, model__kernel=linear; total time= 1.6s\n",
"[CV] END model__C=1000, model__degree=5, model__gamma=0.001, model__kernel=linear; total time= 1.3s\n",
"[CV] END model__C=1000, model__degree=5, model__gamma=0.001, model__kernel=linear; total time= 2.2s\n",
"[CV] END model__C=1000, model__degree=5, model__gamma=0.001, model__kernel=linear; total time= 1.7s\n",
"[CV] END model__C=1000, model__degree=5, model__gamma=0.001, model__kernel=linear; total time= 2.0s\n",
"[CV] END model__C=1000, model__degree=5, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=5, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=5, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=5, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=5, model__gamma=0.001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=5, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=5, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=5, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=5, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=5, model__gamma=0.001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=5, model__gamma=0.0001, model__kernel=linear; total time= 1.6s\n",
"[CV] END model__C=1000, model__degree=5, model__gamma=0.0001, model__kernel=linear; total time= 1.3s\n",
"[CV] END model__C=1000, model__degree=5, model__gamma=0.0001, model__kernel=linear; total time= 2.3s\n",
"[CV] END model__C=1000, model__degree=5, model__gamma=0.0001, model__kernel=linear; total time= 1.7s\n",
"[CV] END model__C=1000, model__degree=5, model__gamma=0.0001, model__kernel=linear; total time= 2.1s\n",
"[CV] END model__C=1000, model__degree=5, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=5, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=5, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=5, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=5, model__gamma=0.0001, model__kernel=sigmoid; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=5, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=5, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=5, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=5, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n",
"[CV] END model__C=1000, model__degree=5, model__gamma=0.0001, model__kernel=rbf; total time= 0.0s\n"
]
},
{
"data": {
"text/plain": "GridSearchCV(cv=5,\n estimator=Pipeline(steps=[('scaler', StandardScaler()),\n ('model', SVC())]),\n param_grid={'model__C': [1, 10, 100, 1000],\n 'model__degree': [3, 4, 5],\n 'model__gamma': [0.001, 0.0001],\n 'model__kernel': ['linear', 'sigmoid', 'rbf']},\n verbose=2)"
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"\n",
"pipe = Pipeline(steps=[(\"scaler\", StandardScaler()), (\"model\", SVC())])\n",
"\n",
"param_grid = dict(\n",
" model__C=[1, 10, 100, 1000],\n",
" model__kernel=[\"linear\", \"sigmoid\", \"rbf\"],\n",
" model__gamma=[0.001, 0.0001],\n",
" model__degree=[3, 4, 5],\n",
")\n",
"\n",
"gscv = GridSearchCV(\n",
" pipe,\n",
" param_grid=param_grid,\n",
" cv=5,\n",
" verbose=2,\n",
")\n",
"gscv.fit(X_train, y_train)"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 25,
"outputs": [
{
"data": {
"text/plain": "Pipeline(steps=[('scaler', StandardScaler()),\n ('model', SVC(C=1000, gamma=0.001))])"
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"gscv.best_estimator_"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 26,
"outputs": [
{
"data": {
"text/plain": "0.768"
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"gscv.best_score_"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 27,
"outputs": [
{
"data": {
"text/plain": "{'model__C': 1000,\n 'model__degree': 3,\n 'model__gamma': 0.001,\n 'model__kernel': 'rbf'}"
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"gscv.best_params_"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 28,
"outputs": [
{
"data": {
"text/plain": "Pipeline(steps=[('scaler', StandardScaler()),\n ('model', SVC(C=1000, gamma=0.001))])"
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pipe.set_params(**gscv.best_params_)"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 29,
"outputs": [
{
"data": {
"text/plain": "Pipeline(steps=[('scaler', StandardScaler()),\n ('model', SVC(C=1000, gamma=0.001))])"
},
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pipe.fit(X_train, y_train)"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 30,
"outputs": [
{
"data": {
"text/plain": "0.792"
},
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pipe.score(X_test, y_test)"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "markdown",
"source": [
"## Pipeline"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
}
},
{
"cell_type": "code",
"execution_count": 21,
"outputs": [
{
"data": {
"text/plain": "Pipeline(steps=[('scaler', StandardScaler()), ('model', SVC())])"
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from sklearn.preprocessing import StandardScaler\n",
"from sklearn.svm import SVC\n",
"from sklearn.pipeline import make_pipeline\n",
"\n",
"pipe = Pipeline(steps=[(\"scaler\", StandardScaler()), (\"model\", SVC())])\n",
"pipe"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 22,
"outputs": [
{
"data": {
"text/plain": "Pipeline(steps=[('standardscaler', StandardScaler()), ('svc', SVC())])"
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pipe = make_pipeline(StandardScaler(), SVC())\n",
"pipe"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 23,
"outputs": [
{
"data": {
"text/plain": " feature1 feature2 feature3 feature4 feature5 feature6 \\\n0 -63.760563 182.204847 32.453468 70.877513 351.512660 -7.018939 \n1 0.694192 3.355630 5.694617 -152.936033 187.217311 -3.100926 \n2 -5.393549 184.011971 -38.685624 -119.911350 75.420933 -3.545307 \n3 -6.519019 39.696925 33.622070 -103.923978 97.519965 -0.220483 \n4 -29.057685 65.604430 72.474747 34.571492 155.318598 -2.501579 \n\n feature7 feature8 feature9 feature10 y \n0 59.892217 33.898478 75.654550 47.921250 0 \n1 -2.367609 -236.786098 -22.062320 -159.777679 0 \n2 78.284389 71.452933 -46.133634 -23.066554 1 \n3 28.255805 -90.692126 -51.072717 6.297472 0 \n4 -98.117314 209.305727 -113.667228 24.212523 2 ",
"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>feature1</th>\n <th>feature2</th>\n <th>feature3</th>\n <th>feature4</th>\n <th>feature5</th>\n <th>feature6</th>\n <th>feature7</th>\n <th>feature8</th>\n <th>feature9</th>\n <th>feature10</th>\n <th>y</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>-63.760563</td>\n <td>182.204847</td>\n <td>32.453468</td>\n <td>70.877513</td>\n <td>351.512660</td>\n <td>-7.018939</td>\n <td>59.892217</td>\n <td>33.898478</td>\n <td>75.654550</td>\n <td>47.921250</td>\n <td>0</td>\n </tr>\n <tr>\n <th>1</th>\n <td>0.694192</td>\n <td>3.355630</td>\n <td>5.694617</td>\n <td>-152.936033</td>\n <td>187.217311</td>\n <td>-3.100926</td>\n <td>-2.367609</td>\n <td>-236.786098</td>\n <td>-22.062320</td>\n <td>-159.777679</td>\n <td>0</td>\n </tr>\n <tr>\n <th>2</th>\n <td>-5.393549</td>\n <td>184.011971</td>\n <td>-38.685624</td>\n <td>-119.911350</td>\n <td>75.420933</td>\n <td>-3.545307</td>\n <td>78.284389</td>\n <td>71.452933</td>\n <td>-46.133634</td>\n <td>-23.066554</td>\n <td>1</td>\n </tr>\n <tr>\n <th>3</th>\n <td>-6.519019</td>\n <td>39.696925</td>\n <td>33.622070</td>\n <td>-103.923978</td>\n <td>97.519965</td>\n <td>-0.220483</td>\n <td>28.255805</td>\n <td>-90.692126</td>\n <td>-51.072717</td>\n <td>6.297472</td>\n <td>0</td>\n </tr>\n <tr>\n <th>4</th>\n <td>-29.057685</td>\n <td>65.604430</td>\n <td>72.474747</td>\n <td>34.571492</td>\n <td>155.318598</td>\n <td>-2.501579</td>\n <td>-98.117314</td>\n <td>209.305727</td>\n <td>-113.667228</td>\n <td>24.212523</td>\n <td>2</td>\n </tr>\n </tbody>\n</table>\n</div>"
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import pandas as pd\n",
"from sklearn.datasets import make_classification\n",
"\n",
"X, y = make_classification(\n",
" n_samples=500,\n",
" n_classes=3,\n",
" n_features=10,\n",
" n_informative=6,\n",
" scale=None,\n",
" random_state=233,\n",
")\n",
"\n",
"data = pd.DataFrame(\n",
" X,\n",
" columns=[f\"feature{n + 1}\" for n in range(0, 10)],\n",
")\n",
"data[\"y\"] = y\n",
"data.head()"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 24,
"outputs": [
{
"data": {
"text/plain": "Pipeline(steps=[('preprocessor',\n ColumnTransformer(transformers=[('odd_features_with_standardscaler',\n StandardScaler(),\n ['feature3', 'feature5',\n 'feature7', 'feature9']),\n ('even_features_with_mimaxscaler',\n MinMaxScaler(),\n ['feature2', 'feature4',\n 'feature6', 'feature8']),\n ('passthrough_feature',\n 'passthrough',\n ['feature1', 'feature10'])])),\n ('model', SVC())])"
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from sklearn.compose import ColumnTransformer\n",
"from sklearn.preprocessing import StandardScaler, MinMaxScaler\n",
"\n",
"preprocessor = ColumnTransformer(\n",
" transformers=[\n",
" (\"odd_features_with_standardscaler\", StandardScaler(), [f\"feature{n}\" for n in [3, 5, 7, 9]]),\n",
" (\"even_features_with_mimaxscaler\", MinMaxScaler(), [f\"feature{n}\" for n in [2, 4, 6, 8]]),\n",
" (\"passthrough_feature\", \"passthrough\", [\"feature1\", \"feature10\"]),\n",
" ],\n",
" remainder=\"drop\",\n",
")\n",
"\n",
"\n",
"pipe = Pipeline(\n",
" steps=[\n",
" (\"preprocessor\", preprocessor),\n",
" (\"model\", SVC()),\n",
" ]\n",
")\n",
"pipe.fit(data, data[\"y\"])"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "markdown",
"source": [
"## Persistence"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
}
},
{
"cell_type": "code",
"execution_count": 31,
"outputs": [
{
"data": {
"text/plain": "[PosixPath('/var/folders/0t/s0c95rbs6ds7w_b0d471p0kc0000gn/T/tmpeuwitk1w/LinearRegression.pkl')]"
},
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"\n",
"import pickle\n",
"import pathlib\n",
"import tempfile\n",
"\n",
"from sklearn.linear_model import LinearRegression\n",
"\n",
"root = pathlib.Path(tempfile.mkdtemp())\n",
"fpath = root.joinpath(\"LinearRegression.pkl\")\n",
"\n",
"regressor = LinearRegression()\n",
"\n",
"\n",
"with open(fpath, \"wb\") as file:\n",
" pickle.dump(regressor, file)\n",
"\n",
"files = list(root.iterdir())\n",
"files"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 34,
"outputs": [
{
"data": {
"text/plain": "{'copy_X': True,\n 'fit_intercept': True,\n 'n_jobs': None,\n 'normalize': 'deprecated',\n 'positive': False}"
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"file = open(fpath, \"rb\")\n",
"model = pickle.load(file)\n",
"file.close()\n",
"\n",
"model.get_params()"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 37,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[PosixPath('/var/folders/0t/s0c95rbs6ds7w_b0d471p0kc0000gn/T/tmpeuwitk1w/SVC.joblib'), PosixPath('/var/folders/0t/s0c95rbs6ds7w_b0d471p0kc0000gn/T/tmpeuwitk1w/LinearRegression.pkl')]\n"
]
}
],
"source": [
"import joblib\n",
"from sklearn.svm import SVC\n",
"\n",
"classifier = SVC()\n",
"fpath = root.joinpath(\"SVC.joblib\")\n",
"\n",
"joblib.dump(classifier, fpath)\n",
"files = list(root.iterdir())\n",
"print(files)"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 38,
"outputs": [
{
"data": {
"text/plain": "{'C': 1.0,\n 'break_ties': False,\n 'cache_size': 200,\n 'class_weight': None,\n 'coef0': 0.0,\n 'decision_function_shape': 'ovr',\n 'degree': 3,\n 'gamma': 'scale',\n 'kernel': 'rbf',\n 'max_iter': -1,\n 'probability': False,\n 'random_state': None,\n 'shrinking': True,\n 'tol': 0.001,\n 'verbose': False}"
},
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"model = joblib.load(fpath)\n",
"model.get_params()"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 0
}