简体   繁体   English

Sklearn 预处理 -- *** TypeError: 找不到匹配的签名

[英]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.

相关问题 数据集上的sklearn.preprocessing.LabelEncoder TypeError - sklearn.preprocessing.LabelEncoder TypeError on data set Pearsonr:TypeError:没有找到与指定签名匹配的循环,并且为 ufunc add 找到了转换 - Pearsonr: TypeError: No loop matching the specified signature and casting was found for ufunc add TypeError:没有找到与指定签名匹配的循环,并且为 ufunc greater 找到了转换 - TypeError: No loop matching the specified signature and casting was found for ufunc greater NaN 替换 pandas DataFrame 引发 TypeError:找不到匹配的签名 - NaN replace on pandas DataFrame raises TypeError: No matching signature found 调用 func pearsonr 和 Got TypeError: 没有找到匹配指定签名和转换的循环用于 ufunc add - Call func pearsonr and Got TypeError: No loop matching the specified signature and casting was found for ufunc add Seaborn TypeError: No loop match the specified signature and cast was found for ufunc add when using hue - Seaborn TypeError: No loop matching the specified signature and casting was found for ufunc add when using hue sklearn预处理培训清单 - Preprocessing training list with sklearn 使用滚动 window 进行 sklearn 预处理? - sklearn preprocessing with a rolling window? sklearn.manifold.TSNE TypeError:ufunc&#39;multiply&#39;不包含签名匹配类型的循环(dtype(&#39; - sklearn.manifold.TSNE TypeError: ufunc 'multiply' did not contain a loop with signature matching types (dtype('<U32'), dtype('<U32'))...) np.linalg.lstsq(X,Y)[0] - TypeError: No loop match the specified signature and cast was found for ufunc lstsq_n - np.linalg.lstsq(X,Y)[0] - TypeError: No loop matching the specified signature and casting was found for ufunc lstsq_n
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM