You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the latest version of scikit-learn, the power_transform() function does not provide a way to access the lambda values ((\lambda)) used during the transformation. This was possible in the older version using the PowerTransformer class with the lambdas_ attribute.
Steps
fromsklearn.preprocessingimportpower_transformimportpandasaspdimportnumpyasnpnp.random.seed(42)
data=np.random.exponential(scale=2, size=1000)
transformed_data=power_transform(data, method='box-cox')
# No way to access lambda values
Actual behavior
The power_transform() function does not expose lambda values, making it less informative for users who need them.
transformed_data.lambdas_ AttributeError:numpy.ndarray object has no attribute lambdas_
Expected behavior
There should be a way to retrieve the lambda values (𝜆) when using the power_transform() function.
Environment
scikit-learn version: 1.6.1
The text was updated successfully, but these errors were encountered:
I think this bug was accidentally introduced with #26566, but I'm not 100 % sure yet.
I would like to take a look and give it a try in fixing that, if it's okay, @jeremiedbb?
I now understand it better and I don't think it is a bug, @samer-oxy.
power_transform() in contrast to the PowerTransformer class returns only X as an array and not attributes that were created while fitting.
I did some investigation to see if I could re-create the fact that you said it worked in previous versions, but not even with scikit-learn==1.1.0 and numpy==1.22.0 we would get an attribute for the lambdas on the numpy array (which makes sense, because scikit-learn doesn't manipulate other librarie's objects).
Please use PowerTransformer directly to obtain the lambdas_.
(And sorry for the confusion @jeremiedbb, just ignore that.)
Describe the issue
In the latest version of scikit-learn, the
power_transform()
function does not provide a way to access the lambda values ((\lambda)) used during the transformation. This was possible in the older version using thePowerTransformer
class with thelambdas_
attribute.Steps
Actual behavior
The
power_transform()
function does not expose lambda values, making it less informative for users who need them.transformed_data.lambdas_
AttributeError:
numpy.ndarray
object has no attributelambdas_
Expected behavior
There should be a way to retrieve the lambda values (𝜆) when using the
power_transform()
function.Environment
scikit-learn version: 1.6.1
The text was updated successfully, but these errors were encountered: