Skip to content

Commit

Permalink
Change preprocessing of categorical attributes in Titanic exercise, f…
Browse files Browse the repository at this point in the history
…ixes ageron#488
  • Loading branch information
ageron committed Oct 20, 2021
1 parent dcd1eab commit ce94de1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions 03_classification.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3111,7 +3111,7 @@
"metadata": {},
"outputs": [],
"source": [
"from sklearn.preprocessing import OrdinalEncoder, OneHotEncoder"
"from sklearn.preprocessing import OneHotEncoder"
]
},
{
Expand All @@ -3121,7 +3121,6 @@
"outputs": [],
"source": [
"cat_pipeline = Pipeline([\n",
" (\"ordinal_encoder\", OrdinalEncoder()), \n",
" (\"imputer\", SimpleImputer(strategy=\"most_frequent\")),\n",
" (\"cat_encoder\", OneHotEncoder(sparse=False)),\n",
" ])"
Expand Down Expand Up @@ -3187,7 +3186,8 @@
}
],
"source": [
"X_train = preprocess_pipeline.fit_transform(train_data)\n",
"X_train = preprocess_pipeline.fit_transform(\n",
" train_data[num_attribs + cat_attribs])\n",
"X_train"
]
},
Expand Down Expand Up @@ -3250,7 +3250,7 @@
"metadata": {},
"outputs": [],
"source": [
"X_test = preprocess_pipeline.transform(test_data)\n",
"X_test = preprocess_pipeline.transform(test_data[num_attribs + cat_attribs])\n",
"y_pred = forest_clf.predict(X_test)"
]
},
Expand Down Expand Up @@ -4588,7 +4588,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.10"
"version": "3.8.12"
},
"nav_menu": {},
"toc": {
Expand Down

0 comments on commit ce94de1

Please sign in to comment.