[英]Sklearn Preprocessing -- *** TypeError: No matching signature found
I am trying to normalize a CSR matrix,我正在尝试标准化 CSR 矩阵,
but I get this error: (*** TypeError: No matching signature found).
但我收到此错误: (*** TypeError: No matching signature found).
from sklearn.preprocessing import normalize
normalize(x_m, norm="l2", axis=1)
The matrix is 609186x849632 sparse matrix of type 'numpy.float16' with 189140200 stored elements in Compressed Sparse Row format该矩阵是 609186x849632 类型为 'numpy.float16' 的稀疏矩阵,其中包含 189140200 个以压缩稀疏行格式存储的元素
Actually I solved the problem.其实我解决了这个问题。 I think it is because of the data type.我认为这是因为数据类型。 Changing np.float16
to np.float32
, solved the problem.将np.float16
更改为np.float32
,解决了问题。 I do not know why, this problem only happens with np.float16
data type.我不知道为什么,这个问题只发生在np.float16
数据类型上。
from sklearn.preprocessing import normalize
columns_changed = []
for col in df.columns:
col_type = x_m[col].dtypes
if col_type == 'float16':
columns_changed.append(col)
x_m[col] = x_m[col].astype(np.float32)
normalize(x_m, norm="l2", axis=1)
for col in columns_changed:
x_m[col] = x_m[col].astype(np.float16)
x_m
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.