Docsity

DATA MINING & COMPUTATIONAL STATISTICS, Dispense di Machine learning

Toggle sidebar
bg1
DATA MINING AND COMPUTATIONAL STATISTICS
Lesson 1 clarifies the relationship between four central concepts: Artificial Intelligence,
Machine Learning, Statistical Learning, and Data Mining.
Artificial Intelligence (AI)
• AI is the broad field aimed at building systems that perform tasks typically associated
with human intelligence (reasoning, perception, decision-making, language, etc.).
• It includes a variety of approaches, from rule-based systems to search, planning, and
modern learning-based methods.
In finance, AI can refer to autonomous trading systems, robo-advisors, or complex
decision-support systems.
5.2 Machine Learning (ML)
• ML is a subset of AI focused on algorithms that learn from data and improve
performance over time without being explicitly programmed for every case.
• The emphasis is often on predictive performance and scalability to large, complex
datasets.Examples in finance include models predicting stock price movements,
default probabilities, or customer churn.
5.3 Statistical Learning (SL)
• Statistical learning provides the mathematical and statistical foundation for many ML
methods.
• It focuses on specifying probabilistic models, estimating parameters, quantifying
uncertainty, and interpreting the relationship between variables.
A typical example is credit scoring models, where you relate customer characteristics to
default events using regression or classification frameworks.
5.4 Data Mining
• Data mining is the process of extracting useful patterns and insights from large
datasets using methods from ML and statistical learning.
• It is often exploratory and application-driven, especially in business and scientific
settings.
In finance, data mining includes tasks such as fraud detection, customer segmentation, or
transaction pattern analysis.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Anteprima parziale del testo

Scarica DATA MINING & COMPUTATIONAL STATISTICS e più Dispense in PDF di Machine learning solo su Docsity!

DATA MINING AND COMPUTATIONAL STATISTICS

Lesson 1 clarifies the relationship between four central concepts: Artificial Intelligence,

Machine Learning, Statistical Learning, and Data Mining.

Artificial Intelligence (AI)

  • AI is the broad field aimed at building systems that perform tasks typically associated

with human intelligence (reasoning, perception, decision-making, language, etc.).

  • It includes a variety of approaches, from rule-based systems to search, planning, and

modern learning-based methods.

In finance, AI can refer to autonomous trading systems, robo-advisors, or complex

decision-support systems.

5.2 Machine Learning (ML)

  • ML is a subset of AI focused on algorithms that learn from data and improve

performance over time without being explicitly programmed for every case.

  • The emphasis is often on predictive performance and scalability to large, complex

datasets.Examples in finance include models predicting stock price movements,

default probabilities, or customer churn.

5.3 Statistical Learning (SL)

  • Statistical learning provides the mathematical and statistical foundation for many ML

methods.

  • It focuses on specifying probabilistic models, estimating parameters, quantifying

uncertainty, and interpreting the relationship between variables.

A typical example is credit scoring models, where you relate customer characteristics to

default events using regression or classification frameworks.

5.4 Data Mining

  • Data mining is the process of extracting useful patterns and insights from large

datasets using methods from ML and statistical learning.

  • It is often exploratory and application-driven, especially in business and scientific

settings.

In finance, data mining includes tasks such as fraud detection, customer segmentation, or

transaction pattern analysis.

Hierarchy and overlaps between AI, ML, SL, and Data Mining

Lesson 1 provides a conceptual hierarchy.Lezione1_2026.pdf

  • AI is the umbrella field, containing ML and other intelligent systems such as rule-based

expert systems.

  • Within AI, ML provides data-driven models that can adapt to new information.
  • Statistical learning is the core of many ML algorithms, offering interpretable models

and formal statistical tools.

  • Data mining is an application area that uses ML/statistical learning to discover

patterns in large datasets, often in business or scientific research.

Key distinctions:

  • AI vs ML: AI is broader; ML is the main data-driven technique inside AI.
  • ML vs Statistical Learning: ML tends to prioritize prediction accuracy and often uses

flexible models; statistical learning stresses interpretability and statistical rigor.

  • Data Mining vs ML/SL: data mining is about using these methods in exploratory, often

business-oriented pattern discovery.

The instructor notes that in the course they will typically use the single term “statistical

learning” to refer both to traditional statistical methods and ML approaches.

Supervised vs unsupervised learning

These are fundamental paradigms shared by ML and statistical learning.

Supervised learning

  • Data include both input variables (predictors, features) and an outcome variable

(response, target).

  • Goal: learn the relationship between the response 𝑌and one or more predictors

1

𝑝

, to predict 𝑌for new observations or understand the effect of predictors.

Typical applications:

  • Business and economics: demand forecasting, credit risk classification, churn

prediction.Lezione1_2026.pdf

  • Methods: linear regression, logistic regression, decision trees, etc.Lezione1_2026.pdf

For your finance background, you can think of supervised learning as generalizing standard

regression and classification models you already know from econometrics.

LESSON 2:

1. Variables, notation, and measurement scales

1.1 Response and predictor variables

  • Response (dependent) variable

o Denoted 𝑌.

o It is the outcome we want to predict or explain (e.g., stock return, probability of

default, house price).

o It is treated as random because it changes with the predictors and contains

noise.

  • Predictor (independent) variables

o Denoted 𝑋(often as a vector 𝑋 = (𝑋

1

𝑝

o These are features/inputs that influence the response and are typically treated

as fixed or non-random in the modeling framework.

In supervised learning we always think in terms of “𝑌 given 𝑋”: we model how the distribution

of 𝑌changes as a function of the predictors.

1.2 Measurement scales

The type of a variable (measurement scale) matters because it determines which models and

loss functions are appropriate.

Nominal classification

o Pure categories with no intrinsic ordering.

o Examples: default vs non-default, sector (banking, utilities, tech), yes/no to a

survey question.

  • Ordinal classification

o Categorical but with a meaningful order.

o Examples: age group (young, middle-aged, old), credit rating classes (AAA, AA,

A, BBB, …), risk categories (low, medium, high).

  • Discrete measurements

o Numeric counts taking integer values.

o Examples: number of transactions, number of previous late payments, number

of claims per year.

  • Continuous measurements

o Can take any value in an interval.

o Examples: age in years, income, stock returns, log-GDP.

For the exam, be able to: define each type, classify example variables, and explain why, e.g.,

“credit rating” is ordinal while “income bracket” may be either ordinal or nominal depending

on how it is used.

2. Goals of statistical learning: prediction vs inference

Statistical learning aims at estimating the relationship between a response and predictors,

typically written 𝑌 ≈ 𝑓(𝑋).

Prediction

o Use past data to predict future or unseen outcomes.

o Example: predict future stock returns or real-estate prices from

macroeconomic indicators.

  • Inference

o Understand the nature and strength of the relationship between 𝑌and each 𝑋

𝑗

o Example: measure how consumer spending changes when tax policy changes,

or how PD changes with income and leverage.ù

Prediction asks “how accurately can we predict 𝑌for new 𝑋?”, while inference asks “which

predictors matter, and how do they affect 𝑌?”.

3. Supervised learning basics

3.1 Definition

Supervised learning uses labeled data, where both predictors 𝑋and outcomes 𝑌are observed,

to learn a model that can predict 𝑌 for new observations.

Supervised methods are built around a model that relates the response variable to the

predictors.

3.2 Regression vs classification

  • Regression

o 𝑌is continuous.

o Examples: predicting stock returns from macro variables, forecasting sales

from advertising expenditures.

  • Impact: supports buy/hold/sell decisions, helping to design portfolios that maximize

returns for a given risk level.

5.2 Classification: credit scoring

Scenario: A bank decides whether a loan applicant will default.

Inputs: income, credit score, employment status, loan amount, etc.

  • Output: default vs non-default (yes/no).
  • Model: logistic regression (or other classifier) fitted on historical loan data.
  • Prediction: model outputs a probability of default for each new applicant.
  • Impact: the bank can price risk (e.g., higher interest rates for high-risk borrowers) or

reject very risky applications.

These examples show how notation 𝑋and 𝑌, measurement scales, and supervised learning

concepts directly apply in finance.

6. Why estimate 𝒇? Prediction and inference in depth

We estimate 𝑓for two primary reasons: prediction and inference.

6.1 Prediction

  • Objective: estimate 𝑓 in order to predict 𝑌 for new values of 𝑋.
  • Prediction formula: for a new 𝑋, the prediction is 𝑌

(𝑋), where 𝑓

is an estimator of

the unknown 𝑓.

  • Example: predicting future sales from advertising budgets, where 𝑋 is vector of ad

spending and 𝑌 is sales.

Prediction accuracy depends on two sources of error: reducible and irreducible.

6.2 Inference

Inference focuses on understanding the relationship between 𝑌and the predictors.

Typical questions:

  • Which predictors are significantly associated with the response?
  • What is the direction and strength of each effect (e.g., does higher income reduce PD,

and by how much)?

  • Is the relationship approximately linear, or do we need more complex functional

forms?

Inference allows us to move from “black-box prediction” to economic interpretation and

policy implications.

7. Assessing prediction accuracy: Mean Squared Error (MSE)

To evaluate the accuracy of a statistical learning method that produces a prediction 𝑓

0

) at

some input 𝑥

0

, the relevant quantity is the Mean Squared Error (MSE).

MSE(𝑓

) = 𝔼[(𝑌

0

0

2

]

0

is the true response at input 𝑥

0

  • The expectation is taken over the randomness in 𝑌

0

and often also over the

randomness in the training sample that produced 𝑓

  • MSE is the expected forecast error measured in squared units of 𝑌.

A lower MSE means better predictive performance.

8. MSE decomposition: simplified and general cases

8.1 Simplified case (fixed 𝑿 , fixed 𝒇

Assume 𝑋 and 𝑓

are fixed, so variability comes only from the noise 𝜀.

Then:

MSE(𝑓

) = 𝔼 [(𝑌 − 𝑌

2

] = 𝔼 [(𝑓

2

] = [𝑓

]

2

Reducible Error

  • Var

Irreducible Error

  • The first term [𝑓(𝑋) − 𝑓

(𝑋)]

2

is the reducible error: it depends on how well we estimate

  • The second term Var(𝜀) is the irreducible error: variation in 𝑌that cannot be explained

even if we knew 𝑓exactly.

This decomposition shows that no method can reduce MSE below the irreducible component.

8.2 General case (both 𝒀 𝟎

and 𝒇

𝟎

) random)

In the general case:

MSE(𝑓

𝑌

0

[(𝑌

0

0

2

]

Here both 𝑌 0

and 𝑓

0

) are random: 𝑌

0

because of noise, and 𝑓

0

) because it depends on the

specific training sample.

The lecture shows that MSE can be written as an irreducible part (variance of 𝜀) plus a

reducible part that depends on the bias and variance of 𝑓

0

MSE(𝑓

𝜀

2

⏟

Irreducible error

𝑌

[(𝑓

0

0

2

] ≥ 𝜎

𝜀

2

11. Parametric methods

11.1 Definition and steps

Parametric methods assume a specific functional form for 𝑓with a finite number of

parameters.

Two steps:

  1. Model specification: choose the form of 𝑓, e.g. linear model

0

𝑗

𝑝

𝑗= 1

𝑗

  1. Parameter estimation: use training data to fit the model, i.e., estimate 𝛽via OLS, MLE,

etc.

11.2 Advantages and limitations

  • Model alignment problem

o If the chosen functional form differs from the true 𝑓, the model is misspecified

and estimates can be biased.

  • Flexibility vs complexity

o More flexible parametric models (e.g., high-degree polynomials, many

interaction terms) can approximate a wider range of functions but require

estimating more parameters.

o Greater flexibility increases risk of overfitting: the model fits noise in the training

set instead of true signal.

  • Effect on MSE and bias–variance

o Overfitting increases MSE because variance becomes large.

o Parametric modeling therefore requires controlling complexity (e.g., via

regularization or model selection) to balance bias and variance.

Linear and logistic regression, parametric survival models, and many econometric

specifications are classic parametric methods widely used in finance.

12. Non-parametric methods

12.1 Definition and flexibility

Non-parametric methods do not assume a fixed functional form for 𝑓; instead, they let the

data determine the shape of 𝑓.

  • They can approximate very complex, nonlinear relationships, effectively “learning” the

structure from the sample.

  • They typically require larger sample sizes to achieve accurate estimates, because they

estimate more local structure.

12.2 Examples and challenges

Examples of non-parametric or highly flexible methods mentioned:

Decision trees.

  • Support Vector Machines (SVM).
  • k-Nearest Neighbors (KNN).

Challenges:

  • With small sample sizes they are particularly prone to overfitting.
  • The lack of a predefined structure can make models complex, harder to interpret, and

fragile to noise.

In financial applications, these methods can capture complex nonlinearities (e.g., nonlinear

relation between volatility and returns), but must be controlled via pruning, regularization, or

cross-validation.

3. Unsupervised learning examples

3.1 Customer segmentation in banking

Scenario: a bank wants to segment clients based on financial behavior to offer personalized

products.

  • Inputs: transaction data, loan history, demographics (age, income, spending habits).
  • Model: clustering algorithm (e.g., k-means, hierarchical clustering).
  • Output: groups such as “high-net-worth individuals”, “frequent loan users”, “students

with low balances”.

  • Impact: targeted marketing and product design (e.g., premium cards for

high-net-worth, student loans for young customers).

3.2 Country classification

Scenario: an economist groups countries using macro indicators.

Inputs: GDP growth, inflation, unemployment, trade balance.

Model: clustering algorithm.

Output: clusters like “emerging markets”, “developed economies”, “high-inflation

economies”.

Impact: guides policy analysis and investment strategies for country groups with similar

economic conditions.

4. Choosing and assessing statistical learning methods

4.1 No universally best method

Lesson 3 emphasizes that there is no single method that is best for all datasets.

Performance is data-specific: a method may work very well on one dataset but poorly on

another.

Selecting an appropriate method is one of the most challenging aspects of statistical

learning.

4.2 Evaluating model fit: the role of MSE

Key question: how well do predictions match the actual data?

For regression, we use Mean Squared Error (MSE) to quantify prediction error.

  • The theoretical MSE is an expectation, but we cannot compute expectations exactly

because the underlying distribution is unknown.

  • In practice we approximate expectations using sample means and empirical averages.

This sets up the need for training and test splits.

5. Training and test sets

5.1 Definitions

  • Training set

o Used to fit (train) the model parameters.

o Training MSE measures how well the model captures patterns in the observed

data:

Training MSE =

∣ training set ∣

∑ [𝑌

𝑖

𝑖

)]

2

𝑖∈training set

  • Test set

o Set of observations not used during training.

o Used to evaluate generalization performance, i.e., how well the model predicts

unseen data

Test MSE =

∣ test set ∣

∑ [𝑌

𝑖

𝑖

)]

2

𝑖∈test set

5.2 Importance of test MSE

It is crucial that the model generalizes to new data.

Training MSE always decreases as model complexity (flexibility) increases; a very flexible

model can even fit the training data almost perfectly.

However, this can lead to overfitting, where the model learns noise instead of the true

underlying pattern. The key insight is that we want to minimize test MSE , not training MSE.

A later slide shows training MSE (grey curve) decreasing with flexibility, test MSE (red curve)

with a minimum at intermediate flexibility, and a horizontal line for Var(𝜀), the irreducible

error.

7. Overfitting and model complexity

As flexibility increases, test MSE initially decreases but eventually rises; this turning point

marks the onset of overfitting.

Overfitting occurs when a model achieves very low training MSE but high test MSE, meaning it

memorizes noise instead of learning the underlying structure.

An optimal model balances flexibility: complex enough to capture real patterns but simple

enough to avoid high variance.

The slides also show examples where:

  • When the true function is smooth and noise is high, simpler models (linear or mildly

flexible) perform well.

  • When the true function is highly wiggly and noise is low, more flexible models perform

better.

8. Classification setting: error rates

8.1 Training and test error rates

In classification, the response variable 𝑌is qualitative (categorical).

We estimate a classifier 𝑓

and define:

  • Training error rate:

o Proportion of misclassified observations in the training set.

o If 𝑦̂

𝑖

is the predicted class for observation 𝑖, the training error is

𝑛

𝑖= 1

𝑖

𝑖

where 𝐼(⋅) is the indicator function.

  • Test error rate:

o Proportion of misclassified observations in a test set (unseen data).

o Computed with the same formula but over test observations. A good classifier

is the one that minimizes the test error rate, not necessarily the training error.

For a training sample

1

1

𝑛

𝑛

and predicted class labels 𝑦̂

𝑖

𝑖

), the training

error rate is:

Training Error =

𝑛

𝑖= 1

𝑖

𝑖

where 𝐼(⋅) is the indicator function equal to 1 if its argument is true and 0 otherwise.

A slide illustrates a 2D example with two classes: the shaded region where one class’

probability exceeds 50% and a dashed line marking the Bayes decision boundary.

10. From Bayes classifier to KNN

10.1 Practical limitations

In practice, we almost never know the conditional distribution 𝑃(𝑌 ∣ 𝑋), so we cannot

implement the Bayes classifier exactly.

K-Nearest Neighbors is introduced as a simple, non-parametric method that approximates

the Bayes rule using local information from the training sample.

10.2 K-Nearest Neighbors (KNN): definition

KNN is a non-parametric classifier that:

Makes no assumptions about the functional form of the decision boundary or about the data

distribution.

Classifies a new observation based on the majority class among its 𝐾nearest neighbors in the

training set.

Mechanism:

  1. Choose a positive integer 𝐾.
  2. For a given test point 𝑥

0

, identify the set 𝑁

0

of the 𝐾closest training points (using a

distance such as Euclidean).

  1. Estimate Pr(𝑌 = 𝑗 ∣ 𝑋 = 𝑥

0

) as the fraction of points in 𝑁

0

whose class is 𝑗.

  1. Assign 𝑥

0

to the class with the highest estimated probability.

KNN estimate of conditional probability

0

𝑖∈𝑁

0

𝑖

KNN classification rule

KNN

0

) = arg max

𝑗

0

10.3 Illustrative example

A slide shows:

  • Left panel: a small dataset with six blue and six orange points and a black cross

representing a new observation. For 𝐾 = 3 , the three nearest neighbors include two

blue and one orange point, so the cross is classified as blue (probability 2/3).

  • Right panel: decision boundary for 𝐾 = 3 , indicating regions classified as blue vs

orange.

Another slide compares the KNN decision boundary (black curve, e.g., 𝐾 = 10 ) with the Bayes

decision boundary (purple dashed line), showing that KNN can approximate the Bayes

classifier remarkably well even though it is a simple algorithm.