Skip to content

Commit

Permalink
bugfix in sklearn svr notebook, fixes #48
Browse files Browse the repository at this point in the history
  • Loading branch information
claesenm committed Jul 15, 2015
1 parent 4662b9c commit 66f5e15
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 38 deletions.
31 changes: 15 additions & 16 deletions docs/notebooks/notebooks/sklearn-svr.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ for support vector regression, more specifically:
import optunity
import optunity.metrics
import sklearn.svm
import matplotlib.pylab as plt
import time
We start by creating the data set. We use sklearn's diabetes data.

.. code:: python
Expand Down Expand Up @@ -70,7 +68,7 @@ estimate of MSE for an SVR with default hyperparameters.
.. parsed-literal::
6056.311654865084
6190.481497665955
Expand Down Expand Up @@ -112,16 +110,16 @@ cross-validation.
.. parsed-literal::
optimal hyperparameters: {'C': 8103.600260416671, 'coef0': 0.5978059895833331, 'degree': 4.797399399165802}
optimal hyperparameters: {'C': 19755.083174237032, 'coef0': 0.4450483090495349, 'degree': 4.6829006570233025}
optimal hyperparameters: {'C': 8680.403645833334, 'coef0': 0.47259114583333317, 'degree': 3.0486328125000006}
optimal hyperparameters: {'C': 12078.673881034498, 'coef0': 0.5011052085197018, 'degree': 4.60890281463418}
optimal hyperparameters: {'C': 14391.165364583334, 'coef0': 0.17313151041666666, 'degree': 2.35826171875}
optimal hyperparameters: {'C': 11713.456382191061, 'coef0': 0.49836486667796476, 'degree': 4.616077904035152}
.. parsed-literal::
3122.5387612208156
3047.035965991627
Expand Down Expand Up @@ -162,16 +160,16 @@ twice-iterated 5-fold cross-validation.
.. parsed-literal::
optimal hyperparameters: {'C': 81.98731244487078, 'gamma': 4.895475395394894}
optimal hyperparameters: {'C': 52.067311507783465, 'gamma': 6.5244315086089815}
optimal hyperparameters: {'C': 26.993648162210402, 'gamma': 25.997204804202134}
optimal hyperparameters: {'C': 21.654003906250026, 'gamma': 16.536188056152554}
optimal hyperparameters: {'C': 80.89867187499999, 'gamma': 3.2346692538501784}
optimal hyperparameters: {'C': 19.35431640625002, 'gamma': 22.083848774716085}
.. parsed-literal::
2982.6835697931674
2990.8572696483493
Expand Down Expand Up @@ -244,17 +242,18 @@ hyperparameterization.
.. parsed-literal::
optimal hyperparameters: {'kernel': 'rbf', 'C': 36.396896096116805, 'gamma': 10.015489219932745}
optimal hyperparameters: {'kernel': 'rbf', 'C': 25.6858037455125, 'gamma': 17.48771066406458}
optimal hyperparameters: {'kernel': 'rbf', 'C': 93.31245007796964, 'gamma': 7.082799132257288}
optimal hyperparameters: {'kernel': 'rbf', 'C': 33.70116043112164, 'gamma': 16.32317353448437}
optimal hyperparameters: {'kernel': 'rbf', 'C': 58.11404170763237, 'gamma': 26.45349823062099}
optimal hyperparameters: {'kernel': 'poly', 'C': 14964.421875843143, 'coef0': 0.5127175861493205, 'degree': 4.045210787998622}
.. parsed-literal::
3001.3258583571483
3107.625560844859
Looks like an RBF kernel was indeed the best choice!
It looks like the RBF and polynomial kernel are competitive for this
problem.
42 changes: 20 additions & 22 deletions notebooks/sklearn-svr.ipynb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"metadata": {
"name": "",
"signature": "sha256:ffffcd755c9a4dc22df222af2da80e7fa04f94ea53fc9391ecb8f742d370b57d"
"signature": "sha256:622e6696890c825b50112f76f68f1961aab9e55f39eb0e5b47e7352d51d29fec"
},
"nbformat": 3,
"nbformat_minor": 0,
Expand Down Expand Up @@ -37,9 +37,7 @@
"import itertools\n",
"import optunity\n",
"import optunity.metrics\n",
"import sklearn.svm\n",
"import matplotlib.pylab as plt\n",
"import time"
"import sklearn.svm"
],
"language": "python",
"metadata": {},
Expand Down Expand Up @@ -131,7 +129,7 @@
"output_type": "pyout",
"prompt_number": 4,
"text": [
"6056.311654865084"
"6190.481497665955"
]
}
],
Expand Down Expand Up @@ -194,16 +192,16 @@
"output_type": "stream",
"stream": "stdout",
"text": [
"optimal hyperparameters: {'C': 8103.600260416671, 'coef0': 0.5978059895833331, 'degree': 4.797399399165802}\n",
"optimal hyperparameters: {'C': 19755.083174237032, 'coef0': 0.4450483090495349, 'degree': 4.6829006570233025}"
"optimal hyperparameters: {'C': 12078.673881034498, 'coef0': 0.5011052085197018, 'degree': 4.60890281463418}\n",
"optimal hyperparameters: {'C': 14391.165364583334, 'coef0': 0.17313151041666666, 'degree': 2.35826171875}"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n",
"optimal hyperparameters: {'C': 8680.403645833334, 'coef0': 0.47259114583333317, 'degree': 3.0486328125000006}"
"optimal hyperparameters: {'C': 11713.456382191061, 'coef0': 0.49836486667796476, 'degree': 4.616077904035152}"
]
},
{
Expand All @@ -218,7 +216,7 @@
"output_type": "pyout",
"prompt_number": 6,
"text": [
"3122.5387612208156"
"3047.035965991627"
]
}
],
Expand Down Expand Up @@ -281,16 +279,16 @@
"output_type": "stream",
"stream": "stdout",
"text": [
"optimal hyperparameters: {'C': 81.98731244487078, 'gamma': 4.895475395394894}\n",
"optimal hyperparameters: {'C': 52.067311507783465, 'gamma': 6.5244315086089815}"
"optimal hyperparameters: {'C': 21.654003906250026, 'gamma': 16.536188056152554}\n",
"optimal hyperparameters: {'C': 80.89867187499999, 'gamma': 3.2346692538501784}"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n",
"optimal hyperparameters: {'C': 26.993648162210402, 'gamma': 25.997204804202134}"
"optimal hyperparameters: {'C': 19.35431640625002, 'gamma': 22.083848774716085}"
]
},
{
Expand All @@ -305,7 +303,7 @@
"output_type": "pyout",
"prompt_number": 8,
"text": [
"2982.6835697931674"
"2990.8572696483493"
]
}
],
Expand Down Expand Up @@ -348,7 +346,7 @@
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 21
"prompt_number": 9
},
{
"cell_type": "markdown",
Expand Down Expand Up @@ -398,7 +396,7 @@
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 26
"prompt_number": 10
},
{
"cell_type": "markdown",
Expand All @@ -420,16 +418,16 @@
"output_type": "stream",
"stream": "stdout",
"text": [
"optimal hyperparameters: {'kernel': 'rbf', 'C': 36.396896096116805, 'gamma': 10.015489219932745}\n",
"optimal hyperparameters: {'kernel': 'rbf', 'C': 25.6858037455125, 'gamma': 17.48771066406458}"
"optimal hyperparameters: {'kernel': 'rbf', 'C': 33.70116043112164, 'gamma': 16.32317353448437}\n",
"optimal hyperparameters: {'kernel': 'rbf', 'C': 58.11404170763237, 'gamma': 26.45349823062099}"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n",
"optimal hyperparameters: {'kernel': 'rbf', 'C': 93.31245007796964, 'gamma': 7.082799132257288}"
"optimal hyperparameters: {'kernel': 'poly', 'C': 14964.421875843143, 'coef0': 0.5127175861493205, 'degree': 4.045210787998622}"
]
},
{
Expand All @@ -442,19 +440,19 @@
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 27,
"prompt_number": 13,
"text": [
"3001.3258583571483"
"3107.625560844859"
]
}
],
"prompt_number": 27
"prompt_number": 13
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Looks like an RBF kernel was indeed the best choice!"
"It looks like the RBF and polynomial kernel are competitive for this problem."
]
}
],
Expand Down

0 comments on commit 66f5e15

Please sign in to comment.