01
How AI, machine learning and deep learning differ
People often use these three terms as if they mean the same thing, but they fit inside each other. Artificial intelligence (AI) is the whole field of getting machines to perceive and decide like people. Inside it is machine learning, which learns from data. Inside machine learning is deep learning, which learns with neural networks that have many layers. The generative AI everyone talks about today is a kind of deep learning model that creates new text or images. Pick a layer in the scene below.
- Layer
- Machine learning
- Examples
- spam filtering, demand forecasting, churn prediction
Lower layers are broader ideas — each upper layer sits inside the one below
Machine learning: Learns the rules from data instead of having people write them. It's one branch of AI.
The key question in machine learning is: who writes the rules? A traditional program has a person write a rule like "if the subject contains 'free' and 'winner', it's spam." With machine learning, you show the computer lots of spam and normal email and let it find the rules itself. It shines when the rules are too many, too complicated, or change too often for anyone to write them all down.
When machine learning isn't a good fit
- The rules are already clear and must always give the same result (tax calculations, a fixed discount policy)
- There's no data to learn from, or far too little
- Mistakes aren't acceptable and every decision has to be explained, but you can't verify the model that well
- Building and maintaining it would cost more than it's worth
If a question says… → pick this
- “Calculates using a fixed formula or rule”No ML needed (ordinary program)
- “Learns patterns from data”Machine learning
- “Artificial neural networks with many layers”Deep learning
- “Creates new text or images”Generative AI
- “Results must always be the same and 100% accurate”A case where ML is not appropriate
We said machine learning learns from data. So what should that data look like?
02
Data, features and labels
Imagine a company that wants to know ahead of time which customers will cancel (churn). It gathers past customer records into a table. Each row is one customer, and the columns hold their age, how many months they've been subscribed, and how much they spend each month. The values the model looks at to make its decision are called features. The last column says whether that customer actually left. That answer, the thing the model has to predict, is called the label.
- Features
- Age, Months subscribed, Monthly spend
- Label
- Churned
- Split
- not split yet
Data for predicting whether a customer will leave (churn) — one row per customer
The first three columns (age, months subscribed, monthly spend) are the features the model looks at. The last column (churned or not) is the answer it has to predict: the label.
You don't train on all of the data. You split it into three sets first. If you think of studying for an exam, the training set is your textbook and workbook, the validation set is a practice test, and the test set is the real exam.
- Training set: the model learns from this data.
- Validation set: used to decide how to build the model. For example, should the decision tree you'll meet in chapter 4 ask two questions or three? How many passes should training make? You build a model for each option and pick the one that does best on the validation set. Values like these, which you set before training, are called hyperparameters. You'll see them again in chapter 6.
- Test set: used once, at the very end, after all the choosing is done, to measure performance.
Why keep the validation and test sets separate? This is the part that trips people up. You picked the model that scored best on the validation set, so it's already tuned to that data, and its validation score comes out a little better than it really is. That's why you measure its real ability on a test set it has never been trained or chosen on. It's like seeing the exam questions before you study: the score no longer tells you what you actually know.
When you don't have much data, you can use cross-validation. Split the data into, say, five parts. Take turns using one part for validation and the other four for training, then average the five results. That way your score depends less on how the data happened to be split. This is called k-fold cross-validation.
| Type of data | Examples |
|---|---|
| Structured data | Tables with rows and columns: customer records, transactions |
| Unstructured data | No fixed columns: text, images, audio, video |
| Labeled data | Comes with answers: emails marked spam or not spam |
| Unlabeled data | No answers: purchase records with no tags |
| Time-series data | The order in time matters: daily sales, sensor readings |
If a question says… → pick this
- “A column (variable) fed into the model as input”Feature
- “The target value you want to predict, the answer”Label
- “Data used to choose hyperparameters”Validation set
- “Evaluates final performance once at the end”Test set
- “Splits data into k parts and validates on each in turn”k-fold cross-validation
- “Images, audio, free-form text”Unstructured data
This table had answers (whether the customer churned). But a lot of data doesn't come with answers. Whether it does or not changes how the model learns.
Advertisement
03
Supervised, unsupervised and reinforcement learning
Machine learning falls into three broad types, depending on what you give the model to learn from. The scene below plots 18 pieces of fruit by weight and sweetness. Switch between the types.
- Learning type
- Supervised learning
- You provide
- data + answers
18 pieces of fruit by weight (across) and sweetness (up)
Every dot comes with the right answer (the fruit). The model uses those answers to learn the boundaries (white lines) between the three fruits. When a new dot arrives, it predicts the fruit from which area the dot lands in.
| Type | What you provide | Typical problems |
|---|---|---|
| Supervised learning | Data + answers (labels) | Classification (is it spam? will they churn?), regression (how much will we sell?) |
| Unsupervised learning | Data only | Clustering (grouping similar customers), association rules (items bought together), dimensionality reduction, anomaly detection |
| Reinforcement learning | An environment to act in, and rewards | Games, robot control, deciding the order of recommendations |
In supervised learning, if you're predicting a category (spam or not, apple / mandarin / grape), it's classification. If you're predicting a number (sales, house prices), it's regression. In unsupervised learning, clustering groups similar things together, but a person still has to work out what each group means. Association rules find things that happen together, like "people who buy diapers also buy beer." You pick rules by how often the items appear together (support), how reliable the rule is (confidence), and how much more often than chance they occur together (lift).
There are also approaches in between. When only some of the data has labels, it's called semi-supervised learning. In self-supervised learning, the model makes its own answers from the data itself. Pre-training an LLM by having it predict the next token in text is an example. RLHF (reinforcement learning from human feedback), which fine-tunes an LLM using people's feedback as the reward, is an application of reinforcement learning.
If a question says… → pick this
- “Trains on labeled data”Supervised learning
- “Predicts a category (yes/no, A·B·C)”Classification
- “Predicts a continuous number (price, demand)”Regression
- “Groups similar items without labels”Clustering (unsupervised learning)
- “Items bought together, support and confidence”Association rules
- “Learns actions that maximize a reward”Reinforcement learning
Once you know the type, you need to pick an actual model. Let's start with the easiest one to understand.
Pro only
That’s the free part of this guide
The other 5 chapters are open to Pro subscribers. Each one continues with 3D visuals and “if a question says…” tips, and the last chapter lets you check yourself with a short quiz.
- 04Common algorithms
- 05Overfitting and underfitting
- 06Loss and gradient descent
- 07Data preparation
- 08Identifying the problem type
PasslyExam
You have read the concept. Now test it on exam questions
PasslyExam offers original practice questions, explanations and full mock exams built around each certification’s exam guide. The explanations cover why the right option is right and why the look-alike options are wrong. Sign up to practice for free every day.