Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
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
33 changes: 19 additions & 14 deletions sklearn/preprocessing/_encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def fit(self, X, y=None):

Parameters
----------
X : array-like, shape [n_samples, n_features]
X : array-like of shape (n_samples, n_features)
The data to determine the categories of each feature.

y : None
Expand All @@ -431,7 +431,7 @@ def fit_transform(self, X, y=None):

Parameters
----------
X : array-like, shape [n_samples, n_features]
X : array-like of shape (n_samples, n_features)
The data to encode.

y : None
Expand All @@ -440,8 +440,10 @@ def fit_transform(self, X, y=None):

Returns
-------
X_out : sparse matrix if sparse=True else a 2-d array
Transformed input.
X_out : {ndarray, sparse matrix} of shape \
(n_samples, n_encoded_features)
Transformed input. If `sparse=True`, a sparse matrix will be
returned.
"""
self._validate_keywords()
return super().fit_transform(X, y)
Expand All @@ -452,13 +454,15 @@ def transform(self, X):

Parameters
----------
X : array-like, shape [n_samples, n_features]
X : array-like of shape (n_samples, n_features)
The data to encode.

Returns
-------
X_out : sparse matrix if sparse=True else a 2-d array
Transformed input.
X_out : {ndarray, sparse matrix} of shape \
(n_samples, n_encoded_features)
Transformed input. If `sparse=True`, a sparse matrix will be
returned.
"""
check_is_fitted(self)
# validation of X happens in _check_X called by _transform
Expand Down Expand Up @@ -522,12 +526,13 @@ def inverse_transform(self, X):

Parameters
----------
X : array-like or sparse matrix, shape [n_samples, n_encoded_features]
X : {array-like, sparse matrix} of shape \
(n_samples, n_encoded_features)
The transformed data.

Returns
-------
X_tr : array-like, shape [n_samples, n_features]
X_tr : ndarray of shape (n_samples, n_features)
Inverse transformed array.
"""
check_is_fitted(self)
Expand Down Expand Up @@ -745,7 +750,7 @@ def fit(self, X, y=None):

Parameters
----------
X : array-like, shape [n_samples, n_features]
X : array-like of shape (n_samples, n_features)
The data to determine the categories of each feature.

y : None
Expand Down Expand Up @@ -814,12 +819,12 @@ def transform(self, X):

Parameters
----------
X : array-like, shape [n_samples, n_features]
X : array-like of shape (n_samples, n_features)
The data to encode.

Returns
-------
X_out : sparse matrix or a 2-d array
X_out : ndarray of shape (n_samples, n_features)
Transformed input.
"""
X_int, X_mask = self._transform(X, handle_unknown=self.handle_unknown,
Expand All @@ -841,12 +846,12 @@ def inverse_transform(self, X):

Parameters
----------
X : array-like or sparse matrix, shape [n_samples, n_encoded_features]
X : {array-like, sparse matrix} of shape (n_samples, n_features)
The transformed data.

Returns
-------
X_tr : array-like, shape [n_samples, n_features]
X_tr : ndarray of shape (n_samples, n_features)
Inverse transformed array.
"""
check_is_fitted(self)
Expand Down