如何解决此错误? &quot”功能'对象没有属性'标准标准器;
def preprocessing(df:pd.DataFrame,scaler:str):
standard_scaler= preprocessing.StandardScaler()
not_uv=[]
for column in df.columns:
if column != 'uv': # uv is target
not_uv.append(column)
if scaler == 'standard':
standard_df = pd.DataFrame(standard_scaler.fit_transfrom(df[not_uv]), columns = not_uv)
standard_df = pd.concat([standard_df,df[['uv']]],axis=1)
return standard_df
preprocessing(df_13,'standard')
AttributeError: 'function' object has no attribute 'StandardScaler'
我想制作预处理功能 我的代码怎么了?
def preprocessing(df:pd.DataFrame,scaler:str):
standard_scaler= preprocessing.StandardScaler()
not_uv=[]
for column in df.columns:
if column != 'uv': # uv is target
not_uv.append(column)
if scaler == 'standard':
standard_df = pd.DataFrame(standard_scaler.fit_transfrom(df[not_uv]), columns = not_uv)
standard_df = pd.concat([standard_df,df[['uv']]],axis=1)
return standard_df
preprocessing(df_13,'standard')
AttributeError: 'function' object has no attribute 'StandardScaler'
i want to make preprocssing function
whats wrong with my code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此代码在用户定义的功能预处理和Sklearn内置功能预处理之间产生冲突。只需导入并进行这样的实例。
或
将您的功能名称更改为预处理 预处理或其他东西。切勿声明或制作内置关键字的实例。
This code generates a conflict between user-defined function preprocessing and sklearn built-in function preprocessing. Simply import and make instance like this.
OR
Change your function name preprocessing to preprocessings or something else. Never declare or make an instance of built-in keywords.
函数的名称
def预处理(...):
与preprocessing.standardscaler()
相同。这意味着您正在覆盖内存。更改功能的名称。例如:The name of the function
def preprocessing(...):
is same aspreprocessing.StandardScaler()
. Which means you are overwriting the memory. Change the name of the function. For Example: