Skip to content

DOC Improve consistency of inverse_transform return name #31135

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

Merged
Merged
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
4 changes: 2 additions & 2 deletions sklearn/cluster/_feature_agglomeration.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ def inverse_transform(self, X):

Returns
-------
X : ndarray of shape (n_samples, n_features) or (n_features,)
A vector of size `n_samples` with the values of `Xred` assigned to
X_original : ndarray of shape (n_samples, n_features) or (n_features,)
A vector of size `n_samples` with the values of `X` assigned to
each of the cluster of samples.
"""
check_is_fitted(self)
Expand Down
4 changes: 2 additions & 2 deletions sklearn/cross_decomposition/_pls.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,10 +419,10 @@ def inverse_transform(self, X, y=None):
Returns
-------
X_reconstructed : ndarray of shape (n_samples, n_features)
X_original : ndarray of shape (n_samples, n_features)
Return the reconstructed `X` data.
y_reconstructed : ndarray of shape (n_samples, n_targets)
y_original : ndarray of shape (n_samples, n_targets)
Return the reconstructed `X` target. Only returned when `y` is given.
Notes
Expand Down
2 changes: 1 addition & 1 deletion sklearn/decomposition/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def inverse_transform(self, X):
Returns
-------
X_original array-like of shape (n_samples, n_features)
X_original : array-like of shape (n_samples, n_features)
Original data, where `n_samples` is the number of samples
and `n_features` is the number of features.
Expand Down
4 changes: 2 additions & 2 deletions sklearn/decomposition/_dict_learning.py
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,7 @@ def inverse_transform(self, X):

Returns
-------
X_new : ndarray of shape (n_samples, n_features)
X_original : ndarray of shape (n_samples, n_features)
Transformed data.
"""
check_is_fitted(self)
Expand Down Expand Up @@ -1378,7 +1378,7 @@ def inverse_transform(self, X):

Returns
-------
X_new : ndarray of shape (n_samples, n_features)
X_original : ndarray of shape (n_samples, n_features)
Transformed data.
"""
return self._inverse_transform(X, self.dictionary)
Expand Down
2 changes: 1 addition & 1 deletion sklearn/decomposition/_fastica.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ def inverse_transform(self, X, copy=True):
Returns
-------
X_new : ndarray of shape (n_samples, n_features)
X_original : ndarray of shape (n_samples, n_features)
Reconstructed data obtained with the mixing matrix.
"""
check_is_fitted(self)
Expand Down
2 changes: 1 addition & 1 deletion sklearn/decomposition/_kernel_pca.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ def inverse_transform(self, X):
Returns
-------
X_new : ndarray of shape (n_samples, n_features)
X_original : ndarray of shape (n_samples, n_features)
Returns the instance itself.
References
Expand Down
2 changes: 1 addition & 1 deletion sklearn/decomposition/_nmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,7 @@ def inverse_transform(self, X):

Returns
-------
X : ndarray of shape (n_samples, n_features)
X_original : ndarray of shape (n_samples, n_features)
Returns a data matrix of the original shape.
"""

Expand Down
2 changes: 1 addition & 1 deletion sklearn/feature_extraction/_dict_vectorizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def inverse_transform(self, X, dict_type=dict):
Returns
-------
D : list of dict_type objects of shape (n_samples,)
X_original : list of dict_type objects of shape (n_samples,)
Feature mappings for the samples in X.
"""
check_is_fitted(self, "feature_names_")
Expand Down
2 changes: 1 addition & 1 deletion sklearn/feature_extraction/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,7 @@ def inverse_transform(self, X):
Returns
-------
X_inv : list of arrays of shape (n_samples,)
X_original : list of arrays of shape (n_samples,)
List of arrays of terms.
"""
self._check_vocabulary()
Expand Down
2 changes: 1 addition & 1 deletion sklearn/feature_selection/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def inverse_transform(self, X):
Returns
-------
X_r : array of shape [n_samples, n_original_features]
X_original : array of shape [n_samples, n_original_features]
`X` with columns of zeros inserted where features would have
been removed by :meth:`transform`.
"""
Expand Down
4 changes: 2 additions & 2 deletions sklearn/model_selection/_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,8 @@ def inverse_transform(self, X):

Returns
-------
X : {ndarray, sparse matrix} of shape (n_samples, n_features)
Result of the `inverse_transform` function for `Xt` based on the
X_original : {ndarray, sparse matrix} of shape (n_samples, n_features)
Result of the `inverse_transform` function for `X` based on the
estimator with the best found parameters.
"""
check_is_fitted(self)
Expand Down
2 changes: 1 addition & 1 deletion sklearn/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ def inverse_transform(self, X, **params):

Returns
-------
Xt : ndarray of shape (n_samples, n_features)
X_original : ndarray of shape (n_samples, n_features)
Inverse transformed data, that is, data in the original feature
space.
"""
Expand Down
27 changes: 14 additions & 13 deletions sklearn/preprocessing/_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ def inverse_transform(self, X):
Returns
-------
Xt : ndarray of shape (n_samples, n_features)
X_original : ndarray of shape (n_samples, n_features)
Transformed data.
"""
check_is_fitted(self)
Expand Down Expand Up @@ -1098,12 +1098,13 @@ def inverse_transform(self, X, copy=None):
----------
X : {array-like, sparse matrix} of shape (n_samples, n_features)
The data used to scale along the features axis.
copy : bool, default=None
Copy the input X or not.
Copy the input `X` or not.
Returns
-------
X_tr : {ndarray, sparse matrix} of shape (n_samples, n_features)
X_original : {ndarray, sparse matrix} of shape (n_samples, n_features)
Transformed array.
"""
check_is_fitted(self)
Expand Down Expand Up @@ -1345,7 +1346,7 @@ def inverse_transform(self, X):
Returns
-------
X_tr : {ndarray, sparse matrix} of shape (n_samples, n_features)
X_original : {ndarray, sparse matrix} of shape (n_samples, n_features)
Transformed array.
"""
check_is_fitted(self)
Expand Down Expand Up @@ -1720,7 +1721,7 @@ def inverse_transform(self, X):
Returns
-------
X_tr : {ndarray, sparse matrix} of shape (n_samples, n_features)
X_original : {ndarray, sparse matrix} of shape (n_samples, n_features)
Transformed array.
"""
check_is_fitted(self)
Expand Down Expand Up @@ -3008,7 +3009,7 @@ def inverse_transform(self, X):
Returns
-------
Xt : {ndarray, sparse matrix} of (n_samples, n_features)
X_original : {ndarray, sparse matrix} of (n_samples, n_features)
The projected data.
"""
check_is_fitted(self)
Expand Down Expand Up @@ -3404,20 +3405,20 @@ def inverse_transform(self, X):
The inverse of the Box-Cox transformation is given by::
if lambda_ == 0:
X = exp(X_trans)
X_original = exp(X_trans)
else:
X = (X_trans * lambda_ + 1) ** (1 / lambda_)
X_original = (X * lambda_ + 1) ** (1 / lambda_)
The inverse of the Yeo-Johnson transformation is given by::
if X >= 0 and lambda_ == 0:
X = exp(X_trans) - 1
X_original = exp(X) - 1
elif X >= 0 and lambda_ != 0:
X = (X_trans * lambda_ + 1) ** (1 / lambda_) - 1
X_original = (X * lambda_ + 1) ** (1 / lambda_) - 1
elif X < 0 and lambda_ != 2:
X = 1 - (-(2 - lambda_) * X_trans + 1) ** (1 / (2 - lambda_))
X_original = 1 - (-(2 - lambda_) * X + 1) ** (1 / (2 - lambda_))
elif X < 0 and lambda_ == 2:
X = 1 - exp(-X_trans)
X_original = 1 - exp(-X)
Parameters
----------
Expand All @@ -3426,7 +3427,7 @@ def inverse_transform(self, X):
Returns
-------
X : ndarray of shape (n_samples, n_features)
X_original : ndarray of shape (n_samples, n_features)
The original data.
"""
check_is_fitted(self)
Expand Down
2 changes: 1 addition & 1 deletion sklearn/preprocessing/_discretization.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ def inverse_transform(self, X):
Returns
-------
Xinv : ndarray, dtype={np.float32, np.float64}
X_original : ndarray, dtype={np.float32, np.float64}
Data in the original feature space.
"""

Expand Down
4 changes: 2 additions & 2 deletions sklearn/preprocessing/_encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@ def inverse_transform(self, X):

Returns
-------
X_tr : ndarray of shape (n_samples, n_features)
X_original : ndarray of shape (n_samples, n_features)
Inverse transformed array.
"""
check_is_fitted(self)
Expand Down Expand Up @@ -1622,7 +1622,7 @@ def inverse_transform(self, X):

Returns
-------
X_tr : ndarray of shape (n_samples, n_features)
X_original : ndarray of shape (n_samples, n_features)
Inverse transformed array.
"""
check_is_fitted(self)
Expand Down
2 changes: 1 addition & 1 deletion sklearn/preprocessing/_function_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def inverse_transform(self, X):

Returns
-------
X_out : array-like, shape (n_samples, n_features)
X_original : array-like, shape (n_samples, n_features)
Transformed input.
"""
if self.validate:
Expand Down
6 changes: 3 additions & 3 deletions sklearn/preprocessing/_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def inverse_transform(self, y):
Returns
-------
y : ndarray of shape (n_samples,)
y_original : ndarray of shape (n_samples,)
Original encoding.
"""
check_is_fitted(self)
Expand Down Expand Up @@ -389,7 +389,7 @@ def inverse_transform(self, Y, threshold=None):
Returns
-------
y : {ndarray, sparse matrix} of shape (n_samples,)
y_original : {ndarray, sparse matrix} of shape (n_samples,)
Target values. Sparse matrix will be of CSR format.
Notes
Expand Down Expand Up @@ -925,7 +925,7 @@ def inverse_transform(self, yt):
Returns
-------
y : list of tuples
y_original : list of tuples
The set of labels for each sample such that `y[i]` consists of
`classes_[j]` for each `yt[i, j] == 1`.
"""
Expand Down