




























Studia grazie alle numerose risorse presenti su Docsity
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Questa pagina non è visibile nell’anteprima
Non perderti parti importanti!





























there can be defined
dummy variables - binary
work as an orthogonal vectorial basis
H-1 necessary because the last one is a linear combination of the rest, but we usually keep H
when facing a large dataset it is also appropriate to reduce its size, in order to make learning algorithms more efficient, without
sacrificing the quality of the results obtained
J
1
H
j 1
j 2
j ( H − 1 )
Aims
smaller dataset = shorter computation time
for most known cases, reduction of data for superlinear functions causes dramatic reduction fo computation times
∀ parameter there’s a tradeoff of benefits and risks to be weighted out before taking a decision
ATTRIBUTE SELECTION - feature selection
Aim : eliminate from the dataset a subset of variables not relevant for the purpose of the algorithm
Select relevant attributes **before** the training algorithm run 1x large datasets ( observations, attributes )
can be associated w/ any algorithm
Features selected in groups (as combinations) performance metrics algorithm run n x, costs
higher acc
Attribute selection **inside** the algorithm: directly made during _model generation_ phase forward : starts with empty set and adds
backward : starts with full set and takes away
extracting a sample of observations that is significant from a statistical standpoint
simple : extract randomly from the dataset (ok just for very big datasets and sample set extracted)
stratified : extract from each class as to preserve the original proportions
i. First component is determined by solving an appropriate optimization problem, in order to explain the highest
percentage of variation in the data
it can be shown that
a. the solution is the eigenvector associated w/ the largest eigenvalue of the covariance matrix
b. percentage of explained variance
ii. At each iteration the principal component is chosen, among the vectors orthogonal to the ones already
determined, as the one that explains the max % of in the data, yet not already explained
N principal components obtained are a new basis of (= uncorrelated) and can be ordered in as one likes (usually
st component explains the most variance, 2
nd the second most etc. )
no loss of information but usually a subset of q < n components has information content almost equivalent to the
original dataset
explanatory capability of the first q-principal components
usually : 1st & 2nd component explains most of the variance, from then on it’s a subjective choice how many
principal components to include
w 1
1
1
1
1
1
1
1
1
1
1
1
KT T
∂ L ( w 1
, λ 1
)
∂ w 1
1
1
1
∂ L ( w 1
, λ 1
)
∂ λ 1
1
1
u 1
λ 1
1
1
2
1
w 1
2
1
2
1
n
q
1
q
1
n
q
min
much more useful for the algorithm
but much less easy to interpret
Aim : obtain projective transformation that replaces a subset of the original numerical attributes w/ lower no. of new
attributes obtained as a linear transformation of the original set
given covariance matrix of data (after std)
with with
principal components, have to be determined
Principal components obtained with an iterative algorithm
The variance of the projection is
n
⏟
original
dataset
⏟
linear
combination
of original
dataset
1
n
better at explaining
data variance
n
i
j
new basis
i
i
i
i
i
i
i
j
i
j
i
2
j
j
L02 - EXPLORATORY DATA ANALYSIS
Given the aim is to study the behavior of as an independent attribute
Data preparation
creation of a high quality dataset,
identifying and implementing corrective
actions in case of incomplete, noisy or
inconsistent data
Data exploration
Highlight relevant features of each attribute,
with graphical methods and summary statistics
identify relationships between attributes and
targets
Univariate analysis
Bivariate analysis
Multivariate analysis
j
generic attribute being analyzed
j
1
2
m
j
Graphical
analysis of
categorical
attributes
Measures of
heterogeneity
for
categorical
attributes
Graphical
analysis of
numerical
attributes
discrete numerical attribute
Histogram
(≈ 5-20 obs. class r )
classes width
empirical density = height of interval rectangle
j
j
r
r
total range
r
r
r
R
r = 1
r
r
R
r = 1
r
Heterogeneity min
Gini index
Expresses the heterogeneity of
Meaning
normalized
Entropy index
Meaning
normalized
measurement of the impurity or randomness in the data points
Indexes uses in classification trees
H
h = 1
2
h
h
H − 1
H
max heterogeneity
rel
H
h = 1
h
2
h
2
rel
2
categorical attribute
values taken by
relative frequencies
relative empirical frequency
for large samples for the Central Limit Theoem
For a sample of adequate size, by virtue of the central limit theorem, the
relative empirical frequency represents a good approximation of the
probability density of attribute
j
j
1
H
h
h
h
h
a j
Intervals’ areas interpretation
the interval
theorem,
p r
≈ P (new obs. from the population will fall within r )
Outliers : fall outside of whiskers
Whiskers can be defined in more than one way
Measuer of
central
tendency for
numerical
attributes
Measures of
dispersion
for numerical
attributes
Measures of
relative
location for
numerical
attributes
Dispersion : level of variability expressed by the observations, with respect to the central values
range [unable to catch actual dispersion]
deviation
mean absolute deviation
variance
sample std deviation
variance can be used to delimit I around where it’s reasonable to expect values will fall
coefficient of variation
range
ma x
min
i
i
m
i = 1
i
2
m
i = 1
2
i
m
i = 1
i
2
2
μ ¯
mode : value that corresponds to the peak of the empirical density curve
Multimodal empirical densities have multiple max no
statistical relevance
midrange
geometric mean
midrange
ma x
min
g
m
1
2
m
m
m
i = 1
i
sample arithmetic mean of sample
weighted sample mean, weights
median : central value of observations ordered in a non-decreasing way
1
2
m
m
i = 1
i
w
1
1
m
m
1
m
m
i = 1
1
1
m
i = 1
1
i
med
( m + 1 )/ 2
if m odd
med
x m / 2
2
if m even
def. quantile : given any value , the p-order quantile is the value : observations will fall on
the left of [and the remaining on its right]
Mead mean : mean of values
Trimmed mean : mean of values , generalization of mead mean
Windsored mean : mean of all values, taking those out of at the extremes of the range
z - index , signed distance between any value and , normalized on
p
p
q
U
L
interquartile range
L
P
p
1 − p
[ q p
, q 1 − p
ind
i
i
external lower edge = q L
q
internal lower edge = q L
q
internal upper edge = q U
q
external upper edge = q U
q
trace of covariance matrix
plots
Box
plots
Comparing boxplots of more variables
Time
series
If an explanatory attribute has a similar distribution as a target variable, then it’s potentially explanatory with
respect to the target
j
k
lj
lk
j
k
k
have been extracted
Covariance
Correlation
jk
j
k
m
i = 1
ij
j
ik
k
ij
j
k
in concordance
ij
j
k
in discordance
linear correlation coefficient
ij
k
j
ij
j
k
ij
Marginal
frequencies
Sums of each
column
def. given categorical attributes, let the sets of
distinct values respectively assumed by each of them
a contingency table is defined as a matrix whose generic element indicates the
frequency with which pair of values appears in the records of the
dataset
j
k
1
J
1
K
rs
ij
r
ij
s
r
K
s = 1
rs
s
J
r = 1
rs
the two attributes are independent if the analysis of in relation to is equivalent to the univariate analysis of
(introducing a new variable does not introduce more variance in the results)
j
k
r 1
1
r 2
2
rk
k
1 s
1
Js
j
j
k
j
k
j
Scatter plot
matrix
Scatter plots for every pair of numerical variables
Star plots 1. Every record is matched with a star-shaped icon, from the center of which. Depart as many rays as the # of
attributes
Spider
webchart
Grids where the main rays correspond to the attributes analyzed
∀ record the position in calculated on each ray, based on the value of the corresponding attribute
n
j = 1
ij
n
j = 1
2
ij
L03 - CLASSIFICATION
We use past data to understand the dynamics between explanatory attributes and the target variable and build a “separation
function” = algorithm that can be used to predict the outcome classes on future data
Target variable class
given : ,
the classification problem is the definition of the hypothesis space and a function which optimally describes the
relationship between and
target class y to be attached to each observation x
then compared to asses the algorithm efficiency
Probabilistic structure
Classification for an unbalanced dataset can be performed by properly varying the discriminating threshold
classification can be every multi-category problem can be reduced to a binary problem
predicting the class applying k training classifiers + majority voting
predicting the class applying k(k-1)/2 training classifiers + majority voting
in general extra computational is worth it
m
i
i
i
n
i
n
i
i
Old data
Identify “rules” =
separation function that
link old data with old
results
Training
Old results
Rules used to predict unknown
results of new data
Prediction
Comparing
predicted results
with real results
Evaluation
New data
Predicted results Metrics
Generator
extracts random vectors x of examples
according to an unknown probability
distribution P x ( x )
Supervisor
returns for each vector x the value of the target
class according to a conditional distribution Py|
x (y| x ) (unknown)
Algorithm
( classifier ) chooses a function
in so as to min a defined
loss function
f
y
f( x )
binary
multicategory
2
Heuristic models classification procedures based on intuitive and simple procedures K-NN, trees
Separation
models
Regression
models
make an explicit assumption concerning the functional form of the conditional
probabilities P y|x (y|x)
Regression , LR
Probabilistic
models
hypothesis is formulated regarding the functional form of the conditional probabilities P x|
y (x|y) of the observations given the target class, known as class-conditional probabilities.
Naive Bayesian
divide the attribute space in H regions separating the observations by
target class
n
1
H
Overfitting : production of an analysis that corresponds too closely or exactly to a particular set of data, and may therefore fail
to fit additional data or predict future observations reliably
outliers and we’re correctly classifying them as well )
Separate observations belonging to different classes through simple and explanatory rules for the relationship between target and
predictive variables
It is a algorithm, but not knowing the general pattern it's not the best choice always
recursive heuristic procedure = top-down induction of decision trees
selected and used for the next step
If all explanatory variables undergo the same transformation, a similar tree to the one obtained with the original variables is built
CLASSIFICATION TREE TRAINING
i. Observations are divided in disjoint subsets and placed in two or more descendant nodes ( branching)
ii. At each node stopping conditions are checked, if at least one if met the node becomes a leaf m
iii. Otherwise the procedure is repeated for each node
In some classifiers it is possible to assign a matrix of costs for incorrectly classified examples, misclassification costs :
direct a classifier toward the actual objectives of the decision makers
R O C C U R V E C U M U L A T I V E G A I N
Idea : evaluating accuracy based on the density of positive observations in the
set identified by the model’s predictions
with Lift
Receiving operating characteristic
matrices (coming from models with varied parameters)
parameters of can be adjusted to maximize tpr
negatives
asse x : fpr - false positive rate
asse y : tpr - true positive rate
probably
acc. on past data
generality (efficiency on future data)
The new record is attributed to the class to which the majority of records out of K closest ones belongs
majority voting
There is no systematic way for parameters optimization, it’s an empirical process (comparing scores)
less sentitive to ouliers
less distinction btw classes
recursive (every step repeated for all nodes)
greedy (takes best choice for each node)
iv. At the end no node can be further subdivided, each leaf node is labeled with the value of the class by majority voting
Classification rule : set of splitting rules found along the
outcome
target class
score
classification rule
root node
path
leaf
Binary trees : each node has at most two branches
Multi-split trees : each node has an arbitrary number of branches
No significant difference seems to
emerge in the predictive accuracy of
classification trees in connection
with the maximum # of descendant
branches
MULTIVARIATE TREES - splitting rule
p.c. : f is a linear combination of explanatory variables
oblique decision trees - separations generate polygonal partition
Univariate vs multivariate
than univariate trees
1
2
n
n
j = 1
j
j
misclassification index
Proportion of misclassified examples
has a non derivable point
Entropy
Gini Index
h
h
H
h = 1
h
2
h
H
h = 1
2
h
Information gain criteria
splitting rule impurity
1
2
k
K
k = 1
k
k
1
k
information gain
⏟
father node
1
k
descendant nodes
q
K
k = 1
k
k
Univariate trees - splitting rule := function of a single attribute
axis parallel trees separations are to each other, since the variables and independent from each other
selects (i) the explanatory variable and (ii) the partitioning criterion with an evaluation function
maximization of evaluation function identifies the rule
Let be the proportion of records from the target class at a given node q and Q total # of
records in q ,
heterogeneity index at the node q is function of , needs to be:
j
f ( X j
h
h
H
h = 1
h
h
h
p h
def. given sigmoid function and hp the posterior probability follows a
logistic function
with to be determined, and to be extended as to include the intercept
By introducing the transformation:
logarithms of predicted probabilities)
Family of separation methods for classification and regression, developed in the context of statistical learning theory
classification algorithm defines the hp space and the function which optimally describes the relationship between
the class value y and the vector of explanatory variables x
variables
stochastic dependence
conditional probabilities, is limited in Bayesian networks,
precedence links included in the network.
regression technique
adapted for binary [0,1] outcome problems
logistic regression
− t
1
1 + e
w
′ x
1
e
w
′ x
w
′ x
Classification Regression
⏟
∈𝒞
Binary classification problem is traced
back to the identification of a linear
regression model between the dependent
variable z and the original explanatory
attributes
Pro Cons
class)
n.b. boundary similar to SVM but
i. based on probabilistic assumptions, while SVM is based on geometrical properties while
LR on statistical assumptions
ii. SVM has the margin between the boundary and the support vectors gives a “no error
zone” while in LR the separation is “clean”
ℱ
conflicting effects produced by an increase in the complexity of the hypothesis space (= VC on x- axis)
1) Overfitting
If the space is too broad the optimal hypothesis has low generalization capability, ( e.g. is a polynomial of high
degree ), to avoid : bounds on
Vapnik-Chervonenkis dimension (VC)
Expresses complexity of the hp space, increases
, confidence
complexity of hp space
confidence level ( )
emp
number of observations
number or separating planes OR degree of the separating function
ψ ( t , γ , η )
emp
emp
has two critical drawbacks
ERM - empirical risk minimization
expected risk
P() that obs will
fall in that interval
empirical error
removes the probability element
emp
t
i = 1
i
i
SRM - structural risk minimization
emp
it's an ill posed problem
2) Ill-posedeness
The parameters of optimal, may vary significantly for small changes in the input data
we solve the well posed problem:
minimization of the structural risk
K kernel , simmetric positive function
penalty against the hp that leads to overfitting
smoothing regularizer for well-posing the problem
t
i = 1
i
i
2
K
regulizer
Simulates the behavior of biological systems composed of neurons
neural network is an oriented graph consisting of nodes , which in the biological analogy represent neurons, c onnected by arcs ,
which correspond to dendrites and synapses.
each iteration the weights associated with the arcs
distorsion [constant]
g activation function
i. Hard problem in current space
ii. Data projected in a new space where the problem is
easier to solve
iii. Problem solved
iv. Solutions projected back in first space
kernel function
with transformation operator
Do kernels always exist when we need them?
very mild conditions)
There have been proposed and neural netwok-based kernels
rbf are not perfectly circular
i
h
i
h
rbf : radial based
poly : polynomial
non linear prediction
from separating the hyperplane and therefore lie on the
canonical hyperplane = support vector
m
i = 1
i
i
i
h
i
i
i
i
i
Going back and forth is time/computing consuming
we do it all implicitly in the original space thanks to kernel
functions
the data is approximated by a linear function in the feature
space
1
m
Weights initialization
prediction obtained applying the activation function g to the linear
combination of weighted input variables
binary classification problems ,
identity’, no-op activation, useful to implement linear bottleneck,
returns f(x) = x -> non linear!
1
1
n
n
g (. ) = sgn(. )
g (. ) = S(. ) =
1 + e
(.)
g (. ) = Re L u =
y = 0 x ≤ 0
y = x x > 0
committed
error < threshold
Deep Learning : neural networks with several hidden layers (good in image analysis)
Can be extended to regression using the SSE method to determine the coefficients
Combining predictions obtained from different classifiers usually really good predictions are obtained by combining more
weak classifiers + they are less likely to overfit
Regularization of neural networks
function of the network)
since the final function is a linear combination we treat is as regression and apply the L1 (Lasso) or L2 (ridge) regularizers
we need to take into account that the regularizer will undergo the same transformations as the data at each node
the error on the validation set in minimum
Cons
Optimization of neural networks
Find minimize the prediction error function
hidden nodes of the network
j
algorithm (similar to single perceptron)
layer and in different layers
Parameters : #layers, #nodes (increasing the # of nodes there is
overfitting risk), types of function
Input Nodes Hidden nodes Output Nodes
receive the input x i
apply transformations to input return prediction value
Pro
i
i
Weak classifier Strong classifier
is a model for binary classification which only performs
slightly better than a random classifier.
A weak learner in general is a model which performs only
slightly better than a naive model.
strong classifier is a model for binary classification that
performs with arbitrary performance, much better than a
random classifier.
A strong learner in general is a model which performs much
better than a naive model
Bagging Boosting