Python:ufunc ‘subtract‘ did not contain a loop with signature matching types dtype(‘「U32‘)
python报错ufunc 'subtract' did not contain a loop with signature matching types dtype('<U32') dtype('<U32') dtype('<U32')前面有个warning:FutureWarning: Beginning in version 0.22, arrays of bytes/st
python报错ufunc 'subtract' did not contain a loop with signature matching types dtype('<U32') dtype('<U32') dtype('<U32')
前面有个warning: FutureWarning: Beginning in version 0.22, arrays of bytes/strings will be converted to decimal numbers if dtype='numeric'. It is recommended that you convert the array to a float dtype before using it in scikit-learn, for example by using your_array = your_array.astype(np.float64).
y_true = check_array(y_true, ensure_2d=False, dtype=dtype)
大概意思就是嫌弃我没有转换类型。
加入参数dtype = ‘float64’即可。
#Y = numpy.array(names_classes)
Y = numpy.array(names_classes, dtype = 'float64')
如果之前已经指定过dtype,可以用astype转化类型。
y = np.array([0, 1, 1], dtype='S32')
y = y.astype('float64')
参考:
更多推荐
所有评论(0)