ValueError:找到样本数不一致的输入变量:[75,1]

时间:2017-03-16 07:35:24

标签: python scikit-learn

有人可以告诉我这是什么样的错误以及如何解决这个问题(如图所示)

,这是错误消息

Traceback (most recent call last):
  File "ep5pipeline.py", line 57, in <module>
    print (accuracy_score(y_test,predictions, normalize = False))
  File "//anaconda/lib/python3.6/site-packages/sklearn/metrics/classification.py", line 172, in accuracy_score
    y_type, y_true, y_pred = _check_targets(y_true, y_pred)
  File "//anaconda/lib/python3.6/site-packages/sklearn/metrics/classification.py", line 72, in _check_targets
    check_consistent_length(y_true, y_pred)
  File "//anaconda/lib/python3.6/site-packages/sklearn/utils/validation.py", line 181, in check_consistent_length
    " samples: %r" % [int(l) for l in lengths])
ValueError: Found input variables with inconsistent numbers of samples: [75, 1]

1 个答案:

答案 0 :(得分:1)

在函数predict()中,return predictions应该出现在&#34; for&#34;迭代。

此外,像Neil说的那样,最好发布源代码。