What Is Machine Learning? A Plain-English Introduction
In ordinary programming, a person writes the rules: "if the order total is over $50, shipping is free". Machine learning (ML) flips this around. You give the computer examples of inputs together with the answers you want, and an algorithm finds a rule that reproduces those answers. The rule it finds is called a model, and the process of finding it is called training.
ML is one part of the wider field of artificial intelligence (AI), which covers any technique for getting computers to do tasks we associate with human judgment. Most AI products you hear about today are built on machine learning.
When learning beats writing rules
Learning from data is useful when the rule is hard to write down but examples are easy to collect. Nobody can list the rules that separate spam from real email, but millions of emails labeled "spam" or "not spam" exist. The same goes for recognizing speech, recommending a song or estimating a house price. When the rule is easy to write, like the shipping example, plain code is simpler, cheaper and easier to explain.
The main kinds of ML
- Supervised learning: every training example comes with the right answer. Predicting a category ("spam" or "not spam") is classification; predicting a number (a price) is regression. Most of this track is about supervised learning.
- Unsupervised learning: there are no answers, and the algorithm looks for structure, such as grouping similar customers.
- Reinforcement learning: a program learns by trial and error from rewards, as in game-playing systems.
A model in ten lines
The example below "learns" a rule from eight students: how many hours each studied, and whether they passed. The model is as simple as models get, a single threshold: "predict pass if hours studied is at least t". Training means trying each candidate value of t and keeping the one that agrees with the most examples.
Expected output
threshold 1.0: accuracy 0.500 threshold 1.5: accuracy 0.625 threshold 2.0: accuracy 0.750 threshold 2.5: accuracy 0.875 threshold 3.0: accuracy 0.750 threshold 3.5: accuracy 0.875 threshold 4.0: accuracy 0.750 threshold 5.0: accuracy 0.625 Learned rule: predict pass if hours >= 2.5 1.2 hours -> fail 2.8 hours -> pass 4.5 hours -> pass
Two things to notice. First, the learned rule is not perfect even on the data it learned from: one student who studied 3 hours failed, and no single threshold can get every example right. Real data is noisy like this. Second, the model now makes predictions for students it has never seen, which is the whole point. Whether those predictions are any good is a question we can only answer with new data, covered in the train/test chapter.
What a model is not
A trained model does not understand the world the way a person does. It captures patterns in the data it was given, including mistakes and biases in that data. That is why the later chapters spend time on evaluation and on responsible use.
Summary
- ML learns a rule (a model) from examples instead of having it written by hand.
- Supervised learning uses labeled examples: classification predicts categories, regression numbers.
- A model is judged by how well it predicts data it has not seen.
Quiz: What machine learning is