Answers.Body: <p>My favorite first alternative is change the error/cost function in order to penalize more the errors in the less frequent label.</p>
  <p>About other alternatives (generate synthetic cases, ..) you can easily Google for &quot;imbalanced data&quot;. Some easy to understand articles will appear, as:</p>
  <p><a href="https://machinelearningmastery.com/tactics-to-combat-imbalanced-classes-in-your-machine-learning-dataset/" rel="nofollow noreferrer">https://machinelearningmastery.com/tactics-to-combat-imbalanced-classes-in-your-machine-learning-dataset/</a></p>
  <p>who suggest 8 groups of solutions, four concrete:</p>
  <ul>
  <li>Collect More Data</li>
  <li>Change Performance Metric</li>
  <li>Resampling</li>
  <li>Generate Synthetic Samples</li>
  </ul>
  <p>and four more generic:</p>
  <ul>
  <li>Try Different Algorithms</li>
  <li>Try Penalized Models</li>
  <li>Try a Different Perspective</li>
  <li>Try Getting Creative</li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-02-13T11:19:05.423Z
Answers.LastActivityDate: 2022-02-13T11:28:05.120Z
Answers.LastEditDate: 2022-02-13T11:28:05.120Z
Answers.UserDisplayName: pasaba por aqui
Answers.Body: <p>&quot;the model always predict 0 and for this reason, it is not good.&quot;</p>
  <p>If accuracy is the performance metric that is of most interest for your application then this may well be the ideal behaviour if the density of positive patterns is not higher than the density of negative patterns anywhere in the feature space.</p>
  <p>You need to determine what is the appropriate performance metric for your application <em>before</em> deciding what to do.  In imbalanced learning problems it is common for false-positive and false-negative misclassification errors to have different costs, in which case the first thing to do is to use cost-sensitive learning and incorporate these costs into the training criterion.</p>
  <p>I'd also advise using a probabilistic classifier (e.g. logistic regression, neural net, kernel logistic regress, Gaussian process classification) that gives the probability of class membership rather than a hard yes/no classification as then the misclassification costs can be changed without having to re-fit the model.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-01T09:31:17.030Z
Answers.LastActivityDate: 2022-05-01T09:31:17.030Z
Answers.UserDisplayName: Dikran Marsupial
Body: <p>I have a dataset that I want to use for training.
  The output of the model is a binary value (0,1)</p>
  <p>The dataset is not balanced, it has only 200 entries for output 1 and 4000 entries for output 0.</p>
  <p>When I tried to use it with LightGMB, the model always predict 0 and for this reason, it is not good.</p>
  <p>How can deal with an unbalanced dataset?</p>
  <p>One way that I can think of it is to delete several of 0 entries and only use around 200  entries with an output of 0.</p>
  <p>This is not good, as the model can not see all datasets.</p>
  <p>What is the best way to deal with unbalanced datasets?</p>
  
Tags: <machine-learning><imbalanced-datasets>
Title: How to deal with datasets which are not balanced?
UserDisplayName: mans
ThreadText: # How to deal with datasets which are not balanced?
  
  (Asked by: username_0 on 2022-02-13)
  
  I have a dataset that I want to use for training.
  The output of the model is a binary value (0,1)
  
  The dataset is not balanced, it has only 200 entries for output 1 and 4000 entries for output 0.
  
  When I tried to use it with LightGMB, the model always predict 0 and for this reason, it is not good.
  
  How can deal with an unbalanced dataset?
  
  One way that I can think of it is to delete several of 0 entries and only use around 200 entries with an output of 0.
  
  This is not good, as the model can not see all datasets.
  
  What is the best way to deal with unbalanced datasets?
  
  **Tags:** machine-learning, imbalanced-datasets
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2022-02-13. Score: 2
  
  My favorite first alternative is change the error/cost function in order to penalize more the errors in the less frequent label.
  
  About other alternatives (generate synthetic cases, ..) you can easily Google for "imbalanced data". Some easy to understand articles will appear, as:
  
  <https://machinelearningmastery.com/tactics-to-combat-imbalanced-classes-in-your-machine-learning-dataset/>
  
  who suggest 8 groups of solutions, four concrete:
  
  * Collect More Data
  * Change Performance Metric
  * Resampling
  * Generate Synthetic Samples
  
  and four more generic:
  
  * Try Different Algorithms
  * Try Penalized Models
  * Try a Different Perspective
  * Try Getting Creative
  
  
  ---
  
  ### Answer by username_2 on 2022-05-01. Score: 0
  
  "the model always predict 0 and for this reason, it is not good."
  
  If accuracy is the performance metric that is of most interest for your application then this may well be the ideal behaviour if the density of positive patterns is not higher than the density of negative patterns anywhere in the feature space.
  
  You need to determine what is the appropriate performance metric for your application *before* deciding what to do. In imbalanced learning problems it is common for false-positive and false-negative misclassification errors to have different costs, in which case the first thing to do is to use cost-sensitive learning and incorporate these costs into the training criterion.
  
  I'd also advise using a probabilistic classifier (e.g. logistic regression, neural net, kernel logistic regress, Gaussian process classification) that gives the probability of class membership rather than a hard yes/no classification as then the misclassification costs can be changed without having to re-fit the model.
  
  
  ---
  
  