Balance The Distribution of a Binary or Nominal Variable
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Sinan Islam
le 10 Juil 2016
Réponse apportée : Image Analyst
le 10 Juil 2016
Hello,
I am trying to predict a binary target with True/False possible values. The dataset consists of 500 observations, 400 observation is False, and 100 observation is True. In order to avoid model bias, I wish to balance the distribution such that the dataset will consist of 100 False and 100 True observations.
Is there a function in MATLAB that automatically balance binary or nominal distribution? Thank you.
0 commentaires
Réponse acceptée
Image Analyst
le 10 Juil 2016
Just get a random distribution and threshold it. To get 500 observations with about 400 false and 100 true, do this
observations = rand(1, 500) > 0.8;
To get 100 true and 100 false, on average, do this
observations = rand(1, 200) > 0.5;
0 commentaires
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!