SplitDecide what the model may see
Every review arrives as free text with one human label, positive or negative. When the labeled set is big enough, the trainer holds back a stratified slice, scores itself on reviews it did not fit, then refits on everything. The deployed demo ships with ten sample reviews and fits on all of them, so what it shows you is behavior, not a benchmark.
VectorizeTF-IDF turns words into weight
A classifier cannot read. TF-IDF scores each term by how often it appears in one review against how common it is everywhere, so filler words weigh almost nothing. I fit two vectorizers side by side: word unigrams and bigrams, so “was bad” counts as its own feature, and character three to five grams, which keep working through typos and odd spacing.
PlaceSimilar reviews land near each other
Plotted, those vectors give the picture the rest of this chapter is built on. Reviews worded alike sit close together and the two labeled groups pull apart. The two axes stand in for a space with one dimension per feature, far wider than any screen; the geometry is the point, not the picture.
CompareThe simplest honest answer first
You can classify a new review without training anything: find the five nearest labeled reviews and let them vote. k-nearest neighbors is the clearest way to see what similarity means in this space, and it is where my data mining coursework started. It keeps every example instead of learning from them, which is exactly why it is not what I shipped.
WeighThe shipped model draws a line
Movie Mood Machine does not take a vote. Logistic regression learns one weight per term and adds them up, and that sum is a single boundary through the whole space. A prediction becomes two facts: which side of the line a review falls on, and how far from it.
DecideA label, and how sure it is
That distance goes through a logistic curve, which turns it into a probability. The app reports both sides rather than a bare verdict, because a review sitting on the line and one sitting far from it should not look the same to the person reading the result.
ShipShow the words, then serve it
The same weights say which terms pushed a prediction, so the app lists them instead of asking for trust. The fitted pipeline is saved with joblib, the container is a slim Python image, and one small JSON endpoint answers the page: post a review, get the label, both probabilities and the signals behind them.