Skip to content

Commit

Permalink
Fixing errors related to sklearn.model_selection
Browse files Browse the repository at this point in the history
  • Loading branch information
hereismari committed Dec 13, 2017
1 parent 101043b commit 8dd0876
Showing 1 changed file with 41 additions and 44 deletions.
85 changes: 41 additions & 44 deletions doc/notebooks/Using lime for regression.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,28 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.datasets import load_boston\n",
"import sklearn.ensemble\n",
"import sklearn.model_selection\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"boston = load_boston()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -35,30 +32,30 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"train, test, labels_train, labels_test = sklearn.model_selection.train_test_split(boston.data, boston.target, train_size=0.80)\n"
"train, test, labels_train, labels_test = sklearn.model_selection.train_test_split(boston.data, boston.target, train_size=0.80, test_size=0.20)\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"RandomForestRegressor(bootstrap=True, criterion='mse', max_depth=None,\n",
" max_features='auto', max_leaf_nodes=None,\n",
" min_impurity_split=1e-07, min_samples_leaf=1,\n",
" min_samples_split=2, min_weight_fraction_leaf=0.0,\n",
" n_estimators=1000, n_jobs=1, oob_score=False, random_state=None,\n",
" verbose=0, warm_start=False)"
" min_impurity_decrease=0.0, min_impurity_split=None,\n",
" min_samples_leaf=1, min_samples_split=2,\n",
" min_weight_fraction_leaf=0.0, n_estimators=1000, n_jobs=1,\n",
" oob_score=False, random_state=None, verbose=0, warm_start=False)"
]
},
"execution_count": 5,
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -69,14 +66,14 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 19,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"('Random Forest MSError', 17.349331324117653)\n"
"('Random Forest MSError', 12.492700792156878)\n"
]
}
],
Expand All @@ -86,14 +83,14 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 20,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"('MSError when predicting the mean', 79.186326166360075)\n"
"('MSError when predicting the mean', 101.94960262930775)\n"
]
}
],
Expand All @@ -103,7 +100,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -112,7 +109,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -122,7 +119,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 23,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -131,16 +128,16 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 24,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Intercept 23.9047475063\n",
"Prediction_local [ 22.32579479]\n",
"Right: 23.1073\n"
"Intercept 23.3472933614\n",
"Prediction_local [ 22.26816652]\n",
"Right: 22.0623\n"
]
}
],
Expand All @@ -151,7 +148,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 25,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -35959,25 +35956,25 @@
"/***/ })\n",
"/******/ ]);\n",
"//# sourceMappingURL=bundle.js.map </script></head><body>\n",
" <div class=\"lime top_div\" id=\"top_div3DYALDXEHA3EFUR\"></div>\n",
" <div class=\"lime top_div\" id=\"top_divUHORLQZYDYE90XA\"></div>\n",
" \n",
" <script>\n",
" var top_div = d3.select('#top_div3DYALDXEHA3EFUR').classed('lime top_div', true);\n",
" var top_div = d3.select('#top_divUHORLQZYDYE90XA').classed('lime top_div', true);\n",
" \n",
" \n",
" var pp_div = top_div.append('div')\n",
" .classed('lime predicted_value', true);\n",
" var pp_svg = pp_div.append('svg').style('width', '100%');\n",
" var pp = new lime.PredictedValue(pp_svg, 23.10730000000004, 8.401499999999976, 48.1053000000001);\n",
" var pp = new lime.PredictedValue(pp_svg, 22.062300000000018, 10.031499999999957, 45.930800000000026);\n",
" \n",
" var exp_div;\n",
" var exp = new lime.Explanation([\"negative\", \"positive\"]);\n",
" \n",
" exp_div = top_div.append('div').classed('lime explanation', true);\n",
" exp.show([[\"6.99 < LSTAT <= 11.43\", 1.7571320048618118], [\"6.21 < RM <= 6.62\", -1.5638211582388033], [\"NOX > 0.62\", -0.7738437298911042], [\"19.10 < PTRATIO <= 20.20\", -0.607561126946643], [\"2.08 < DIS <= 3.17\", -0.39085870918058263]], 1, exp_div);\n",
" exp.show([[\"7.43 < LSTAT <= 11.73\", 1.6485568658614111], [\"6.18 < RM <= 6.57\", -1.5185815542882575], [\"284.00 < TAX <= 341.00\", -0.46847722088708765], [\"0.27 < CRIM <= 4.28\", -0.39482132673497322], [\"5.81 < INDUS <= 9.90\", -0.34580360269472482]], 1, exp_div);\n",
" \n",
" var raw_div = top_div.append('div');\n",
" exp.show_raw_tabular([[\"LSTAT\", \"7.79\", 1.7571320048618118], [\"RM\", \"6.40\", -1.5638211582388033], [\"NOX\", \"0.77\", -0.7738437298911042], [\"PTRATIO\", \"20.20\", -0.607561126946643], [\"DIS\", \"2.52\", -0.39085870918058263]], 1, raw_div);\n",
" exp.show_raw_tabular([[\"LSTAT\", \"10.36\", 1.6485568658614111], [\"RM\", \"6.38\", -1.5185815542882575], [\"TAX\", \"304.00\", -0.46847722088708765], [\"CRIM\", \"0.40\", -0.39482132673497322], [\"INDUS\", \"9.90\", -0.34580360269472482]], 1, raw_div);\n",
" \n",
" </script>\n",
" </body></html>"
Expand All @@ -35996,20 +35993,20 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 26,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[('6.99 < LSTAT <= 11.43', 1.7571320048618118),\n",
" ('6.21 < RM <= 6.62', -1.5638211582388033),\n",
" ('NOX > 0.62', -0.77384372989110417),\n",
" ('19.10 < PTRATIO <= 20.20', -0.60756112694664299),\n",
" ('2.08 < DIS <= 3.17', -0.39085870918058263)]"
"[('7.43 < LSTAT <= 11.73', 1.6485568658614111),\n",
" ('6.18 < RM <= 6.57', -1.5185815542882575),\n",
" ('284.00 < TAX <= 341.00', -0.46847722088708765),\n",
" ('0.27 < CRIM <= 4.28', -0.39482132673497322),\n",
" ('5.81 < INDUS <= 9.90', -0.34580360269472482)]"
]
},
"execution_count": 13,
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -36021,9 +36018,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "lime-reg",
"display_name": "Python 2",
"language": "python",
"name": "lime-reg"
"name": "python2"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -36035,7 +36032,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.13"
"version": "2.7.12"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 8dd0876

Please sign in to comment.