From e84ec199706a1d7d5476bd7f03ddf1cfbd890567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20du=20Boisberranger?= Date: Wed, 2 Apr 2025 18:14:16 +0200 Subject: [PATCH] uniformize to X_original --- sklearn/cluster/_feature_agglomeration.py | 4 +-- sklearn/cross_decomposition/_pls.py | 4 +-- sklearn/decomposition/_base.py | 2 +- sklearn/decomposition/_dict_learning.py | 4 +-- sklearn/decomposition/_fastica.py | 2 +- sklearn/decomposition/_kernel_pca.py | 2 +- sklearn/decomposition/_nmf.py | 2 +- .../feature_extraction/_dict_vectorizer.py | 2 +- sklearn/feature_extraction/text.py | 2 +- sklearn/feature_selection/_base.py | 2 +- sklearn/model_selection/_search.py | 4 +-- sklearn/pipeline.py | 2 +- sklearn/preprocessing/_data.py | 27 ++++++++++--------- sklearn/preprocessing/_discretization.py | 2 +- sklearn/preprocessing/_encoders.py | 4 +-- .../preprocessing/_function_transformer.py | 2 +- sklearn/preprocessing/_label.py | 6 ++--- 17 files changed, 37 insertions(+), 36 deletions(-) diff --git a/sklearn/cluster/_feature_agglomeration.py b/sklearn/cluster/_feature_agglomeration.py index 3471329cb1472..5f27b511bd412 100644 --- a/sklearn/cluster/_feature_agglomeration.py +++ b/sklearn/cluster/_feature_agglomeration.py @@ -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) diff --git a/sklearn/cross_decomposition/_pls.py b/sklearn/cross_decomposition/_pls.py index 6999cabf2d8b8..0bf6ec8f01d06 100644 --- a/sklearn/cross_decomposition/_pls.py +++ b/sklearn/cross_decomposition/_pls.py @@ -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 diff --git a/sklearn/decomposition/_base.py b/sklearn/decomposition/_base.py index 13202d56c50f4..783c316b50f27 100644 --- a/sklearn/decomposition/_base.py +++ b/sklearn/decomposition/_base.py @@ -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. diff --git a/sklearn/decomposition/_dict_learning.py b/sklearn/decomposition/_dict_learning.py index 282376550de24..d639f17b606e3 100644 --- a/sklearn/decomposition/_dict_learning.py +++ b/sklearn/decomposition/_dict_learning.py @@ -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) @@ -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) diff --git a/sklearn/decomposition/_fastica.py b/sklearn/decomposition/_fastica.py index a6fd837313fc5..efda7bfca56b6 100644 --- a/sklearn/decomposition/_fastica.py +++ b/sklearn/decomposition/_fastica.py @@ -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) diff --git a/sklearn/decomposition/_kernel_pca.py b/sklearn/decomposition/_kernel_pca.py index 37ff77c8d7c64..79573651eeb84 100644 --- a/sklearn/decomposition/_kernel_pca.py +++ b/sklearn/decomposition/_kernel_pca.py @@ -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 diff --git a/sklearn/decomposition/_nmf.py b/sklearn/decomposition/_nmf.py index 78c394ad7f90b..50ba91c68ae49 100644 --- a/sklearn/decomposition/_nmf.py +++ b/sklearn/decomposition/_nmf.py @@ -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. """ diff --git a/sklearn/feature_extraction/_dict_vectorizer.py b/sklearn/feature_extraction/_dict_vectorizer.py index a754b92824585..689146bd229d8 100644 --- a/sklearn/feature_extraction/_dict_vectorizer.py +++ b/sklearn/feature_extraction/_dict_vectorizer.py @@ -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_") diff --git a/sklearn/feature_extraction/text.py b/sklearn/feature_extraction/text.py index 8d26539645866..eb3226b01c79e 100644 --- a/sklearn/feature_extraction/text.py +++ b/sklearn/feature_extraction/text.py @@ -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() diff --git a/sklearn/feature_selection/_base.py b/sklearn/feature_selection/_base.py index 065d9c7eed03a..56e50e49ca30c 100644 --- a/sklearn/feature_selection/_base.py +++ b/sklearn/feature_selection/_base.py @@ -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`. """ diff --git a/sklearn/model_selection/_search.py b/sklearn/model_selection/_search.py index fe86a11c50267..869e2dcaf57e4 100644 --- a/sklearn/model_selection/_search.py +++ b/sklearn/model_selection/_search.py @@ -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) diff --git a/sklearn/pipeline.py b/sklearn/pipeline.py index 13b9599ffc5e0..71717252d155c 100644 --- a/sklearn/pipeline.py +++ b/sklearn/pipeline.py @@ -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. """ diff --git a/sklearn/preprocessing/_data.py b/sklearn/preprocessing/_data.py index 74d7b1909c4e1..e5abbf6d17a58 100644 --- a/sklearn/preprocessing/_data.py +++ b/sklearn/preprocessing/_data.py @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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 ---------- @@ -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) diff --git a/sklearn/preprocessing/_discretization.py b/sklearn/preprocessing/_discretization.py index 0cdfe225d163f..ef5081080bda1 100644 --- a/sklearn/preprocessing/_discretization.py +++ b/sklearn/preprocessing/_discretization.py @@ -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. """ diff --git a/sklearn/preprocessing/_encoders.py b/sklearn/preprocessing/_encoders.py index 86e0c991ab2a3..5f41c9d0c6d22 100644 --- a/sklearn/preprocessing/_encoders.py +++ b/sklearn/preprocessing/_encoders.py @@ -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) @@ -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) diff --git a/sklearn/preprocessing/_function_transformer.py b/sklearn/preprocessing/_function_transformer.py index 3fc33c59e76bd..0363f8c5b6120 100644 --- a/sklearn/preprocessing/_function_transformer.py +++ b/sklearn/preprocessing/_function_transformer.py @@ -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: diff --git a/sklearn/preprocessing/_label.py b/sklearn/preprocessing/_label.py index 14b7c7907d1eb..dd721b35a3521 100644 --- a/sklearn/preprocessing/_label.py +++ b/sklearn/preprocessing/_label.py @@ -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) @@ -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 @@ -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`. """