我已经pred_data.txt作为访问数数组中从该文件在Python
19.08541,17.41787,16.59118,16.03507,15.68560
20.01880,18.21,19.48975,19.32,19.29945
17.32453,17.434,15.4253,12.422,11.4311
f=open('pred_data.txt','r')
for value in f:
exam=np.array(value)
pred=clf.predict(exam)
print(pred)
当我运行它,我得到了
ValueError: could not convert string to float:'19.08541,17.41787,16.59118,16.03507,15.68560\n'
但是当我尝试这样的: example=np.array([19.08541,17.41787,16.59118,16.03507,15.68560]) pred=clf.predict(example)
我得到了预测的输出。如何从文件访问数据以获取输出?
当我用'考试= np.array(浮在value.strip V()。分裂( '')(V))'我喜欢这个<发生器对象在0x00000266DAF54410>在'打印(考试)' –