FutureWarning:如果 dtype='numeric'

问题描述

FutureWarning: Arrays of bytes/strings is being converted to decimal numbers if 
dtype='numeric'. This behavior is deprecated in 0.24 and will be removed in 1.1 (renaming of 0.26). 
Please convert your data to numeric values explicitly instead.

请问这是什么意思?我一直在尝试部署我的模型,但是当我运行它时总是出现这种情况

解决方法

我认为您的 targetsfeatures 不是数字格式。

例如:

['1.0','2.0','3.0','4.0'] #  non-numeric format
[1.0,2.0,3.0,4.0] #  numeric format

您可以通过使用 numpy 或 for 循环来解决此问题:

a = ['1.0','4.0'] #  non-numeric format
b = np.array(a,dtype=float) #  convert using numpy
c = [float(i) for i in a] #  convert with for loop

据我所知,sklearn 会将非数字数组转换为数字数组,因此无论如何它都可以工作,但从警告来看,未来不会再出现这种情况。

下次请包含您的代码或其中的一部分,以便更容易为您提供帮助。 干杯。