[英]StandardScaler: TypeError: fit() missing 1 required positional argument: 'X'
I am using StandardScaler to scaling my dataframe like below, and I got an error of ypeError: fit() missing 1 required positional argument: 'X'.我正在使用 StandardScaler 来缩放我的数据框,如下所示,我得到了一个错误 ypeError: fit() missing 1 required positional argument: 'X'. I am not sure where is the problem?
我不确定问题出在哪里? Thanks for your help.
谢谢你的帮助。
import seaborn as sns
import pandas as pd
from random import randrange
import random
import numpy as np
from sklearn.preprocessing import StandardScaler # for feature scaling
random.seed(10)
df = pd.DataFrame()
for i in range(0,50):
df = df.append({'x': randrange(1,10),
'y': randrange(10,21),
'depth':randrange(400,601)}, ignore_index=True)
df.head()
depth x y
0 523.0 1.0 16.0
1 518.0 1.0 13.0
2 567.0 8.0 14.0
3 533.0 3.0 10.0
4 419.0 8.0 15.0
scaler = StandardScaler
scaler.fit(df)
df_scaled= scaler.transform(df)
The error is:错误是:
TypeError Traceback (most recent call last)
<ipython-input-40-98ea46087b3f> in <module>
4 scaler = StandardScaler
5
----> 6 scaler.fit(df)
7 df_scaled= scaler.transform(df)
TypeError: fit() missing 1 required positional argument: 'X'
You have to write你必须写
scaler = StandardScaler()
You forgot the parenthesis你忘了括号
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.