wxt_hillwill
wxt_hillwill
2018-05-28 02:09

使用sklearn进行模型预测的时候遇到ValueError错误

5
  • sklearn
  • matrix

程序是:

 test_matrix = vect.transform(zf['text'])
res = model.predict(test_matrix)

zf['text']是获取的网页中的纯文本文件。运行到第二句进行预测的时候报错了:

 Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Program Files\Python36\lib\site-packages\sklearn\linear_model\base.py", line 324, in predict
    scores = self.decision_function(X)
  File "D:\Program Files\Python36\lib\site-packages\sklearn\linear_model\base.py", line 305, in decision_function
    % (X.shape[1], n_features))
ValueError: X has 6140 features per sample; expecting 8

请问这个报错是什么意思,应该怎么修改呢?

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

4条回答