Python 如何将变量转换为scikit learn中预测方法的参数类型

Python 如何将变量转换为scikit learn中预测方法的参数类型,python,scikit-learn,predict,Python,Scikit Learn,Predict,我必须使用随机森林模型clf预测输入,如下所示: y_predict_test = clf.predict(input) print input [ 6.36505950e+10 6.36505951e+10 6.32830000e+01 ..., 0.00000000e+00 0.00000000e+00 0.00000000e+00] FV = np.array(input) print FV [ 6.36505950e+10 6.36505951e+10 6

我必须使用随机森林模型clf预测输入,如下所示:

y_predict_test = clf.predict(input)
print input
[  6.36505950e+10   6.36505951e+10   6.32830000e+01 ...,   0.00000000e+00
0.00000000e+00   0.00000000e+00]

FV = np.array(input)
print FV
[  6.36505950e+10   6.36505951e+10   6.32830000e+01 ...,   0.00000000e+00
0.00000000e+00   0.00000000e+00]

print type (FV)
<type 'numpy.ndarray'>
print FV.dtype
|S109
输入类型为字符串,其值由函数生成

print input
[  6.36505950e+10   6.36505951e+10   6.32830000e+01 ...,   0.00000000e+00
0.00000000e+00   0.00000000e+00]
predict方法不接受字符串作为参数

使用哪种类型转换变量输入?如何转换

也许我得用另一种方式问我的问题

我必须将变量输入转换为dtype float64的数组

变量输入如下所示:

y_predict_test = clf.predict(input)
print input
[  6.36505950e+10   6.36505951e+10   6.32830000e+01 ...,   0.00000000e+00
0.00000000e+00   0.00000000e+00]

FV = np.array(input)
print FV
[  6.36505950e+10   6.36505951e+10   6.32830000e+01 ...,   0.00000000e+00
0.00000000e+00   0.00000000e+00]

print type (FV)
<type 'numpy.ndarray'>
print FV.dtype
|S109
但它不起作用


谢谢您的帮助,

您能否运行
键入(输入)
以确保它是字符串?另外,返回它的函数可能实际上应该返回一个numpy数组。在我看来,它返回一个字符串似乎是一个bug。type(input)的结果是。事实上,输入变量由消息传递协议接收。消息的内容被系统地转换成字符串,然后错误就出现在发送者身上。数组未正确序列化。请使用与从训练数据转换字符串相同的方法来转换字符串
input
。不知道你在使用什么来矢量化字符串,但如果它是内置的sklearn函数,只需使用类似于
extr=feature\u extraction\u method.fit(你的\u training\u数据)
在训练数据上,然后在
input
变量
矢量化的\u input=extr.transform(input)
predict方法将ndarray类型作为参数类型。如何将输入变量转换为ndarray类型?