我正在使用python自学回归,并在指南中看到了以下代码。显而易见,它调用了ScandardScaler-fit_transform方法-但也尝试存储均值和标准差(以便以后可以将其标准化)
from sklearn.preprocessing import StandardScaler
observations = len(dataset)
variables = dataset.columns
standardisation = StandardScaler(copy = False, with_mean = True,
with_std = True)
Xst = standardization.fit_transform(X)
original_means = standardisation.mean_
original_stds = standardisation.std_
Xst = np.column_stack((Xst, np.ones(observations)))
y = dataset['Target'].values`
此生成的错误是
AttributeError:“ StandardScaler”对象没有属性“ mean _”
答案 0 :(得分:0)
...因此事实证明,从Scikit-Learn版本0.17开始,“ mean_”和“ std_”属性不再作为StandardScaler对象出现。
但是
original_means = np.mean(X)
original_stds = np.std(X)
可以解决问题。