01Chapter 1: What sentiment analysis is and how to frame itSentiment analysis is the task of assigning an opinion label to a piece of text, such as "positive", "negative", or "neutral". This chapter covers how to frame the task before you write any model code. Framing decides which labels you need, what data you must collect, and which metrics make sense la7 min read
02Chapter 2: Where labels come from: star ratings, annotation, and weak labelsA sentiment classifier can only learn what its labels teach it. This chapter covers the three main ways to get labels (star ratings, human annotation, and weak labeling), the biases each one brings, and how to check label quality before you train anything.7 min read
03Chapter 3: Cleaning noisy text: URLs, mentions, hashtags, emojis, and casingYou should be comfortable with Python, regular expressions at a basic level, and the idea of a train/test split. You do not need to know TF-IDF or transformers yet. Later chapters cover those. This chapter explains how to prepare reviews and social posts so that the signal that carries sentiment sur6 min read
04Chapter 4: A quick baseline with a sentiment lexicon (VADER)This chapter assumes you can run Python scripts, install packages with pip, and read a dictionary of scores. It also assumes you know the labels from the first chapter: positive, negative, and neutral. You do not need any machine learning for this chapter. A lexicon scorer is the cheapest baseline y6 min read
05Chapter 5: Turning text into features with TF-IDFThis chapter assumes you can run Python with scikit-learn installed. It also assumes you know what a training set and a test set are, and that you have read the earlier chapters on framing the task and normalizing noisy text. A classifier cannot read sentences, so it needs numbers. TF-IDF is the sta5 min read
06Chapter 6: Training a logistic regression classifierThis chapter assumes you know basic Python, can install packages with pip, and understand the idea of supervised learning: you train on labeled examples and predict labels for new ones. It also assumes you have seen TF-IDF features, which turn each text into a vector of weighted word counts. Here yo6 min read
07Chapter 7: Measuring performance: precision, recall, F1, and the confusion matrixThis chapter assumes you can train a scikit-learn classifier, such as the TF-IDF and logistic regression baseline from earlier chapters. It also assumes you know what a train/test split is. Here you learn to judge a sentiment classifier honestly. A single accuracy number hides most of what matters, 6 min read
08Chapter 8: Handling imbalanced classes and the neutral labelThis chapter covers two problems that appear in almost every real sentiment dataset. Some classes have far fewer examples than others, and the "neutral" class is hard to define. It assumes you can train the TF-IDF and logistic regression baseline from the previous chapters and read a classification 6 min read
09Chapter 9: Using a pretrained transformer modelThis chapter assumes you can run Python with pip-installed packages, know the basic supervised learning vocabulary (training data, test data, predictions), and have already built the TF-IDF and logistic regression baseline and the evaluation tools from the earlier chapters. The goal here is to run a6 min read
10Chapter 10: Why negation, sarcasm, and slang cause errorsThis chapter explains why sentiment models fail on certain kinds of language, and how to find those failures in your own data. It assumes you can run Python and scikit-learn, and that you have met the VADER lexicon baseline, the TF-IDF plus logistic regression baseline, and precision, recall, and F17 min read
11Chapter 11: When a model trained on reviews meets social postsThis chapter assumes you can train and evaluate a TF-IDF plus logistic regression classifier, read a classification report and confusion matrix, and run a Hugging Face pipeline. It covers what happens when you move a trained sentiment model to a different kind of text, how to detect the drop in qual7 min read
12Chapter 12: Fine-tuning a transformer on your own labeled dataThis chapter shows how to adapt a pretrained transformer to your own sentiment labels, and how to decide whether that effort is worth it. It assumes you have read the earlier chapters on labeled data, evaluation metrics, class imbalance, and pretrained transformer models. You should also be comforta5 min read
13Chapter 13: Going beyond one label: aspect-based sentimentThis chapter assumes you can run Python, have scored text with VADER, and know how a TF-IDF classifier is evaluated with precision, recall, and F1. It also assumes you have seen a pretrained transformer used through the Hugging Face pipeline API.6 min read
14Chapter 14: Reading your errors and using results responsiblyThis chapter assumes you can train and score a sentiment classifier (a lexicon such as VADER, a TF-IDF plus logistic regression baseline, or a pretrained transformer). You should also know precision, recall, F1, and how to read a confusion matrix. Here we look at what to do after you have a number. 6 min read