Artificial intelligence for quality control with active infrared thermography�Introduction to Machine Learning
ING-IND/14, 2 CFU
Roberto Marani - April 21st, 2023
Linear regression as an indicator
Principle
Since the surface temperature of sound regions decays linearly in a log-log scale, any difference from a linear T-t dependence indicates a defect
log(T)
log(t)
log(t)
log(T)
Roberto Marani
Slide 2
Linear regression as an indicator
One measure of goodness of fit is the coefficient of determination (or R2)
R2 = 1 – SSresid / SStotal
Roberto Marani
Slide 3
Linear regression as an indicator
R2 discrimination has several flaws:
Need for more sophisticated approaches (machine learning!)
Roberto Marani
Slide 4
Use case
Inspection of a calibrated plate of GFRP
Ø 7.85
Ø 14.1
Ø 20.2
depth
15.7
Hole depths
12.4
9.82
7.08
4.35
315
290
Ø 17.44
Ø 13.3
Ø 9.54
Ø 8.3
Ø 7.85
In-depth defects
Surface defects
Sound region
Roberto Marani
Slide 5
Outlines
Roberto Marani
Slide 6
Outlines
Roberto Marani
Slide 7
Introduction to machine learning
Definition by Tom Mitchell (1998):
Machine Learning is the study of algorithms that:
A well-defined learning task is given by <P,T,E>.
“Learning is any process by which a system improves performance from experience” (Herbert Simon)
Roberto Marani
Slide 8
Introduction to machine learning
Why ML?
Roberto Marani
Slide 9
Introduction to machine learning
Why now?
Roberto Marani
Slide 10
Introduction to machine learning
When do we need ML?
Roberto Marani
Slide 11
Introduction to machine learning
History of ML
Roberto Marani
Slide 12
Introduction to machine learning
History of ML
Roberto Marani
Slide 13
Introduction to machine learning
History of ML
Roberto Marani
Slide 14
Introduction to machine learning
Possible applications:
State of the art:
Roberto Marani
Slide 15
Introduction to machine learning
Roberto Marani
Slide 16
Introduction to machine learning
Roberto Marani
Slide 17
Introduction to machine learning
Roberto Marani
Slide 18
Introduction to machine learning
Types of learning
Roberto Marani
Slide 19
Introduction to machine learning
Types of learning
Supervised learning
Semi-supervised learning
Unsupervised learning
Roberto Marani
Slide 20
Introduction to machine learning
Supervised learning
Unsupervised learning
Roberto Marani
Slide 21
Introduction to machine learning
Classification vs. regression
Given (x1, y1), (x2, y2), ..., (xn, yn), learn a function y = f(x) to predict y given x
Y is categorical 🡪 classification
Y is real-valued 🡪 regression
Roberto Marani
Slide 22
Designing a learning system
Roberto Marani
Slide 23
Designing a learning system
Training vs test set
Roberto Marani
Slide 24
Designing a learning system
ML in practice
LOOP
Roberto Marani
Slide 25
Evaluation
Roberto Marani
Slide 26
Evaluation
Performance on test data is a good indicator of generalization
The test accuracy is more important than the training accuracy
Roberto Marani
Slide 27
Generalization problem
Simple decision boundary
Complex decision boundary
In classification
Roberto Marani
Slide 28
Generalization problem
Simple model
Complex model
In regression
Roberto Marani
Slide 29
Generalization problem
Over-fitting and under-fitting
Roberto Marani
Slide 30
Comparing models: k-fold cross-validation
Roberto Marani
Slide 31
Comparing models: k-fold cross-validation
Roberto Marani
Slide 32
Comparing models: k-fold cross-validation
Cross-validation in training
Roberto Marani
Slide 33
Outlines
Roberto Marani
Slide 34
Reducing dimensionality
Why do we need features?
In any ML problem, data needs to be preprocessed to:
Features are measurable properties or characteristics of a phenomenon. They need to be:
Compact representation of an image (or an object within)
Roberto Marani
Slide 35
Reducing dimensionality
Examples
In character recognition
In speech recognition
In spam detection algorithms
In computer vision
Roberto Marani
Slide 36
Feature in image processing
Examples
Roberto Marani
Slide 37
Feature in image processing
Histogram of Oriented Gradients (HOG)
Steps
Roberto Marani
Slide 38
Feature in image processing
Histogram of Oriented Gradients (HOG)
Roberto Marani
Slide 39
Feature in image processing
Histogram of Oriented Gradients (HOG)
Roberto Marani
Slide 40
Feature in image processing
Feature vector:
Location
Scale level where the gradient is maximum (or minimum)
Strength and orientation
Gradient sign
Scale-Invariant Feature Transform (SIFT)
Steps
Roberto Marani
Slide 41
Feature in image processing
Applications
Object detection
Image stitching
Roberto Marani
Slide 42
Outlines
Roberto Marani
Slide 43
Unsupervised learning
Roberto Marani
Slide 44
Clustering data
Roberto Marani
Slide 45
Outlines
Roberto Marani
Slide 46
K-means
Roberto Marani
Slide 47
K-means
Roberto Marani
Slide 48
K-means
Roberto Marani
Slide 49
K-means
https://mubaris.com/posts/kmeans-clustering/
Roberto Marani
Slide 50
K-means
Roberto Marani
Slide 51
Outlines
Roberto Marani
Slide 52
Hierarchical clustering
An algorithm that groups similar objects into groups (clusters) to create a set of exclusive clusters, whose objects are broadly similar to each other
It starts by treating each observation as a separate cluster
Then, it repeatedly executes the followings:
This iterative process continues until all the clusters are merged
Roberto Marani
Slide 53
Hierarchical clustering
New structure of information: Dendrogram
Possible cuts
1 class
2 classes
3 classes
5 classes
Feature vector
Agglomerative approach
Roberto Marani
Slide 54
Hierarchical clustering
Roberto Marani
Slide 55
Hierarchical clustering
Roberto Marani
Slide 56
Hierarchical clustering
Roberto Marani
Slide 57
Implementation of Unsupervised Clustering
Lecture_5_Unsupervised_Clustering.m
Roberto Marani
Slide 58
Outlines
Roberto Marani
Slide 59
Supervised learning
Roberto Marani
Slide 60
Example: Detection of mail spam
Roberto Marani
Slide 61
Example: Detection of mail spam
Known examples depending on the number of recipients
Roberto Marani
Slide 62
Example: Detection of mail spam
High error
Best separation
The model will learn this lesson to predict spam in new mails
Roberto Marani
Slide 63
Example: Detection of mail spam
How can we separate the dataspace to have a new improved model?
Roberto Marani
Slide 64
Outlines
Roberto Marani
Slide 65
k-Nearest Neighbor (kNN)
Roberto Marani
Slide 66
k-Nearest Neighbor (kNN)
Roberto Marani
Slide 67
k-Nearest Neighbor (kNN)
Roberto Marani
Slide 68
k-Nearest Neighbor (kNN)
Improvements
Roberto Marani
Slide 69
k-Nearest Neighbor (kNN)
Possible distance function
d2 = (xs−yt) (xs−yt)′
d2 = (xs−yt) V−1 (xs−yt)′
d2 = (xs−yt) C−1 (xs−yt)′
d = ∑j ∣xsj−ytj∣
dp = ∑j ∣xsj−ytj∣p
d = maxj{ ∣xsj−ytj∣ }
Roberto Marani
Slide 70
Outlines
Roberto Marani
Slide 71
Support Vector Machine (SVM)
Roberto Marani
Slide 72
Support Vector Machine (SVM)
Roberto Marani
Slide 73
Support Vector Machine (SVM)
Example
Roberto Marani
Slide 74
Support Vector Machine (SVM)
Separators
Roberto Marani
Slide 75
Support Vector Machine (SVM)
What if we have noise?
Increasing noise 🡪 One separator remains
Roberto Marani
Slide 76
Support Vector Machine (SVM)
Basic idea
Roberto Marani
Slide 77
Support Vector Machine (SVM)
Practical example
x1
ϴ = [1,0]
Hyperplane: x1 = 0 (i.e., x2 axis)
Margin = 2
The sign function applied to the feature x1 allows the best prediction since the margin is maximum
Note that x2 has no meaning for this problem
x2
Roberto Marani
Slide 78
Support Vector Machine (SVM)
What if the input data are not linearly separable?
The basic idea is to use a new function (kernel) that can map the input data in a new feature space where features are linearly separable
Non-linearly separable
Linearly separable
Φ = (·)2
Roberto Marani
Slide 79
Support Vector Machine (SVM)
Kernel trick
K(xi,xj) = <Φ(xi), Φ(xj)>
Possible kernels
Roberto Marani
Slide 80
Support Vector Machine (SVM)
Multi-class classification with SVMs
Roberto Marani
Slide 81
Outlines
Roberto Marani
Slide 82
Decision trees
Roberto Marani
Slide 83
Decision trees
Roberto Marani
Slide 84
Decision trees
Example: When can they play a tennis game?
Roberto Marani
Slide 85
Decision trees
Example
Categorical attributes (can also be numerical)
Roberto Marani
Slide 86
Decision trees
Example with numerical attributes
Roberto Marani
Slide 87
Decision trees
Decision boundary
Roberto Marani
Slide 88
Decision trees
How to select the attributes (and their order)
Roberto Marani
Slide 89
Decision trees
How to select the attributes (and their order)
Which test is more informative?
Roberto Marani
Slide 90
Decision trees
Overfitting
Solutions:
Roberto Marani
Slide 91
Decision trees
Applications
Roberto Marani
Slide 92
Outlines
Roberto Marani
Slide 93
Neural networks
Basic idea
Roberto Marani
Slide 94
Neural networks
Biological neuron
Roberto Marani
Slide 95
Neural networks
ANN vs. BNN
Roberto Marani
Slide 96
Neural networks
ANN vs. BNN
Criteria | BNN | ANN |
Processing | Massively parallel | Massively parallel, but less than BNN |
Learning | Can tolerate ambiguity | Very precise, structured, and formatted data is required to tolerate ambiguity |
Fault tolerance | Performance degrades with even partial damage | Robust resiliency (can be fault tolerant) |
Storage capacity | Stores the information in the synapse | Stores the information in memory locations |
Roberto Marani
Slide 97
Neural networks
ANN vs. BNN
Roberto Marani
Slide 98
Neural networks
ANN vs. BNN
Roberto Marani
Slide 99
Neural networks
Model of an artificial neuron
Roberto Marani
Slide 100
Neural networks
Model of an artificial neuron
Roberto Marani
Slide 101
Neural networks
Model of an artificial neuron
f (x) = (1/1+ exp(-𝝈x)) (𝝈 is the steepness parameter)
Roberto Marani
Slide 102
Neural networks
Network architecture
Roberto Marani
Slide 103
Neural networks
Roberto Marani
Slide 104
Implementation of supervised learning for defect classification
Lecture_5_Physical_Feature_Extraction.m
Lecture_5_Supervised_Classification.m
Roberto Marani
Slide 105
Next steps
Roberto Marani
Slide 106
Roberto Marani
Researcher
National Research Council of Italy (CNR)
Institute of Intelligent Industrial Technologies and Systems for Advanced Manufacturing (STIIMA)
via Amendola 122/D-O, 70126 Bari, Italy
+39 080 592 94 58
roberto.marani@stiima.cnr.it
robertomarani.com
cnr.it/people/roberto.marani
stiima.cnr.it/ricercatori/roberto-marani/
Roberto Marani
Slide 107
Credits
Roberto Marani
Slide 108