0
$\begingroup$

I am dealing with a multi-class problem and imbalanced data. I am trying to find an algorithm that can predict well each class with python (sklearn and pandas). My dataset contains: 620 rows, 12 columns and is imbalanced:

class 0: 47,3% class 1: 10,5% class 2: 9% class 3: 8,6% I tried to upsample the classes 1,2,3 and trained diferent algorithms but the best f1 weighted score is only 58%.

I also tried to downsample the class 0 and trained the same algorithms but the best f1 weighted score is 40%. SMOTE method does not work so well.

The algorithms that I trained are:

K Nearest Neighbors Logistic Regression (solver='sag') Random Forest Adaboost SVM How can I improve the accuracy of my models? Do I need to change the model or to something else regarding the imbalanced dataset?

$\endgroup$
2
  • 2
    $\begingroup$ class 0: 47,3% class 1: 10,5% class 2: 9% class 3: 8,6% : Total makes 75.4%, where are the other 25% ? $\endgroup$
    – Adept
    Jul 19 at 10:06
  • 1
    $\begingroup$ 620 rows of data is also not much to work with $\endgroup$
    – WBM
    Jul 19 at 10:14
1
$\begingroup$

I believe your dataset size is too small for 12 classes and some of them are not represented enough so that your model can distinguish them.

You can give more weights for less represented classes in the loss function of the related model.

Or, you may apply two step approach (not sure whether it is optimal or not). That means you can predict class 1 or class 2,3,4 or the other classes. Then, extra classifier sub models can be trained. In this case, you will have 3 different models to optimize. Here is an example of two step approach (of course, for totally different use case): https://github.com/koaning/scikit-lego/blob/main/sklego/meta/zero_inflated_regressor.py

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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