Skip to content
All subjects

MachineLearning.

Learn how examples become reliable models through clear concepts, careful data preparation, and honest evaluation.

Modules
8
Topics
44
Data points becoming a learned modelTraining examples appear on a coordinate plane, followed by a line representing the stable pattern learned by a model.EXAMPLES → PATTERNtraining produces a model

0 of 44 complete

Contents

Introduction to Machine Learning

Machine learning helps a computer learn a useful pattern from examples instead of requiring a programmer to write every decision rule by hand.

Start With a Familiar Problem

Imagine an email service that must decide whether a new message is spam. We could write rules such as: if the message contains a certain word, mark it as spam. Real messages are more complicated. Spammers change their words, and a normal message may also contain those words.

A machine-learning system studies many past emails and their correct labels. It learns which combinations of words, links, senders, and other signals are useful. It then uses that learned pattern to classify a new email.

AI, Machine Learning, and Deep Learning

Artificial Intelligence is the broad goal of making computers perform tasks that appear intelligent. Machine Learning is one approach inside AI: it learns patterns from data. Deep Learning is a part of Machine Learning that uses multi-layer neural networks.

PrepLoom keeps ML and DL as separate subjects so that classical ML foundations are learned before neural networks.

Artificial Intelligence
Machine Learning
Deep Learning

Fixed Rules and Learned Patterns

Traditional programming starts with rules written by a programmer. The computer applies those rules to input data and produces an answer.

Supervised machine learning starts with examples and their known answers. A learning algorithm searches for model parameters that connect the inputs to the answers.

Traditional program
Machine-learning system
Rules + data produce answers
Data + known answers produce a model
A programmer writes the decision logic
An algorithm estimates the decision pattern
Best when rules are clear and stable
Useful when patterns are complex but examples exist

What Exactly Is Learned?

A model is a mathematical mapping from input values to an output. Training adjusts the model's parameters so that its outputs become closer to the correct answers in the training data.

For a house-price model, area and number of bedrooms may be inputs. The learned parameters describe how strongly those inputs affect the predicted price.

TermSimple meaningHouse-price example
Example or sampleOne item in the datasetOne house
FeatureInformation given to the modelArea
TargetAnswer to learn or predictSale price
AlgorithmProcedure that learns from dataLinear regression training
ModelThe learned mappingThe fitted price equation
ParameterA value learned during trainingA coefficient
HyperparameterA setting chosen before or around trainingRegularization strength
LossA number measuring prediction errorDifference from the true price
PredictionOutput for a new inputEstimated price
Model notation
y^=f(x)\hat{y}=f\left(x\right)

In plain words: prediction = trained model(input). A lowercase x represents one example.

Training and Inference

Training is the learning stage. The algorithm repeatedly examines training examples, measures errors, and adjusts the model.

Inference is the usage stage. The trained model receives a new input and produces a prediction. Inference normally does not change the model.

Training
Inference
Learns from historical examples
Uses the learned model on new data
Adjusts model parameters
Keeps parameters fixed
Usually requires more computation
Usually needs a quick prediction

The Basic Workflow

A useful ML system begins with a clearly defined problem and ends with an honest test on unseen data. Training a model is only one part of that process.

Machine-learning workflow from defining the task through final testing
Validation helps us make choices. The untouched test set measures the final result.

When Machine Learning Is a Good Choice

Machine learning is useful when the desired pattern is difficult to express as reliable hand-written rules, enough relevant examples are available, and the result can be measured.

  • The same type of decision must be made many times.
  • Past examples contain information about future cases.
  • A clear metric can tell us whether the model is improving.
  • The environment is stable enough for past patterns to remain useful.

When Simple Rules Are Better

Machine learning is not automatically the best solution. If a correct rule is short, stable, and easy to verify, normal programming is clearer and safer.

  • Use a formula for a tax calculation whose rules are explicitly defined.
  • Use validation rules to reject an empty required field.
  • Do not train a model when there is too little reliable data.
  • Do not use an inaccurate prediction where every decision must be provably correct.

Check Your Understanding

Classify each situation before thinking about an algorithm. The first question is whether learning from examples is actually needed.

Problem 01

Is learning useful?

A bank wants to estimate whether a transaction looks fraudulent using patterns from millions of reviewed transactions.

  1. 01The decision depends on many interacting signals.
  2. 02Reviewed past transactions provide examples and correct labels.
  3. 03Performance can be measured on unseen transactions.

Answer

This is a suitable machine-learning problem.

How a basic ML system works

  1. 01Define the input, the required output, and the success measure.
  2. 02Collect examples that represent the real problem.
  3. 03Prepare the examples and separate them into training, validation, and test data.
  4. 04Choose an algorithm and train a model on the training data.
  5. 05Use validation data to compare choices and improve the system.
  6. 06Evaluate the finished model once on the untouched test data.
  7. 07Use the model for inference and monitor whether real data changes over time.

Example

Learning to estimate delivery time

Past deliveries contain distance, traffic, weather, restaurant preparation time, and actual delivery time. Training learns a relationship between those inputs and the actual time. Inference uses the learned model to estimate the time for a new order.

A common mistake

A model does not understand a problem like a person. It learns statistical relationships from the examples and objective it receives.

Actions for Introduction to Machine Learning