2
$\begingroup$

i'm performing a binary classification task , and after cheking the target variable , i saw that i had 69% of 0's and 31% of 1's , so , my question is , do i have in this case a unbalanced target variable ? and can somebody tell me , if there is a threshold , or when to consider a Target Variable unbalanced ?

Thanks to everyone

$\endgroup$
0

2 Answers 2

1
$\begingroup$

There's not a strict threshold about what ratio is considered as unbalanced. But in general, 30 percent is not usually a sign of unbalanced classification.

You can although try different methods for checking if your classification method is accurate and predicts correctly or not, like resampling, over-sampling, under-sampling

  1. increasing the number of records (samples) in the class with less frequency.

  2. randomly removing the samples from the class with higher frequency.

...

from sklearn.utils import resample 
$\endgroup$
0
$\begingroup$

In general, there is no strict definition of imbalanced dataset, but in your case, I suggest you use nonsensitive algorithms, loss functions, and evaluation metrics.

There are many useful metrics which were introduced as loss function and also for evaluating the performance of classification methods for imbalanced data-sets. Some of them are Kappa, CEN, MCEN, MCC, and DP.

If you use python, PyCM module can help you to find out these metrics.

Here is a simple code to get the recommended parameters from this module:

>>> from pycm import *

>>> cm = ConfusionMatrix(matrix={"Class1": {"Class1": 1, "Class2":2}, "Class2": {"Class1": 0, "Class2": 5}})  

>>> print(cm.recommended_list)
["Kappa", "SOA1(Landis & Koch)", "SOA2(Fleiss)", "SOA3(Altman)", "SOA4(Cicchetti)", "CEN", "MCEN", "MCC", "J", "Overall J", "Overall MCC", "Overall CEN", "Overall MCEN", "AUC", "AUCI", "G", "DP", "DPI", "GI"]

After that, each of these parameters you want to use as the loss function can be used as follows:

>>> y_pred = model.predict      #the prediction of the implemented model

>>> y_actu = data.target        #data labels

>>> cm = ConfusionMatrix(y_actu, y_pred)

>>> loss = cm.Kappa             #or any other parameter (Example: cm.SOA1)
$\endgroup$

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