10BC0 Added copy argument · scikit-learn/scikit-learn@7319923 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7319923

Browse files
Added copy argument
1 parent 7edcfce commit 7319923

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

sklearn/preprocessing/data.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,6 +1723,9 @@ class OneHotEncoder(BaseEstimator, TransformerMixin):
17231723
Whether to raise an error or ignore if a unknown categorical feature is
17241724
present during transform.
17251725
1726+
copy : bool, default=True
1727+
If unset, `X` maybe modified in space.
1728+
17261729
Attributes
17271730
----------
17281731
label_encoders_ : list of size n_features.
@@ -1757,13 +1760,14 @@ class OneHotEncoder(BaseEstimator, TransformerMixin):
17571760

17581761
def __init__(self, values='auto', categorical_features="all",
17591762
n_values=None, dtype=np.float64, sparse=True,
1760-
handle_unknown='error'):
1763+
handle_unknown='error', copy=True):
17611764
self.values = values
17621765
self.categorical_features = categorical_features
17631766
self.dtype = dtype
17641767
self.sparse = sparse
17651768
self.handle_unknown = handle_unknown
17661769
self.n_values = n_values
1770+
self.copy = copy
17671771

17681772
def fit(self, X, y=None):
17691773
"""Fit the CategoricalEncoder to X.
@@ -1778,7 +1782,7 @@ def fit(self, X, y=None):
17781782
self
17791783
"""
17801784

1781-
X = check_array(X, dtype=np.object, accept_sparse='csc')
1785+
X = check_array(X, dtype=np.object, accept_sparse='csc', copy=self.copy)
17821786
n_samples, n_features = X.shape
17831787

17841788
_apply_selected(X, self._fit, dtype=self.dtype,

0 commit comments

Comments
 (0)
0