Train test split ERROR So I was applying the random forest classifier model to a problem,however it showed this error ,even though the columns in X and Y of my dataset are equal. How can I resolve this?

ValueError                                Traceback (most recent call last)
&lt;ipython-input-123-8b3f6408c588&gt; in &lt;module&gt;
      1 from sklearn.metrics import confusion_matrix,accuracy_score
----&gt; 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     &quot;&quot;&quot;
--&gt; 253     y_type, y_true, y_pred = _check_targets(y_true, y_pred)
    254     if y_type not in (&quot;binary&quot;, &quot;multiclass&quot;):
    255         raise ValueError(&quot;%s is not supported&quot; % 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     &quot;&quot;&quot;
---&gt; 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) &gt; 1:
    204         raise ValueError(&quot;Found input variables with inconsistent numbers of&quot;
--&gt; 205                          &quot; samples: %r&quot; % [int(l) for l in lengths])
    206 
    207 

ValueError: Found input variables with inconsistent numbers of samples: [7500, 2500]
In your confusion matrix kernel , you passed two arguments. Y_pred and y_true. They are supposed to have same dimensionality. But they are different. That's why the error occured.