在为Keras NN进行准备时无法应用StandardScaler()

时间:2019-06-13 18:07:56

标签: python python-3.x machine-learning scikit-learn

df =

df_train_x.head()
Out[43]: 
      longevity_endfy18      ...       memc_err_law
1029                  9      ...                  0
79                    9      ...                  0
1464                  9      ...                  0
2620                  3      ...                  0
808                   3      ...                  0

type(df_train_x)
Out[44]: pandas.core.frame.DataFrame

normalizer = preprocessing.StandardScaler.fit(df_train_x)
trainx_norm = normalizer.transform(df_train_x) 
testx_norm = normalizer.transform(df_test_x)

我正在尝试应用standardscaler并收到此错误:

normalizer = preprocessing.StandardScaler.fit(df_train_x)
TypeError: fit() missing 1 required positional argument: 'X'

在使用Keras的过程中,我从未想到这将是最困难的部分。我看了很多例子,看不出有什么问题。

1 个答案:

答案 0 :(得分:2)

StandardScaler后缺少括号。

normalizer = preprocessing.StandardScaler().fit(df_train_x)