Make notebook code match book examples more closely in chapter 2
parent
c226f328d3
commit
88acd2b4b9
|
@ -1154,16 +1154,12 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 69,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": true
|
||||||
"deletable": true,
|
|
||||||
"editable": true
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"from sklearn.pipeline import FeatureUnion\n",
|
|
||||||
"\n",
|
|
||||||
"num_attribs = list(housing_num)\n",
|
"num_attribs = list(housing_num)\n",
|
||||||
"cat_attribs = [\"ocean_proximity\"]\n",
|
"cat_attribs = [\"ocean_proximity\"]\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
@ -1177,7 +1173,20 @@
|
||||||
"cat_pipeline = Pipeline([\n",
|
"cat_pipeline = Pipeline([\n",
|
||||||
" ('selector', DataFrameSelector(cat_attribs)),\n",
|
" ('selector', DataFrameSelector(cat_attribs)),\n",
|
||||||
" ('label_binarizer', LabelBinarizer()),\n",
|
" ('label_binarizer', LabelBinarizer()),\n",
|
||||||
" ])\n",
|
" ])"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 69,
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": false,
|
||||||
|
"deletable": true,
|
||||||
|
"editable": true
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"from sklearn.pipeline import FeatureUnion\n",
|
||||||
"\n",
|
"\n",
|
||||||
"full_pipeline = FeatureUnion(transformer_list=[\n",
|
"full_pipeline = FeatureUnion(transformer_list=[\n",
|
||||||
" (\"num_pipeline\", num_pipeline),\n",
|
" (\"num_pipeline\", num_pipeline),\n",
|
||||||
|
@ -1219,7 +1228,7 @@
|
||||||
"editable": true
|
"editable": true
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"# Prepare the data for Machine Learning algorithms"
|
"# Select and train a model "
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue