SproutStackSproutStack home

Machine Learning in Plain English

5 min readBeginner-friendlyFree to read

Read a little, play a little. No scary maths, and no rush.

Share:

The spam-filter story

You collect 5,000 emails, each labeled spam or not. For every email you measure things: does it contain "free"? How many exclamation marks? Is the sender known? Those measurements are features — the inputs. The label (spam/not) is the answer to learn.

Training means finding weights for those features that separate spam from ham. Prediction means applying those weights to a brand-new email. Nobody wrote a rule about "free money"; the weights discovered that "free" + "!!!" + unknown sender ≈ spam.

from sklearn.feature_extraction.text import CountVectorizer
from sklearn.naive_bayes import MultinomialNB

vec = CountVectorizer()
X = vec.fit_transform(["free money now", "meeting notes"])
model = MultinomialNB().fit(X, [1, 0])  # 1 = spam, 0 = ham

Three flavors of learning

  • Supervised: labeled pairs in, predictions out (email → spam?). Most beginner work lives here.
  • Unsupervised: no labels — find structure (cluster customers, compress data). Nobody grades it; usefulness is judged by humans.
  • Reinforcement: trial, reward, repeat (game playing, RLHF preference tuning). Powerful, sample-hungry, fiddly.

The golden split (non-negotiable)

Train on 70%, tune on 15% (validation), judge once on 15% (test) — and never tune on test, or your score is fiction. If test performance drops while training improves, that's overfitting: memorizing quirks instead of learning patterns. Fixes in order: more data, simpler model, regularization.

A second example: predicting a number

Spam filtering picks a category, which is called classification. Plenty of problems want a number instead, which is called regression.

Take house prices. Each past sale gives you features (floor area, bedrooms, distance to the station, age of the building) and a label (the price it sold for). Training finds how much each feature moves the price: perhaps every extra square meter adds a fixed amount, and every kilometer from the station subtracts some. Prediction applies those learned amounts to a house that has not sold yet.

You then measure how far off the predictions are on houses the model never saw, for example "on average within 6% of the real price." That number, not the model's confidence, tells you whether it is useful.

A model learns whatever the data teaches

Training has no idea what you intended. It finds patterns that predict the label, including ones you would never approve of. A loan model trained on past decisions will copy past bias. A model that sees ZIP code may learn to use it as a stand-in for things it should not use.

So the questions that matter most are often about data, not algorithms: Where did these labels come from? Who is missing? Does yesterday's data still describe tomorrow?

Where LLMs fit

LLMs are machine learning too. They are trained on a simple task (predict the next word) using enormous amounts of text. The labels come from the text itself, so nobody labels anything by hand; this is called self-supervised learning. Later stages add human feedback, which is a form of reinforcement learning. The vocabulary in this chapter (features, training, overfitting, test sets) carries straight into the LLM chapters.

Remember this

  • Features in, labels out; training finds the weights, prediction applies them.
  • Split 70/15/15, tune on validation, judge once on test.

Check your understanding

5 questions · first-try answers earn the most XP

1. In a spam classifier, "contains the word free" is an example of what?
2. Why is tuning hyperparameters against the test set a methodological problem?
3. What is the difference between supervised and unsupervised learning?
4. Training accuracy keeps improving while validation accuracy drops. What does that indicate?
5. Why do we bother training on features at all rather than asking a human to write the spam rule?

My notes

Saved in this browser. Highlight a line above and save it, or write it in your own words.

Nothing saved yet. Your highlights will live here.

References

Finished reading?

Ticking it here also ticks the chapter in the sidebar, the section count and your streak — it is all one number.

Related chapters

Spotted a mistake or want a topic covered? Report an issue

📬 An occasional email when new lessons land

New lessons and showdowns, no more than a few times a month. No spam, unsubscribe anytime. We store your email only to send the newsletter.