在R中是否有与powertransform等效的Python函数

在R中是否有与powertransform等效的Python函数,python,r,scikit-learn,scipy,transformation,Python,R,Scikit Learn,Scipy,Transformation,在R中是否有与powertransform等效的python函数 这是在R:powerTransform(X,family=“bcnPower”) 我知道并使用了以下功能/软件包: 从scipy.stats导入倾斜,boxcox_normax 来自scipy.special import boxcox,inv_boxcox 从scipy.stats导入yeojohnson\u normax 从scipy.stats导入boxcox\u llf 从sklearn.preprocessing导入p

在R中是否有与powertransform等效的python函数

这是在R:
powerTransform(X,family=“bcnPower”)

我知道并使用了以下功能/软件包:


从scipy.stats导入倾斜,boxcox_normax
来自scipy.special import boxcox,inv_boxcox
从scipy.stats导入yeojohnson\u normax
从scipy.stats导入boxcox\u llf
从sklearn.preprocessing导入power\u变换
从sklearn.preprocessing导入PowerTransformer
我正在尝试使用python转换列表(向量)


从scipy.stats导入boxcox\u normax
vec=“”“45 5 5 3 7 6 5 8 8 3 2 3 5 10 6 7 5 2 3 1 4 4 5 2 5 5 6 6 3 10 4 5 2
7  7  3 11  5  4  4  2  2  4  6  3  4  5  6  5  8  7  4  3  5  7  3  3  6  5  3  6  6  3  9  7  9  7  2  4  2  6  4  2  5  3  4  2
7  3  7  5  5  1  5  7  1  4  5  7"""
vec=list(映射(int,vec.split())
打印(“最小值:”,最小值(向量))
打印(boxcox_normax(vec,method=“all”))
最小值:1

[0.62926218 0.58382934]


powerTransform(vec, family="bcnPower")

估计变换功率,λ [1] 0.5831778

伽马位置固定在其下限 [1] 0.1

我想要python函数,它提供相同的输出参数和结果。

如果没有这样的函数,我可以实现这样的函数吗?如何实现?

在Python中:

from sklearn.preprocessing import PowerTransformer
import pandas as pd
vec = """ 4  5  5  6  5  5  3  7  7  6  5  5  8  8  3  2  3  5 10  6  7  5  2  3  1  3  4  4  5  2  5  4  5  6  5  4  2  6  3 10  4  7  5  2
7  7  3 11  5  4  4  2  2  4  6  3  4  5  6  5  8  7  4  3  5  7  3  3  6  5  3  6  6  3  9  7  9  7  2  4  2  6  4  2  5  3  4  2
7  3  7  5  5  1  5  7  1  4  5  7"""
vec = list(map(int, vec.split()))
pt = PowerTransformer(method='box-cox', standardize=False)
data = pd.DataFrame(vec)
pt.fit(data)
print('Lambda =',pt.lambdas_)
print('First 10 elements:',pt.transform(data)[:10].reshape(1, -1))

#Lambda = [0.58382935]
#First 10 elements: [[2.13498738 2.67039083 2.67039083 3.16269828 2.67039083 2.67039083
#  1.54007639 3.62183527 3.62183527 3.16269828]]
power\u transform
如果设置
standarding=False,则会给出相同的值

在R中:

p=powerTransform(vec,family=“bcPower”)
兰姆达
#vec
#0.5838294 
bcPower(vec,λ=p$lambda)[1:10]
# [1] 2.134987 2.670391 2.670391 3.162698 2.670391 2.670391 1.540076
# [8] 3.621836 3.621836 3.162698