@@ -2974,21 +2974,6 @@ class PowerTransformer(_OneToOneFeatureMixin, TransformerMixin, BaseEstimator):
2974
2974
2975
2975
.. versionadded:: 1.0
2976
2976
2977
- Examples
2978
- --------
2979
- >>> import numpy as np
2980
- >>> from sklearn.preprocessing import PowerTransformer
2981
- >>> pt = PowerTransformer()
2982
- >>> data = [[1, 2], [3, 2], [4, 5]]
2983
- >>> print(pt.fit(data))
2984
- PowerTransformer()
2985
- >>> print(pt.lambdas_)
2986
- [ 1.386... -3.100...]
2987
- >>> print(pt.transform(data))
2988
- [[-1.316... -0.707...]
2989
- [ 0.209... -0.707...]
2990
- [ 1.106... 1.414...]]
2991
-
2992
2977
See Also
2993
2978
--------
2994
2979
power_transform : Equivalent function without the estimator API.
@@ -3014,6 +2999,21 @@ class PowerTransformer(_OneToOneFeatureMixin, TransformerMixin, BaseEstimator):
3014
2999
3015
3000
.. [2] G.E.P. Box and D.R. Cox, "An Analysis of Transformations", Journal
3016
3001
of the Royal Statistical Society B, 26, 211-252 (1964).
3002
+
3003
+ Examples
3004
+ --------
3005
+ >>> import numpy as np
3006
+ >>> from sklearn.preprocessing import PowerTransformer
3007
+ >>> pt = PowerTransformer()
3008
+ >>> data = [[1, 2], [3, 2], [4, 5]]
3009
+ >>> print(pt.fit(data))
3010
+ PowerTransformer()
3011
+ >>> print(pt.lambdas_)
3012
+ [ 1.386... -3.100...]
3013
+ >>> print(pt.transform(data))
3014
+ [[-1.316... -0.707...]
3015
+ [ 0.209... -0.707...]
3016
+ [ 1.106... 1.414...]]
3017
3017
"""
3018
3018
3019
3019
def __init__ (self , method = "yeo-johnson" , * , standardize = True , copy = True ):
@@ -3044,6 +3044,22 @@ def fit(self, X, y=None):
3044
3044
return self
3045
3045
3046
3046
def fit_transform (self , X , y = None ):
3047
+ """Fit `PowerTransformer` to `X`, then transform `X`.
3048
+
3049
+ Parameters
3050
+ ----------
3051
+ X : array-like of shape (n_samples, n_features)
3052
+ The data used to estimate the optimal transformation parameters
3053
+ and to be transformed using a power transformation.
3054
+
3055
+ y : Ignored
3056
+ Not used, present for API consistency by convention.
3057
+
3058
+ Returns
3059
+ -------
3060
+ X_new : ndarray of shape (n_samples, n_features)
3061
+ Transformed data.
3062
+ """
3047
3063
return self ._fit (X , y , force_transform = True )
3048
3064
3049
3065
def _fit (self , X , y = None , force_transform = False ):
0 commit comments