Chapter 4 Data Analytics
Chapter 4 Data Analytics
Information Management
Boje Deforce
Prof. Dr. Estefanía Serral Asensio
ICT Management
Data Analytics
Theory session
Who am I?
• Boje Deforce
• PhD student at LIRIS with:
• Prof. Dr. Estefanía Serral Asensio
• Prof. Dr. Bart Baesens
• Prof. Dr. Jan Diels
• I work on Machine/Deep Learning for:
• IoT sensor data (i.e. time-series)
• Forecasting 📈
• Anomaly detection ❌
• Other:
• Worked at Deloitte as data scientist for ~2 years
• Have a start-up ([Link])
3. Information Management
4. Data Analytics
[Link]
10 FEB, Campus Brussels
The real (business) value of LLMs
Added
Some Analytics
business
Information process value
Forecast
Price
Prediction
Added
Some Analytics
business
Information process value
Hire a
candidate:
yes/no
Source: datacamp
80% 20%
What makes a “good” data analyst/scientist?
• Traits
• “Statistical thinking”
• “Problem solving skills”
• “Creativity”
• “Communication and storytelling skills”
• “Business intuition”
• …
• Knowledge
• Dashboarding
• Technical knowledge (DS)
• (Basic) data engineering knowledge Source: Verbeke et al. (2018)
• Programming (DS)
• …
4.1 Introduction
How to get from raw data to added business value?
[Link], B. van, Herhausen, D. & Fahse, T. Overcoming the pitfalls and perils of algorithms: A *no need to know the
classification of machine learning biases and mitigation methods. J Bus Res 144, 93–106 (2022). biases
“Still struggling to find a use case? Consider pausing ML/AI in favor of analytics for a while. The
goal of analytics is to generate inspiration for the decision maker.”
• Analytics should not just be used because it sounds cool (e.g. everything is AI
nowadays)
→ It should serve/improve the business outcome
It should be used to discover patterns in the data which are:
• Valid
• Useful
• Unexpected
• Understandable
[Link]
33
(Semi-structured data)
Contains
Twitter_ID Text_length picture #_likes #_retweets #_comments
pickover 12yes 8500 1500 97
… … … … … …
• Often, visualization can already get you a longways (cf. Rule #1 from Google)
• A very interactive way to understand the data that a business has available
[Link]
46 FEB, Campus Brussels
learning
Supervised learning - example
𝑋 𝑌
Learn mapping
𝑓 𝑋
Parking occupancy
Full
Learning algorithm Half-full
Empty
Empty
Half-full
…
Feedback loop
• Linear regression
• Logistic regression
• K-Nearest neighbors
• Decision trees
• Random forest
• Naïve Bayes
• Neural networks
• …
• Linear regression
Will be covered in the Msc
• Logistic regression
• K-Nearest neighbors
This course
• Decision trees
• Random forest
• Naïve Bayes A bit more advanced
• Neural networks
• …
3. Training
4. Evaluation
5. Testing
6. Evaluation
7. Deployment
8. Monitoring
• [Link]
3. Training:
• Learn a mapping 𝑓 that can map an input 𝑋 to
an output 𝑌 using a learning algorithm
• In practice, typically multiple learning algorithms are applied and the best one is
selected
• What is the best one? For that, we need a formal evaluation (see next slide)
• “Learning” is achieved by minimizing some objective function through an
optimization routine (typically iterative)
• See more in the example
E.g. learning a
classifier that can
separate between
the red and blue
class
Live
• Technically missing from CRISP-DM (also because it’s a more recent phenomenon)
Full example
Data wrangling
• Missing values: 0
1
14.23
13.20
5.64
4.38
0
0
2 13.16 5.68 0
• “Impute” with: 3 14.37 7.80 0
4 13.24 ? 0
• Mean: if data is not skewed ... ... ... ...
• Median: if data is skewed (more robust) 125 12.07 2.76 1
126 12.43 3.94 1
• Mode: for categorical data 127 11.79 3.00 1
128 225.36 2.12 1
• Extreme values: 129 12.04 2.60 1
• Investigate cause:
• Keep if valid?
• Else remove
• Or impute
• Explore data:
• Missing values: 0
1
14.23
13.20
5.64
4.38
0
0
2 13.16 5.68 0
• “Impute” with: 3 14.37 7.80 0
4 13.24 ? 0
• Mean: if data is not skewed ... ... ... ...
• Median: if data is skewed (more robust) 125 12.07 2.76 1
126 12.43 3.94 1
• Mode: for categorical data 127 11.79 3.00 1
128 225.36 2.12 1
• Extreme values: 129 12.04 2.60 1
• Investigate cause:
• Keep if valid
• Else remove
• Or impute
• Explore data:
Train-validation-(test) split:
Train-validation-(test) split:
Train-validation-(test) split:
Train-test cycle
Algorithm selection:
K-nearest neighbors
Decision tree
Algorithm selection:
K-nearest neighbors
Decision tree
• Basic intuition:
• If we have a new wine with alcohol %=12.0 and color_intensity=2.6
it is very likely that it belongs to the neighboring class
• Basic intuition:
• If we have a new wine with alcohol %=12.0 and color_intensity=2.6
it is very likely that it belongs to the neighboring class
3. Classify
Training 2. Compute
Unseen
instances Distance
instance
1. Choose k (e.g. 5)
of the “nearest” 74
instances
74 FEB, Campus Brussels
Predictive analysis
1. Choose k (e.g. 5)
of the “nearest” 75
instances
75 FEB, Campus Brussels
Predictive analysis
Underfit
Algorithm selection:
K-nearest neighbors
• Basic intuition:
• Partition the data into leafs that are “pure”. I.e. can we split our data such
that we get subgroups that only contain one class?
1. Select feature to split
on (e.g. at random)
2. Split on feature
3. Calculate measure of
“purity” in resulting
subsets
4. Restart from 1. until
all subsets are “pure”
or until stopping
criterion is reached 82
• Basic intuition:
• Partition the data into leafs that are “pure”. I.e. can we split our data such
that we get subgroups that only contain one class?
1. Select feature to split
on (e.g. at random)
Alcohol < 12.8? 2. Split on feature
yes no
3. Calculate measure of
Color_intensity
Good wine < 5? “purity” in resulting
subsets
4. Restart from 1. until
{Bad: 13, Good: 8} → Bad Bad wine
all subsets are “pure”
or until stopping
criterion is reached 83
• Entropy:
• For KNN we only had 2 hyperparameters (only 1 really) to set (i.e. K &
distance metric)
• For decision trees a lot more hyperparameters are available. Below a selection
of the most important ones:
• Splitting criterion: the impurity measure used to split on (we will use Gini)
• Max depth: how deep we let the tree grow*
• Min_samples_split: how many samples a leaf should contain for it to be
split further
•…
*this is also often called a stopping criterion since the tree stops splitting after the max depth has been reached
Color_intensity
Good wine < 5?
2 2
48 0
𝐺𝑖𝑛𝑖(𝑇1 ) = 1 − +
Decision Tree 48 48
𝑇2
=0
𝑇1 2 2
8 48
𝐺𝑖𝑛𝑖(𝑇2 ) = 1 − +
56 56
= 0.245
48 56
𝐺𝑖𝑛𝑖(𝑇1 , 𝑇2 ) = 𝐺𝑖𝑛𝑖 𝑇1 + 𝐺𝑖𝑛𝑖(𝑇2 )
104 104
= 𝟎. 𝟏𝟑𝟐
2 2
48 3
𝐺𝑖𝑛𝑖(𝑇1 ) = 1 − +
Decision Tree
51 51
= 0.111
𝑇2
2 2
8 45
𝐺𝑖𝑛𝑖(𝑇2 ) = 1 − +
53 53
= 0.256
𝑇1 51 53
𝐺𝑖𝑛𝑖(𝑇1 , 𝑇2 ) = 𝐺𝑖𝑛𝑖 𝑇1 + 𝐺𝑖𝑛𝑖(𝑇2 )
104 104
= 𝟎. 𝟏𝟖𝟓
𝑇2
𝑇2
𝑇1
less impure than
Overfit
Sweet spot
Underfitting Overfitting
• Advantages:
• Learning and using trees is very efficient
• They tend to have good predictive accuracy (on smaller datasets), even
better when combined into ensembles (on larger datasets, i.e. random
forests - see elsewhere)
• They are interpretable: we can understand what the tree says, and we can
explain its predictions
• Disadvantages:
• Trees are sensitive to high variance in the data
• Harder to learn from large datasets or very noisy datasets
• Confusion matrix:
N P
True False
N Negative Positive
(TN) (FP)
True label
False True
P Negative Positive
(FN) (TP)
• ROC-curve:
[Link]
Note on Cross-Validation
Train-test cycle
• Data leakage: leaking part of your validation/testing data to your training phase
(e.g. providing data from the same year as your training data)
• Bias in data: beware of biased data, the model will exploit such bias without
sorry
• Model drift: [Link]
learning-models/ and [Link]
datasets
[Link]
• For many years, people made all sorts of lists with “5 free resources to get
better at ML, AI, …”. Recently, tensorflow (Google’s deep learning library)
summarized this into a nice list of how to get “better” in data science with many
free resources from different sources. See here.
• Datacamp also offers many courses (only the first lessons are free)
• [Link]
• Bit more advanced:
• [Link]
• Overview of useful algorithms etc.: [Link]
ml !!