[英]how to resolve issue with an unsupported format string passed to builtin_function_or_method.__format__
I'm trying to do a standardization (z-score normalization)我正在尝试进行标准化(z-score normalization)
x = data[['BALANCE', 'BALANCE_FREQUENCY', 'PURCHASES']]
std_scale = preprocessing.StandardScaler().fit(x)
df_std = std_scale.transform(x)
print('Mean after standardization:\nBALANCE={:.2f}, BALANCE_FREQUENCY={:.2f}, PURCHASES={:.2f}'.format(df_std[:,0].mean(), df_std[:,1].mean, df_std[:,2].mean()))
print('\nStandard deviation after standardization:\nBALANCE={:.2f}, BALANCE_FREQUENCY={:.2f}, PURCHASES={:.2f}'.format(df_std[:,0].std(), df_std[:,1].std, df_std[:,2].std()))
and I got this error:我得到了这个错误:
---> 10 .format(df_std[:,0].mean(), df_std[:,1].mean, df_std[:,2].mean()))
TypeError: unsupported format string passed to builtin_function_or_method.__format__
You are missing parenthesis in your function calls of mean
and std
.您在
mean
和std
的 function 调用中缺少括号。
print('Mean after standardization:\nBALANCE={:.2f}, BALANCE_FREQUENCY={:.2f}, PURCHASES={:.2f}'.format(df_std[:,0].mean(), df_std[:,1].mean(), df_std[:,2].mean()))
print('\nStandard deviation after standardization:\nBALANCE={:.2f}, BALANCE_FREQUENCY={:.2f}, PURCHASES={:.2f}'.format(df_std[:,0].std(), df_std[:,1].std(), df_std[:,2].std()))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.