0
$\begingroup$

I'm facing a problem about making a classification on a dataset. The target variable is binary (with 2 classes, 0 and 1). I have 8,161 samples in the training dataset. And for each class, I have:

  • class 0: 6,008 samples, 73.6% of total numbers.
  • class 1: 2,153 samples, 26.4%

My questions are:

  • In this case, should I consider the dataset I used as an imbalanced dataset?

  • If it was, should I process the data before using RandomForest to make a prediction?

  • If it was not an imbalanced dataset, could somebody tell me in which situation (like what ratio for each class) I could consider a dataset as imbalanced?

New contributor
ouyqf is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
$\endgroup$
  • 1
    $\begingroup$ Please notice that when someone edits out the "thanks" part in the SO version of your post, it is expected that you get the message and do not repeat it here (or anywhere else, for that matter) $\endgroup$ – desertnaut Jan 16 at 1:24
  • $\begingroup$ @desertnaut I was wondering that you left a comment in SO version like "I’m voting to close this question because it is not about programming as defined in the help center but about ML theory/methodology. " Then I asked my question here in the right version. But you said "do not repeat it here " So where should I ask my question ???? $\endgroup$ – ouyqf 2 days ago
  • $\begingroup$ I meant do not repeat the "thanks" part (which I have removed). $\endgroup$ – desertnaut yesterday
0
$\begingroup$

I think you can speak of imbalanced targets if (in case of a binary classification problem) the classes are not represented in a 50:50 manner. This is almost always the case.

With about 25/75 in your case, I would see this as „imbalanced“. There are some strategies to deal with this problem, such as (re)sampling so that you achieve a 50:50 balanced sample (essentially you will lose observations in the majority class here). Alternatively you can use synthetic oversampling (SMOTE) and related rechniques.

However, some packages come with built-in options to deal with unbalanced targets, e.g. sklearn‘s random forest (option class_weight). Check the docs.

$\endgroup$

Your Answer

ouyqf is a new contributor. Be nice, and check out our Code of Conduct.

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.