Chapter 1 : Machine Learning part 1
1. Introduction
Objectives of this chapter
• Gain an intuitive understanding of machine learning (ML)
• Know when and where to apply ML, and when not
• Know the core terminology
• Know how to prepare datasets for ML
• Know a few of the most common model types, when to apply them, and how
• Common pitfalls like data leakage and overfitting
Exam : no formulas need to be known but they could help for the practical. Ony
metric formulas need to be known which are simple.
2. What is machine learning
ML is not the same as statistics.
Statistics Machine learning
Draws population inferences from a sample Finds generalizable predictive patterns
Take a sample and answer question about Take a sample and also look at the
a population population for patterns to predict future
events (on a certain model)
Aims to answer questions about a whole Aims to learn patterns that work well on
population from a sample new, unseen data.
→ Answering precise hypotheses → Refining pattern to sometime make
predictions
Explains Predicts
Choose the method that fits the goal. If you want to understand relationships or
effects, use statistical inference. If you want to make predictions or classifications,
use supervised learning.
Statistics examples
• Does the medication positively affect blood-pressure?
• Which genes are differently expressed between healthy and diseased tissue?
• Is skin lesion irregularity associated with malignancy?
Machine learning examples
• Which patients will benefit most from the blood-pressure medication?
• Is a tissue healthy or diseased given gene expression data?
• Is a skin lesion malignant or not?
1
,Machine learning
Artifical intelligence
Artificial intelligence is the broad field.
Anything intelligence that is artificial.
We use computers and give them a lot
of example data to make prediction and do something that seems intelligence.
Machine learning
Machine learning is a part of it that learns from data.
Deep learning
Deep learning is a kind of machine learning that uses many layer neural networks.
Deep learning : we stack different models in layers and sometimes these layers
interact.
Important : Not all ML is deep learning, and not all AI uses machine learning.
Traditional programming vs ML
Rule-based programming starts from hand-
written rules and applies them to data.
Supervised machine learning starts from data
and correct answers (labels) and learns the
rules (the model). The main work shifts from
writing rules to building a good dataset.
We take expected output and data and put
this in computer and computer writes the
program (model of the data). So it turns
around programming.
3. Mapping biomedical problems to ML tasks
Machine learning tasks
2
,Clear inputs (features) and outputs (targets) guide the choice of loss, metric, and
model.
We have 2 types of ML tasks :
• Regression : predicting a number (continuous value)
o You give the model input features and it outputs a number
o For example : a lab value
• Classification : predicting a category (discrete class or label)
o You give the model input features and it outputs a category
o For example : healthy vs diseased
Supervised learning = the model learns from labelled examples where both the
input and the correct output are provided.
Unsupervised learning = the model learns patterns from data without labels,
discovering structure on its own.
Mole example
We want to determine whether skin moles are benign or malignant using machine
learning. Because we already know the correct diagnosis for each mole, this is a
supervised learning problem.
1. Start with raw data = images of moles.
2. Extract measurable properties, we turn these images in numbers
Parameters : eccentricity (how round round) and solidity (how uniform the color or
texture). These numerical descriptions are called features.
3. Pair features with the correct diagnosis (label, or target) to train a model.
High‑quality features and accurate labels are both essential for good performance.
By pairing these features with the correct diagnosis (the label: benign or
malignant), we can train a model to learn the relationship between appearance
and outcome.
Samples, features, and targets
A dataset is a table with :
• Samples = rows
o Each row is a sample, example, or instance
• Features = columns
o Most columns are features + 1 column is the target or label.
• Target = outcome we want to predict
o We want the machine to predict the label with the samples and
features.
A density plot can be made that shows how one feature is distributed across the for
each target class in a dataset. So to show feature distribution.
Looking at one feature at a time can show partial class separation, but real
strength comes from combining features. We can also already classify by choosing
a threshold on this density plot.
3
, Density plot
A density plot like this can help you choose a threshold for that single feature,
although such one‑feature thresholds are usually limited.
The plots shows :
• Good sign : The distributions are not completely overlapping, so
Eccentricity helps distinguish the classes.
• Bad sign : Some overlap remains → no perfect separation → predictions
won't be 100% accurate.
Overlapping = the feature is not good to make predictions because it does not give
information for separation.
If we put a threshold manually we already get a very simple model. But we need
terms for mistakes.
A threshold is a cut-off value on the feature. You can visually choose a threshold
using the density plot. This creates a simple model : one feature, one rule.
Once you apply a threshold, predictions fall into four categories : true/false positive
and true/false negative. These are shown in the second plot with coloured zones.
The confusion matrix counts these and forms the basis for evaluation metrics like
accuracy, precision, recall, etc. So for prediction quality.
Confusion matrix
We can fill in the confusion matrix to get a visual representation of these terms.
This can be used to asses prediction quality.
4
1. Introduction
Objectives of this chapter
• Gain an intuitive understanding of machine learning (ML)
• Know when and where to apply ML, and when not
• Know the core terminology
• Know how to prepare datasets for ML
• Know a few of the most common model types, when to apply them, and how
• Common pitfalls like data leakage and overfitting
Exam : no formulas need to be known but they could help for the practical. Ony
metric formulas need to be known which are simple.
2. What is machine learning
ML is not the same as statistics.
Statistics Machine learning
Draws population inferences from a sample Finds generalizable predictive patterns
Take a sample and answer question about Take a sample and also look at the
a population population for patterns to predict future
events (on a certain model)
Aims to answer questions about a whole Aims to learn patterns that work well on
population from a sample new, unseen data.
→ Answering precise hypotheses → Refining pattern to sometime make
predictions
Explains Predicts
Choose the method that fits the goal. If you want to understand relationships or
effects, use statistical inference. If you want to make predictions or classifications,
use supervised learning.
Statistics examples
• Does the medication positively affect blood-pressure?
• Which genes are differently expressed between healthy and diseased tissue?
• Is skin lesion irregularity associated with malignancy?
Machine learning examples
• Which patients will benefit most from the blood-pressure medication?
• Is a tissue healthy or diseased given gene expression data?
• Is a skin lesion malignant or not?
1
,Machine learning
Artifical intelligence
Artificial intelligence is the broad field.
Anything intelligence that is artificial.
We use computers and give them a lot
of example data to make prediction and do something that seems intelligence.
Machine learning
Machine learning is a part of it that learns from data.
Deep learning
Deep learning is a kind of machine learning that uses many layer neural networks.
Deep learning : we stack different models in layers and sometimes these layers
interact.
Important : Not all ML is deep learning, and not all AI uses machine learning.
Traditional programming vs ML
Rule-based programming starts from hand-
written rules and applies them to data.
Supervised machine learning starts from data
and correct answers (labels) and learns the
rules (the model). The main work shifts from
writing rules to building a good dataset.
We take expected output and data and put
this in computer and computer writes the
program (model of the data). So it turns
around programming.
3. Mapping biomedical problems to ML tasks
Machine learning tasks
2
,Clear inputs (features) and outputs (targets) guide the choice of loss, metric, and
model.
We have 2 types of ML tasks :
• Regression : predicting a number (continuous value)
o You give the model input features and it outputs a number
o For example : a lab value
• Classification : predicting a category (discrete class or label)
o You give the model input features and it outputs a category
o For example : healthy vs diseased
Supervised learning = the model learns from labelled examples where both the
input and the correct output are provided.
Unsupervised learning = the model learns patterns from data without labels,
discovering structure on its own.
Mole example
We want to determine whether skin moles are benign or malignant using machine
learning. Because we already know the correct diagnosis for each mole, this is a
supervised learning problem.
1. Start with raw data = images of moles.
2. Extract measurable properties, we turn these images in numbers
Parameters : eccentricity (how round round) and solidity (how uniform the color or
texture). These numerical descriptions are called features.
3. Pair features with the correct diagnosis (label, or target) to train a model.
High‑quality features and accurate labels are both essential for good performance.
By pairing these features with the correct diagnosis (the label: benign or
malignant), we can train a model to learn the relationship between appearance
and outcome.
Samples, features, and targets
A dataset is a table with :
• Samples = rows
o Each row is a sample, example, or instance
• Features = columns
o Most columns are features + 1 column is the target or label.
• Target = outcome we want to predict
o We want the machine to predict the label with the samples and
features.
A density plot can be made that shows how one feature is distributed across the for
each target class in a dataset. So to show feature distribution.
Looking at one feature at a time can show partial class separation, but real
strength comes from combining features. We can also already classify by choosing
a threshold on this density plot.
3
, Density plot
A density plot like this can help you choose a threshold for that single feature,
although such one‑feature thresholds are usually limited.
The plots shows :
• Good sign : The distributions are not completely overlapping, so
Eccentricity helps distinguish the classes.
• Bad sign : Some overlap remains → no perfect separation → predictions
won't be 100% accurate.
Overlapping = the feature is not good to make predictions because it does not give
information for separation.
If we put a threshold manually we already get a very simple model. But we need
terms for mistakes.
A threshold is a cut-off value on the feature. You can visually choose a threshold
using the density plot. This creates a simple model : one feature, one rule.
Once you apply a threshold, predictions fall into four categories : true/false positive
and true/false negative. These are shown in the second plot with coloured zones.
The confusion matrix counts these and forms the basis for evaluation metrics like
accuracy, precision, recall, etc. So for prediction quality.
Confusion matrix
We can fill in the confusion matrix to get a visual representation of these terms.
This can be used to asses prediction quality.
4