FutureWarning:如果 dtype='numeric',则字节/字符串数组将转换为十进制数字

fid*_*ids 5 python scikit-learn deprecation-warning streamlit

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.
Run Code Online (Sandbox Code Playgroud)

请问这是什么意思?我一直在尝试部署我的模型,但是当我运行它时,这个问题不断出现

Enr*_*más 6

我相信您的targetsfeatures都不是数字格式。

例如:

['1.0', '2.0', '3.0', '4.0'] #  non-numeric format
[1.0, 2.0, 3.0, 4.0] #  numeric format
Run Code Online (Sandbox Code Playgroud)

您可以使用numpyfor 循环来修复此问题,如下所示:

a = ['1.0', '2.0', '3.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
Run Code Online (Sandbox Code Playgroud)

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

下次请附上您的代码或部分代码,以便更轻松地为您提供帮助。干杯。