Sentiment Analysis of Movie Reviews
A review whose rating r is 6 or higher is labeled positive, written as $r \geq 6$.
A Website Full of Opinions
Imagine a film website that shows thousands of short written reviews. Some readers loved the film, and others walked out disappointed. A person can skim a review and usually tell which side it falls on, even without reading every word closely. The open question is how a program could learn to do the same thing.
The name for this task is sentiment analysis: deciding whether a piece of text expresses a positive or a negative sentiment. This article follows one specific collection of movie reviews, the IMDb dataset, to show what that task looks like in practice. As you read, keep track of two things: what goes into the program, and what answer it is trying to produce.
What One IMDb Record Contains
What do you think happens?
Each entry in the dataset holds a review and a positive or negative label. Which part would a model read as its input, and which part is the answer it is trying to predict?
Reveal answer
The review text is the input; the label is the answer to predict.
The source describes the text as the input a model would read and the label as the answer it is trying to predict. Keeping this split in mind makes the rest of the dataset easier to read.
The IMDb dataset draws its reviews from IMDb, the Internet Movie Database, a website where people rate and comment on films. The collection was gathered by the researcher Andrew Maas at Stanford. Each entry holds exactly two pieces of information: the text of one review, and a label saying whether that review is positive or negative.
The diagram shows one record. The dataset is a collection of many such records, and each one follows the same pattern: a review text on one side and its label on the other. The text is never stored without its label in this dataset, which is what makes it useful for teaching a program to predict labels.
Turning a Rating into a Label
The website records ratings on a scale from 1 to 10. The dataset does not keep that full scale for its labels. Instead, it compresses every rating into one of two groups using a single cutoff. A review whose rating r is 6 or higher is labeled positive, written as $r \geq 6$. Every other review, with a rating from 1 through 5, is labeled negative.
Trace the rule across the scale. Starting at 1, each rating is checked against the cutoff: ratings 1 through 5 fall below it and receive the negative label. The rating 6 is the first value that meets the cutoff, so it and every rating above it receive the positive label, up to 10. The diagram below places every rating on the scale and shows which side of the cutoff it lands on.
The rule is one cutoff, so the scale splits into a block of five negative ratings and a block of five positive ratings. A rating of 6 and a rating of 10 end up with the same label, and so do a rating of 1 and a rating of 5. The fine distinctions within each block are discarded once the label is assigned.
Labeling Ratings Step by Step
Applying the threshold rule to four reviews
Four reviews arrive with the ratings 7, 6, 4, and 10. Assign each one its label in the dataset.
- 1Check the rating 7
Is 7 at least 6? Yes, so $7 \geq 6$ holds and the label is positive.
- 2Check the rating 6
This is the boundary case. Is 6 at least 6? Yes, so $6 \geq 6$ holds and the label is positive. A rating of exactly 6 is included in the positive group.
- 3Check the rating 4
Is 4 at least 6? No, so the condition fails and every rating from 1 through 5 is labeled negative. The label is negative.
- 4Check the rating 10
Is 10 at least 6? Yes, so the label is positive. The top of the scale gets the same label as the cutoff value 6.
Rating 7 is positive, rating 6 is positive, rating 4 is negative, and rating 10 is positive.
Why Two Classes
A classification problem asks a model to assign each input to one of a fixed set of categories. A two-class classification problem is the simplest version of this, because it has exactly two possible outcomes. In the IMDb dataset those outcomes are positive and negative. Every review belongs to exactly one of the two groups, and the model's job is to predict which group that is from the review text.
The compression from a ten-step scale to two groups is a deliberate modeling choice. The source gives the practical reason: a two-way label is easier to model than a ten-step scale, and the threshold rule turns a numerical rating into a category a classifier can predict. The source treats this as a simplification rather than a claim that two labels fully describe how people feel about a film.
Labeling New Reviews by Hand
A new review on the film website has a rating of 5. Using the threshold rule, what label should it receive, and what would change if its rating were 6 instead? Explain your answer by naming the cutoff.
Hints
- Compare the rating with the cutoff: is it 6 or higher?
- Check the boundary: the rating 5 is one step below the cutoff, and the rating 6 is exactly at it.
Without looking back, list the ratings from 1 to 10 that receive the negative label and the ones that receive the positive label. Then check your list against the rule $r \geq 6$.
Hints
- Start from the cutoff and work outward in both directions.
- Count how many ratings fall in each group; the two groups should together cover every rating from 1 to 10.
Common Mistakes With the Threshold
Common mistake Treating the label as the original 1-to-10 rating
What it looks likeAssuming a review labeled positive must have a rating of 8 or 9.
Why it failsThe dataset does not keep the full scale for its labels. A positive label only means the rating was 6 or higher.
Do this insteadRemember that a positive label covers ratings 6 through 10, and a negative label covers ratings 1 through 5.
Common mistake Placing the cutoff at 5 instead of 6
What it looks likeLabeling a rating of 5 as positive because it is in the middle of the scale.
Why it failsThe rule is $r \geq 6$, so 5 does not meet the cutoff and falls in the negative group.
Do this insteadCheck each rating against 6 exactly, and remember that 6 itself is positive.
Common mistake Assuming ratings within one group are treated differently
What it looks likeThinking a rating of 1 is more negative than a 5 in the labeled dataset.
Why it failsBoth fall in the same group, and the single cutoff gives them the same label.
Do this insteadAccept that the labels capture only which side of the cutoff a rating is on.
Common mistake Confusing the review text with the label, and treating the label as something a model should read as input
Recap of the Labeling Rule
- Each IMDb dataset entry pairs the text of one review, the input, with a positive or negative label, the answer to predict.
- The website's 1-to-10 rating is compressed by one rule: a rating of 6 or higher is positive, and 1 through 5 are negative.
- Because each review falls into exactly one of two groups, the dataset is treated as a two-class classification problem.
- A two-way label is easier to model than a ten-step scale, which is the practical reason for the simplification.
Key Takeaways
- Sentiment analysis decides whether a piece of text expresses a positive or negative sentiment, and the IMDb dataset is a running example of this task.
- Each record pairs the review text, which is the model's input, with a label, which is the answer it predicts.
- The threshold rule labels a rating of 6 or higher as positive and every rating from 1 through 5 as negative, using the cutoff $r \geq 6$.
- Treating the labels as two classes makes the task a two-class classification problem, a simplification chosen for practical modeling reasons.