Yeo-Johnson変換

データサイエンス




yeo-johnson

$$
\psi(\lambda, y)=\left\{\begin{array}{ll}{\left((y+1)^{\lambda}-1\right) / \lambda} & {\text { if } \lambda \neq 0, y \geq 0} \\ {\log (y+1)} & {\text { if } \lambda=0, y \geq 0} \\ {\left.-\left[(-y+1)^{2-\lambda}-1\right)\right] /(2-\lambda)} & {\text { if } \lambda \neq 2, y<0} \\ {-\log (-y+1)} & {\text { if } \lambda=2, y<0}\end{array}\right. $$

Python

#from sklearn
from sklearn.preprocessing import PowerTransformer
sk_yeojohnson = PowerTransformer('yeojohnson')

#lambda = sk_boxcox.lambdas_
yeojohnson_data = sk_yeojohnson.fit_transform(x)
inv_yeojohnson_data = sk_yeojohnson.inverse_transform(yeojohnson_data)

参考

  1. https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.PowerTransformer.html#rf3e1504535de-1
  2. https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.yeojohnson.html
  3. https://www.stat.umn.edu/arc/yjpower.pdf
タイトルとURLをコピーしました