Revision notes

Machine Learning Basics: Foundation

The key points, rules to remember, tables and diagrams from all 5 lessons, on one page for quick revision. To keep a copy, use your browser's Print and choose "Save as PDF".

Lesson 1

What machine learning is: learning from examples instead of rules

How machine learning builds a model

  1. Labelled examples Emails people have already marked as spam or not spam.
  2. Learning program Studies the examples and finds the patterns by itself.
  3. Model A set of learned patterns.
  4. Prediction The model judges new emails it has never seen.
Two ways to make a computer solve a problem
ItemOrdinary programmingMachine learning
InputData + hand-written rulesData + correct answers (examples)
OutputAnswersA model (learned rules) that can give answers
When the world changesA person rewrites the rulesRetrain the model on new examples
Good forClear, fixed logic (tax slabs, interest formulas)Patterns too complex to write down (faces, speech, spam)

Ordinary programming: data + rules give answers. Machine learning: data + answers give the rules (the model).

Splitting labelled data before training

  1. Labelled data Split into two parts before training.
  2. Training set Used to learn; commonly about 80%.
  3. Test set Kept hidden during training; commonly about 20%.
  4. Final check Shows how well the model handles examples it has never seen.
  • Machine learning means learning patterns from examples rather than following hand-written rules.
  • Features are the inputs; the label is the answer to be predicted; the model links them.
  • Keep a test set aside and judge the model only on data it has not seen.
Read the full lesson

Lesson 2

Types of machine learning: supervised, unsupervised and reinforcement

Types of machine learning

  • Supervised learning
    • Every example has its correct label
    • Classification: the label is a category
    • Regression: the label is a number
  • Unsupervised learning
    • The data has no labels
    • Clustering: groups similar examples
    • Spotting unusual examples
    • Reducing many features to a few
  • Reinforcement learning
    • An agent acts in an environment
    • Learns from rewards or penalties
    • Trial and error builds a policy

Ask: is the answer a category or a quantity? Category = classification. Quantity = regression.

How a reinforcement learning agent learns

  1. Agent takes an action In its environment: exploring new actions or repeating ones known to work.
  2. Reward or penalty Received after the action.
  3. Policy improves By trial and error it learns actions that earn the most reward over time.

Then back to step 1: Agent takes an action

The three main types at a glance
TypeData neededGoalExample
Supervised - classificationLabelled examples; label is a categoryPredict the categorySpam filter
Supervised - regressionLabelled examples; label is a numberPredict the quantityHouse price prediction
Unsupervised - clusteringUnlabelled examplesFind natural groupsCustomer groups
ReinforcementAn environment that gives rewardsLearn actions that maximise rewardGame-playing program
  • Supervised = labelled data; classification predicts categories, regression predicts numbers.
  • Unsupervised = no labels; clustering finds groups of similar examples.
  • Reinforcement = an agent learns from rewards by acting in an environment.
Read the full lesson

Lesson 3

Common machine learning algorithms explained in plain words

Is the applicant's monthly income above ₹30,000?

  • No
    • Predict 'reject'
  • Yes: more than two existing loans?
    • Yes: predict 'reject'
    • No: predict 'approve'
An illustrative tree, not a real lending rule.

The two repeating steps of k-means

  1. Assign Put each point with its nearest centre.
  2. Update Move each centre to the average of the points assigned to it.

Then back to step 1: Assign

You choose k first; the steps repeat until nothing changes.
Four algorithms compared
AlgorithmTypePredictsMain ideaWatch out for
Linear regressionSupervisedA numberBest-fitting straight lineFails when the relationship is curved
Decision treeSupervisedCategory or numberChain of yes/no questionsDeep trees memorise noise
k-nearest neighboursSupervisedUsually a categoryMajority vote of the k closest examplesSlow on large data; needs scaled features
k-meansUnsupervisedGroup membershipMove centres to the average of their pointsk must be chosen; result depends on the start

Line for numbers (linear regression); questions for decisions (tree); neighbours vote (k-NN); centres move to averages (k-means).

  • Linear regression and decision trees learn from labelled data; k-means needs no labels.
  • k in k-NN is the number of neighbours that vote; k in k-means is the number of groups.
  • Simple methods are often tried first because they are fast and easy to explain.
Read the full lesson

Lesson 4

Neural networks and deep learning: neurons, layers and weights

Inside one artificial neuron

  1. Inputs Some input numbers.
  2. Multiply by weights Each weight says how important that input is.
  3. Add the bias The weighted inputs are added up with a starting offset.
  4. Activation function Decides the output; ReLU outputs the total if positive, else 0.

How training adjusts the weights

  1. Forward pass Feed in a training example and compute the output.
  2. Measure the error A loss function says how far the output is from the correct label.
  3. Backpropagation Work backwards to find how much each weight contributed to the error.
  4. Gradient descent Nudge every weight a little to reduce the error, by the learning rate.

Then back to step 1: Forward pass

Training starts from small random weights; one full pass through the training set is an epoch.

Neuron: multiply inputs by weights, add the bias, apply the activation. Training: forward pass, measure error, backpropagate, adjust weights, repeat.

  • A neuron = weighted sum + bias + activation; weights and biases are the learned parameters.
  • Training uses backpropagation and gradient descent to reduce the error step by step.
  • CNNs suit images (filters); transformers suit language (attention).
Read the full lesson

Lesson 5

Doing machine learning well: overfitting, bias, accuracy and the workflow

Comparing training and test scores
SituationTraining scoreTest scoreTypical fixes
UnderfittingLowLowUse a more flexible model, add useful features, train longer
Good fitHighClose to trainingKeep it; check it on new data regularly
OverfittingVery highMuch lowerMore data, a simpler model, stop training earlier, limit tree depth

Three ways to score a fraud model

  • Accuracy
    • Share of predictions that are correct
    • Misleading when one class is rare
    • Lazy model: 990 ÷ 1,000 = 99%, but catches no frauds
  • Precision
    • Of the transactions flagged, how many were really fraud?
    • Better model: 8 ÷ 20 = 40%
  • Recall
    • Of all the real frauds, how many were caught?
    • Better model: 8 ÷ 10 = 80%

High training score + low test score = overfitting. Low on both = underfitting. For rare events, look at precision and recall, not accuracy alone.

The ML workflow

  1. Collect Data that matches the real task and people.
  2. Clean Fix errors, missing values, duplicates and labels.
  3. Train Train models; tune settings on a validation set.
  4. Test Once, on the untouched test set.
  5. Deploy Put it into use in an app, website or office process.
  6. Monitor Keep checking results; retrain when needed.
TermMeaning
ParameterA number the model learns from data, such as a weight
HyperparameterA setting chosen by people before training, such as k in k-NN or the learning rate
Validation setData held back to compare models and tune hyperparameters, separate from the test set
EpochOne full pass through the training data
InferenceUsing a trained model to make predictions
Data driftThe real-world data slowly changing so the model becomes less accurate
OverfittingMemorising training data, doing badly on new data
UnderfittingToo simple to learn the pattern, doing badly everywhere
  • Compare training and test scores to spot overfitting and underfitting.
  • Biased data produces biased models; check results for every group.
  • Choose measures that fit the problem, and keep monitoring a model after it goes live.
Read the full lesson

Privacy · Terms · Refunds · Delivery