I am trying to use a multiclass classification using python. For that I used few algorthims like Random Forest, Xgboost, Logitic regression.
My problem is simple, I have users, Images, and people ratings on those images. I devided the ratings into 3 classes:
class 1: good marks class 2: bad marks class 3: medium evaluations
At first I got these results
I have 70% of bad marks (class2) 18% of good marks (class1) 10% of bad marks (class 3)
so all was good I did the classification and I got a good accuracy (75%).
I have collected more data and more (good marks) and the accuracy kept decreasing.
So I understood that the accuracy was good only because the algorithms where predicting that almost all the marks are bad, so basically only one class- class 2, and when I got more data in class 1 and class 3 the accuracy decreased.
This is example of the confusion matrix I was having
Predicted Marks 1 2 3 Actual Marks 1 48 85 3 2 17 250 4 3 10 89 1
I understood that I was getting this problem because I have unbalanced data, so I was predicting bascially the highest frequency class.
I did some researches and I found that there are option called `
class_weight='balanced' So I used it in the classification algorithms.
And I got this result
Predicted Marks 1 2 3 Actual Marks 1 53 61 29 2 66 161 53 3 24 40 17
So my question is:
First I know that the option
balancedtry to requilibrate the data
but I don't understand how. I found in the explanations that it"considers each class as important as the other"` but still don't understand how. Does it duplicate rows of the minor categories ?
When I used that option, it was obvious that the classifier were predicting other Mark classes more frequently, but there are more number of right predictions than the wrong ones. ( example in the second confusion matrix the class 1 was predicted as class 2 66 times , but in the confusion matrix 1 only 17 times)
Am I analysing the problem right? and what are your suggestions for such a problem?
Sorry for making this long, any help will be appreciated !!