Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename OneHotEncoder option sparse to sparse_output #456

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion learntools/ml_intermediate/ex3.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class OneHot(CodingProblem):
"`X_valid[low_cardinality_cols]`, respectively.")
_solution = CS(
"""# Apply one-hot encoder to each column with categorical data
OH_encoder = OneHotEncoder(handle_unknown='ignore', sparse=False)
OH_encoder = OneHotEncoder(handle_unknown='ignore', sparse_output=False)
OH_cols_train = pd.DataFrame(OH_encoder.fit_transform(X_train[low_cardinality_cols]))
OH_cols_valid = pd.DataFrame(OH_encoder.transform(X_valid[low_cardinality_cols]))

Expand Down
4 changes: 2 additions & 2 deletions learntools/time_series/ex3.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class Q4(EqualityCheckProblem): # Create holiday features
```python
from sklearn.preprocessing import OneHotEncoder

ohe = OneHotEncoder(sparse=False)
ohe = OneHotEncoder(sparse_output=False)

X_holidays = pd.DataFrame(
____,
Expand All @@ -134,7 +134,7 @@ class Q4(EqualityCheckProblem): # Create holiday features
# Scikit-learn solution
from sklearn.preprocessing import OneHotEncoder

ohe = OneHotEncoder(sparse=False)
ohe = OneHotEncoder(sparse_output=False)

X_holidays = pd.DataFrame(
ohe.fit_transform(holidays),
Expand Down
2 changes: 1 addition & 1 deletion notebooks/deep_learning_intro/raw/ex3.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"preprocessor = make_column_transformer(\n",
" (StandardScaler(),\n",
" make_column_selector(dtype_include=np.number)),\n",
" (OneHotEncoder(sparse=False),\n",
" (OneHotEncoder(sparse_output=False),\n",
" make_column_selector(dtype_include=object)),\n",
")\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion notebooks/ml_intermediate/raw/ex3.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@
"source": [
"#%%RM_IF(PROD)%%\n",
"# Apply one-hot encoder to each column with categorical data\n",
"OH_encoder = OneHotEncoder(handle_unknown='ignore', sparse=False)\n",
"OH_encoder = OneHotEncoder(handle_unknown='ignore', sparse_output=False)\n",
"OH_cols_train = pd.DataFrame(OH_encoder.fit_transform(X_train[low_cardinality_cols]))\n",
"OH_cols_valid = pd.DataFrame(OH_encoder.transform(X_valid[low_cardinality_cols]))\n",
"\n",
Expand Down
4 changes: 2 additions & 2 deletions notebooks/ml_intermediate/raw/tut3.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
"\n",
"We use the [`OneHotEncoder`](https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.OneHotEncoder.html) class from scikit-learn to get one-hot encodings. There are a number of parameters that can be used to customize its behavior. \n",
"- We set `handle_unknown='ignore'` to avoid errors when the validation data contains classes that aren't represented in the training data, and\n",
"- setting `sparse=False` ensures that the encoded columns are returned as a numpy array (instead of a sparse matrix).\n",
"- setting `sparse_output=False` ensures that the encoded columns are returned as a numpy array (instead of a sparse matrix).\n",
"\n",
"To use the encoder, we supply only the categorical columns that we want to be one-hot encoded. For instance, to encode the training data, we supply `X_train[object_cols]`. (`object_cols` in the code cell below is a list of the column names with categorical data, and so `X_train[object_cols]` contains all of the categorical data in the training set.)"
]
Expand All @@ -238,7 +238,7 @@
"from sklearn.preprocessing import OneHotEncoder\n",
"\n",
"# Apply one-hot encoder to each column with categorical data\n",
"OH_encoder = OneHotEncoder(handle_unknown='ignore', sparse=False)\n",
"OH_encoder = OneHotEncoder(handle_unknown='ignore', sparse_output=False)\n",
"OH_cols_train = pd.DataFrame(OH_encoder.fit_transform(X_train[object_cols]))\n",
"OH_cols_valid = pd.DataFrame(OH_encoder.transform(X_valid[object_cols]))\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion notebooks/time_series/raw/ex3.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@
"# Scikit-learn solution\n",
"from sklearn.preprocessing import OneHotEncoder\n",
"\n",
"ohe = OneHotEncoder(sparse=False)\n",
"ohe = OneHotEncoder(sparse_output=False)\n",
"\n",
"X_holidays = pd.DataFrame(\n",
" ohe.fit_transform(holidays),\n",
Expand Down