1
$\begingroup$

I'm applying the Random Forest classifier on a dataset with 645 records and 12 features (selected by KBest method). This dataset contains a class with 4 possible values (1..4). When I plot the confusion matrix I've got this

enter image description here

My point is about class 2. As you noted, the learned model didn't work for this class. Initially, the size could be a problem, but class 2 has a similar size the class 2 I checked the mean values for each feature but I didn't find anything anormal between class 2 and the others.

Someone has an idea of the reasons the model sounds too bad to only class 2?

$\endgroup$
1
  • 2
    $\begingroup$ Important remark that I forgot to mention in my answer: what you show in the question is not the confusion matrix, it's called the classification report. The confusion matrix is a table with all the true classes as columns and predicted classes as rows, where each cell contains the number of instances from true class X predicted as class Y. $\endgroup$
    – Erwan
    Commented Dec 29, 2021 at 22:05

1 Answer 1

1
$\begingroup$

Most likely the features are not sufficiently discriminative for class 2: class 2 data points are mixed with some of the other classes, and the model cannot distinguish them so it predicts the most likely class.

To investigate more precisely the first step is to look at the confusion matrix: see which other classes the class 2 instances are confused with. Then you could try to train a single decision tree and observe which features the model uses to distinguish between the other classes. Chances are that none of the features are good enough to recognize class 2. If you want to go further you could try to simplify the problem and train a model using only the instances of class 2 vs. one other class.

$\endgroup$
1
  • $\begingroup$ Thanks for your explanation . I got accuracy=0.76 after two changes: 1) Including two more variables and 2) dividing into only two classes. I think that 4 classes configuration (an arbitrary division of mine) create classes with insufficient size for the learning process. $\endgroup$
    – mr x
    Commented Jan 2, 2022 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.