所以我将随机森林分类器模型应用于一个问题,但是它显示了这个错误,即使我的数据集的 X 和 Y 中的列是相等的。我该如何解决这个问题?
ValueError Traceback (most recent call last)
<ipython-input-123-8b3f6408c588> in <module>
1 from sklearn.metrics import confusion_matrix,accuracy_score
----> 2 cm = confusion_matrix(y_pred4,Y_test)
~\Anaconda3\lib\site-packages\sklearn\metrics\classification.py in confusion_matrix(y_true, y_pred, labels, sample_weight)
251
252 """
--> 253 y_type, y_true, y_pred = _check_targets(y_true, y_pred)
254 if y_type not in ("binary", "multiclass"):
255 raise ValueError("%s is not supported" % y_type)
~\Anaconda3\lib\site-packages\sklearn\metrics\classification.py in _check_targets(y_true, y_pred)
69 y_pred : array or indicator matrix
70 """
---> 71 check_consistent_length(y_true, y_pred)
72 type_true = type_of_target(y_true)
73 type_pred = type_of_target(y_pred)
~\Anaconda3\lib\site-packages\sklearn\utils\validation.py in check_consistent_length(*arrays)
203 if len(uniques) > 1:
204 raise ValueError("Found input variables with inconsistent numbers of"
--> 205 " samples: %r" % [int(l) for l in lengths])
206
207
ValueError: Found input variables with inconsistent numbers of samples: [7500, 2500]