How to Check if your Dataset is Balanced

In this free 10-minute A.I. programming tutorial, you will learn how to check if your dataset is balanced.  We will be using Python, PyTorch and Google Colab.  You will be coding along with the instructor.

Level:  Beginner
Time:  10 minutes
Equipment:  Your own PC or laptop


How to Check if your Dataset is Balanced (10 minutes)

In this free 10-minute tutorial, you will get an overview of why it’s important to always check if your dataset is balanced when developing A.I. projects.  You will write your own dataset balance checker by following along with the instructor using Google Colab.  After completing this tutorial, you will be able to verify if your dataset is balanced and take the proper action to fix it if necessary!  This tutorial will be using Python and the PyTorch deep learning library.  Our coding will be done using Google Colab.  No prior experience is necessary.

Step 1 – Import PyTorch and Datasets from Torchvision

First you will import PyTorch and Datasets from Torchvision.

Step 2 – Build your Dataset Balancer Checker

Here you will build a function that takes the dataset and the name of the dataset as inputs and prints out the class instance summary.

Step 3 – Test your Checker on Real Datasets

You will be using MNIST and FashionMNIST.

Next Steps

If you want to learn more about developing your own A.I. projects, take the 4-week on-demand Introduction to A.I. programming course!

Happy Learning! team

Get Free A.I. Tutorials In Your Inbox

It’s Free, No Spam, Opt-Out Anytime