I am working on a classification model where my target class is a biased class with the class shape as

    0     1 
 20694   101

Most of my features are the count of number of times a certain event was triggered. While exploring these features I found that my target variable is only associated with certain values of features. For example as below

                 0         1
Feature V1      
0                12014    75
1                6490     16
2                1177     6
3                402      2
4                176      2
5                100    
6                84 
7                61 
8                39 
9                23 
10               26 
11               14 

As we can see that 1 only occurs when V1 has value of 0 to 4.Thus for any unseen data my model would always predict 0 whenever V1 has value greater than 4.

I thought of using bestNormalize package, however the transformations it is suggesting looses correlation when applied to the data.

Any suggestion would be of great help.

Thanks a lot in advance!!

P.S. Happy to share the data if required.


Some thoughts:

  1. Your data is highly imbalanced. This is a critical issue which should be dealt with. Possible solutions include simple under-/over-sampling to more complicated synthetic approaches like SMOTE.
  2. Decision trees and random forests do not require feature scaling - this means that normalisation is not needed (unless perhaps you plan on using some other modelling technique which uses regularisation).
  3. Just because this data set only shows a particular relationship between values of V1 and target does not mean it is always the case - especially if your model is to be deployed for a period of time. The relationship may change over time so do not rush to artificially curtail your model.

I think the easiest option is to clear the features which have no class '1' in it. It is not forbidden not to use every future in your algorithm. Always keep in mind that your full model is super unbalanced and if you built a model which predicts always class '0' , you will get an accuracy from: 0,995% . Probably in this case it is more interessting to tune your algorithmus, that he identifies your class '1' correctly, so I would built an algorithmus who focus to identify the most '1' correctly.


I think SMOTE is the best approach to try out first and if you want to try further look into the XGBoost parameters especially Scale_pos_weight is the ratio of number of negative class to the positive class.

Suppose, the dataset has 90 observations of negative class and 10 observations of positive class, then ideal value of scale_pos_Weight should be 9. You can check this link.


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.