python - 在为 Keras NN 做准备时应用 StandardScaler() 时遇到问题

标签 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)

我正在尝试应用标准缩放器并收到此错误:

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

在我使用 Keras 的过程中,我从未想过这会是最难的部分。我看了很多例子,但看不出哪里出了问题。

最佳答案

StandardScaler 后面缺少括号。

归一化器 = preprocessing.StandardScaler().fit(df_train_x)

关于python - 在为 Keras NN 做准备时应用 StandardScaler() 时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56586286/

相关文章:

python - Flask 应用程序为 Flask Migrate 获取错误 "could not locate flask application. .....FLASK_APP environment variable"

python - 如何使用类型函数为方法编写 python 多语言单元测试?

python - 尽管格式正确, Pandas 仍无法推断时间序列频率?

linux - 无法链接 python 的共享库

java - 合并两个具有不同但重叠模式和不同实例数量的稀疏 weka 数据集

python - getattr - 异常值 : module 'django.db.models' has no attribute 'model_name' '

python - 为什么导出 GOOGLE_APPLICATION_CREDENTIALS 不适用于 `bq`?

python - 基于日期列之间的月份和平均值的 Pandas 数据框

python - 使用 Python 的 scikit-learn 中随机森林算法的置信度与概率

python - 直接在生产中部署带有 H2O 算法的 Python 代码,无需 MOJO 和 POJO