Four-Project Series

Training Models on Imbalanced Text Data you own this product

intermediate Python • basics of NumPy, pandas, and Jupyter Notebook
skills learned
use a dictionary to decode and encode data • learn NumPy array indexing techniques • understand Python dictionary data structure and how to edit and manipulate it
KC Tung
4 weeks · 4-7 hours per week average · ADVANCED

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases

lite $19.99 per month

  • access to all Manning books, including MEAPs!


5, 10 or 20 seats+ for your team - learn more

In this series of liveProjects, you’ll take on the role of a data scientist working for an online movie streaming service. Your bosses want a machine learning model that can analyze written customer reviews of your movies, but you discover that the data is biased towards negative reviews. Training a model on this imbalanced data would hurt its accuracy, and so your challenge is to create a balanced dataset for your model to learn from. You'll collect your company’s data by deliberately introducing imbalance to an IMDb (Internet Movie Database) review dataset, use a sampling technique to balance the dataset, then build a machine learning model from the dataset.

These projects are designed for learning purposes and are not complete, production-ready applications or solutions.

here's what's included

Project 1 Explore IMDb Dataset
In this liveProject, you’ll explore a dataset of movie reviews and prepare it for sentiment analysis. The dataset you've provided is balanced between positive and negative reviews, but is encoded in such a way that you will need to use the dictionary (lookup) in this dataset package to decode the content to plain text. Your challenges will include decoding the data to plain text, and then converting the plain text into tokens in a Pythonic manner.
Project 2 Manipulate Data Distribution
In this liveProject, you will create an imbalanced dataset from the IMDb movie dataset. Your goal is to make a dataset where positive reviews are the minority. You’ll then test a theory that if you oversample positive reviews, you could rebalance the training data to build and train a text classification model. You finish up by examining the model performance with a confusion table, and basic metrics such as precision, accuracy and recall.
Project 3 Generate Text Samples
In this liveProject, you’ll build a deep learning model that can generate text in order to create synthetic training data. You’ll establish a data training set of positive movie reviews, and then create a model that can generate text based on the data. This approach is the basis of data augmentation.
Project 4 Augment Training Data and Classify Text
In this liveProject, you’ll augment text-based training data for a sentiment analysis algorithm with artificially generated positive reviews. You’ll merge the synthetic positive reviews with an unbalanced dataset focused on negative reviews, thereby creating a balanced dataset for your model to train on. You’ll train your model, then evaluate its metrics using sklearn.

choose your plan


only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • Training Models on Imbalanced Text Data project for free

project author

KC Tung
KC Tung is an AI architect, machine learning engineer, and data scientist who specializes in delivering AI, deep learning, and NLP models across enterprise architectures. As an AI architect at Microsoft, he helps enterprise customers with use-case driven architecture, AI/ML model development/deployment in the cloud, and technology selection and integration best suited for their requirements. He is a Microsoft certified AI engineer and data engineer. He has a PhD in molecular biophysics from the University of Texas Southwestern Medical, and has spoken at the 2018 O'Reilly AI Conference in San Francisco and the 2019 O'Reilly Tensorflow World Conference in San Jose.


This liveProject is for Python programmers interested in common tools for encoding data for NLP. To begin this liveProject, you will need to be familiar with the following:

  • Intermediate Python, with basics of NumPy and pandas
  • Basics of Jupyter Notebook
  • Basics of Google Colab notebook
  • Basics of TensorFlow
  • Basics of NLP
  • Basics of deep learning

you will learn

In this liveProject, you’ll learn the basics of encoding and decoding techniques. These are common techniques for solving natural language processing (NLP) problems.

  • Use tf.keras.datasets module for accessing IMDb movie review dataset
  • Learn NumPy array indexing techniques
  • Understand Python dictionary data structure, and how to edit and manipulate it
  • Use a dictionary to decode and encode data


You choose the schedule and decide how much time to invest as you build your project.
Project roadmap
Each project is divided into several achievable steps.
Get Help
While within the liveProject platform, get help from other participants and our expert mentors.
Compare with others
For each step, compare your deliverable to the solutions by the author and other participants.
book resources
Get full access to select books for 90 days. Permanent access to excerpts from Manning products are also included, as well as references to other resources.