course content

Course Content

Handwritten Digits Recognition: Unlocking the Magic of Machine Learning

Handwritten Digits Recognition: Unlocking the Magic of Machine Learning

Class BalanceClass Balance

Having balanced classes in machine learning is important because it ensures that the model is not biased toward any particular class. A balanced dataset means that there is an equal representation of each class in the dataset. This is important because an imbalanced dataset can lead to a model that performs poorly on the minority class.

For example, if we have a dataset of customer transactions, and 90% of the transactions are legitimate. In comparison, only 10% are fraudulent, a model trained on this dataset may be biased toward classifying all transactions as legitimate. This is because the model would be optimized to minimize overall error, and classifying all transactions as legitimate would achieve high accuracy even though it's not useful.

Therefore, balanced classes ensure that the model is trained on a representative sample of each class and can make accurate predictions for all classes.


  1. Isolate the mnist 'target' in a variable called Y;
  2. Plot the number of values in each class.

Everything was clear?

Section 1. Chapter 4

Start learning today and achieve
coding mastery

  • Master Python, SQL, JavaScript & more.
  • Learn with Step-by-Step Lessons.
  • Get Ready for Real-World Projects.
  • Earn a Certificate Upon Completion.