Box-cox Powertransformer 从非正态分布到正态分布

时间:2021-05-27 09:43:19

标签: python gaussian statistical-test

我在数据框中有非正态分布,如图片 original data 我试图通过使用 box-cox 方法获得正态分布,代码如下:

from sklearn.preprocessing import PowerTransformer


scaler = MinMaxScaler(feature_range=(1, 2))
scaler.fit(data)
data= scaler.transform(data)

#instatiate 

pt = PowerTransformer(method='box-cox') 


#Fit the data to the powertransformer
box_cox = pt.fit(data)

#Lets get the Lambdas that were found
print (box_cox.lambdas_)

calc_lambdas = box_cox.lambdas_

#Transform the data 
box_cox = pt.transform(data)


#Pass the transformed data into a new dataframe 
names= df.iloc[:,0:-1].columns
df_xt = pd.DataFrame(data=box_cox, columns=names)

df_xt.head()

根据 shapiro 检验,结果仍然是非正态的 transformed data 纤峰态分布还能做什么?

0 个答案:

没有答案
相关问题