@@ -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