shaare.it

ValueError: 'method' invalid for PowerTransformer

ValueError: PowerTransformer method invalid

$ python -c "from sklearn.preprocessing import PowerTransformer; PowerTransformer(method='log').fit([[1.0],[2.0],[3.0]])"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ValueError: method must be 'yeo-johnson' or 'box-cox'

Why this happens

Unsupported method.

Fix

Choose one of the valid methods.

Wrong code

from sklearn.preprocessing import PowerTransformer
PowerTransformer(method='log')

Fixed code

from sklearn.preprocessing import PowerTransformer
PowerTransformer(method='yeo-johnson')