Docsity

Machine Learning Appunti - PoliMi | prof. Vercellis, Appunti di Machine learning

Anteprima parziale del testo

Scarica Machine Learning Appunti - PoliMi | prof. Vercellis e più Appunti in PDF di Machine learning solo su Docsity!

MACHINE LEARNING

Anna Sparapani

Politecnico di Milano

prof. Carlo Vercellis

a.a. 2021-2, I semestre

Indice

  • L01 - Data Preparation
    • 01.1 Data validation
    • 01.2 Data transformation
    • 01.3 Data reduction
  • L02 - Exploratory Data Analysis
    • 02.1 Univariate Analysis
    • 02.2 Bivariate Analysis
    • 02.3 Multivariate Analysis
  • L03 - Classification
    • 03.1 Evaluation Metrics
      • 03.2 KNN - Key nearest Neighbors
    • 03.3 Classification Trees
    • 03.4 Bayesian Methods
    • 03.5 Logistic Regression
    • 03.6 SVM - Support Vector Machines
    • 03.7 Neural Networks
    • 03.8 Ensamble classifiers
  • L04 - Regression
    • 04.1 Simple linear regression
    • 04.2 Multiple linear regression
    • 04.3 Ridge and Lasso regressionS
    • 04.4 Generalized regression
    • 04.5 Extension of classification techniques to regression
    • 04.6 Validation of regression Models
  • L05 - Clustering
    • 05.1 Clustering Methods Classification
    • 05.2 Affinity Measures
    • 05.3 Partition Methods
    • 05.4 Hierarchical Methods
    • 05.5 Evaluation of Clustering Methods
  • L06 - Association Rules
    • 06.1 Single-Dimension Association Rules
    • 06.2 Apriori Algorithm
    • 06.3 General Association Rules

NUMERICAL REPRESENTATION OF CATEGORICAL VARIABLES

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

01.3 DATA REDUCTION

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

let X

J

categorical variable, assume the values in the set V = { v

1

,... , v

H

D

j 1

, D

j 2

,... , D

j ( H − 1 )

Aims

M E T H O D S

  1. Efficiency

smaller dataset = shorter computation time

for most known cases, reduction of data for superlinear functions causes dramatic reduction fo computation times

  1. Accuracy : data reduction should not significantly compromise accuracy of generated models
  2. Simplicity : smaller datasets are have a higher interpretability

∀ 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

  1. Filter methods

    Select relevant attributes **before** the training algorithm run 1x 
    • Features selected one by one with rules independent from the algorithm (e.g. correlation)
    • Pro

large datasets ( observations, attributes )

can be associated w/ any algorithm

  1. Wrapper methods

    Features selected in groups (as combinations) 
    • Same algorithm run n x times w/ different subsets of features in input, selected the best subset by comparing

performance metrics algorithm run n x, costs

  • Pro

higher acc

  1. Embedded methods

    Attribute selection **inside** the algorithm: directly made during _model generation_ phase 
    • e.g. Classification Trees , the algorithm itself runs on a feature selection at each step in a greedy search scheme
    • it can be

forward : starts with empty set and adds

backward : starts with full set and takes away

forward-backward : ∀ step one added and one taken away

SAMPLING

extracting a sample of observations that is significant from a statistical standpoint

  • size of sample has to guarantee the level of accuracy
  • useful to set up several independent datasets

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

M E T H O D S

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

  1. original data projected in a q dimensional space w/ same explanatory capability

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

  1. The principal components can be used instead the original attributes, or in addition

max

w 1

{ w ′

1

Vw

1

: w ′

1

w

1

= 1 } → L ( w

1

1

) = w ′

1

Vw

1

1

( w ′

1

w

1

KT T

∂ L ( w 1

, λ 1

)

∂ w 1

= 2 Vw

1

1

w

1

∂ L ( w 1

, λ 1

)

∂ λ 1

= 1 − w ′

1

w

1

u 1

λ 1

V

var( p

1

1

w ′

2

u

1

max

w 1

{ w ′

2

Vw

1

: w ′

2

w

1

IR

n

I

q

1

q

1

n

q : I

q

> I

min

much more useful for the algorithm

but much less easy to interpret

PCA - PRINCIPAL COMPONENT ANALYSIS

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

  • Principal components better suited to explain data variance than the original dataset
  • Standardization required before applying PCA - It’s an unsupervised method
  1. given X matrix of the n original attributes

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

∈ IR

n

V = XX ′

X

⏟

original

dataset

PCA

P

⏟

linear

combination

of original

dataset

P = { p

1

, ... , p

n

better at explaining

data variance

∈ IR

n

p

i

⊥ p

j

, ∀ i ≠ j

new basis

and p

i

= Xw

i

p

i

= Xw

i

w

i

w ′

i

x

i

E

[

w ′

j

x

i

− E [ w ′

j

x

i

]

]

2

= w ′

j

Vw

j

} its var. has to be explained by p.c.

L02 - EXPLORATORY DATA ANALYSIS

02.1 UNIVARIATE 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

𝒟 dataset

a

j

generic attribute being analyzed

a

j

= ( x

1

, x

2

,... , x

m

m no. of observations

a

j

Graphical

analysis of

categorical

attributes

  1. Vertical bar chart
  2. Horizontal bar chart

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

a

j

values of a

j

divided in R classes ∀

l

r

l

r

total range

# R

p

r

e

r

m l

r

R

r = 1

p

r

l

r

m

R

r = 1

e

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

f = 1 for one value

f = 0 for all the other values

G = 1 −

H

h = 1

f

2

h

a

h

G = 0 lowest heterogeneity

G =

H − 1

H

max heterogeneity

G

rel

G

( H − 1 )/ H

E = −

H

h = 1

f

h

log

2

f

h

E = 0 lowest heterogeneity

E = log

2

H highest heterogeneity

E

rel

E

log

2

H

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

a

j

H = {1,2,..., H } a

j

V = { v

1

,... , v

H

v

h

e

h

m

v

h

≈ P { x = v

h

}, h ∈ H

a j

Intervals’ areas interpretation

  1. % of observations falling inside

the interval

  1. By virtue of the central limit

theorem,

p r

≈ P (new obs. from the population will fall within r )

IDENTIFICATION OF OUTLIERS FOR NUMERICAL ATTRIBUTES

  1. With z-index
  2. Box-plots

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

x

range

= x

ma x

− x

min

s

i

= x

i

− μ ¯, i ∈ ℳ

M A D =

m

m

i = 1

| x

i

2

m − 1

m

i = 1

s

2

i

m − 1

m

i = 1

( x

i

2

2

μ ¯

C V = 100

mode : value that corresponds to the peak of the empirical density curve

Multimodal empirical densities have multiple max no

statistical relevance

midrange

geometric mean

x

midrange

x

ma x

+ x

min

g

m

x

1

x

2

... x

m

m

m

i = 1

x

i

sample arithmetic mean of sample

  • strongly affected by outliers not robust
  • If dataset if sufficiently large for the entire population

weighted sample mean, weights

median : central value of observations ordered in a non-decreasing way

  • affected by the no. of elements, but not by outliers more robust than mean
  • suitable for : (i) asymmetric distributions, (ii) distributions w/ open classes
  • if the data are concentrated in the central part, it loses all its statistical relevance

x

1

+ x

2

+... + x

m

m

m

m

i = 1

x

i

w

w

1

x

1

+... + w

m

x

m

w

1

+... + w

m

m

i = 1

w

1

x

1

m

i = 1

w

1

w

i

x

med

= x

( m + 1 )/ 2

if m odd

x

med

x m / 2

  • x ( m + 2 )/ 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 ∈ [ 0 ; 1 ] q

p

p m

q

p

( 1 − p ) m

D

q

= q

U

− q

L

interquartile range

∈ [ q

L

, q

P

]

∈ [ q

p

, q

1 − p

]

[ q p

, q 1 − p

]

z

ind

i

x

i

external lower edge = q L

− 3 D

q

internal lower edge = q L

− 1.5 D

q

internal upper edge = q U

+ 1.5 D

q

external upper edge = q U

+ 3 D

q

MEASURES OF CORRELATION

BIVARIATE ANALYSIS OF CATEGORICAL ATTRIBUTES

02.3 MULTIVARIATE ANALYSIS

trace of covariance matrix

A N A L Y S I S

QQ-

plots

Box

plots

Comparing boxplots of more variables

Time

series

  • quantile - quantile plots
  • numerical quantiles
  • If two series of data are extracted from the same probability distribution, the points in the chart will fall on
  • If explanatory attributes have similar distribution, we can usually ignore one of the two

If an explanatory attribute has a similar distribution as a target variable, then it’s potentially explanatory with

respect to the target

a

j

, a

k

⇒ { q

lj

, q

lk

y = x [ m = 1 ]

a

j

numerical value of a quantity, a

k

sequence of time periods at which values of a

k

have been extracted

Covariance

Correlation

v

jk

= cov( a

j

, a

k

m − 2

m

i = 1

( x

ij

j

)( x

ik

k

v

ij

> 0 : a

j

, a

k

in concordance

v

ij

< 0 : a

j

, a

k

in discordance

linear correlation coefficient

  • covariance standardized relevant

r

ij

= corr( a

k

, a

j

v

ij

j

k

∈ [−1,1]

⇒ ⇔ | v

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

a

j

, a

k

V = { v

1

,... , v

J

}, U = { u

1

,... , u

K

⇒ T t

rs

{ x

ij

= v

r

}, { x

ij

= u

s

f

r

K

s = 1

t

rs

g

s

J

r = 1

t

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)

a

j

, a

k

statistically independent ⇔

t

r 1

g

1

t

r 2

g

2

t

rk

g

k

, r = [1, J ] ⇒

t

1 s

f

1

t

Js

f

j

a

j

, a

k

a

j

a

k

a

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

  1. The length of every ray is matched to the value of corresponding attribute

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

tr ( V ) =

n

j = 1

v

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

  1. Training phase : algorithm applied to a subset , in order to derive classification rules that allow the corresponding

target class y to be attached to each observation x

  1. Test phase : rules generated in training phase used to classify remaining data from , predictions and actual target classes are

then compared to asses the algorithm efficiency

  1. Prediction phase : rules applied to new data

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

  1. one against all k classes = k binary problems to isolate each class

predicting the class applying k training classifiers + majority voting

  1. one against one k classes = ROUND ROBIN CLASSIFICATION

predicting the class applying k(k-1)/2 training classifiers + majority voting

in general extra computational is worth it

TAXONOMY OF CLASSIFICATION MODELS

03.1 EVALUATION METRICS

S

m

= {( x

i

, y

i

), i ∈ ℳ} : training set , x

i

∈ IR

n

and y

i

ℋdenotes a set of functions f ( x ) : IR

n

⇒ ℋ f * ∈ ℋ

x

i

y

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

𝒯 of 𝒟

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

f * ∈ ℱ ℋ

X

y

f( x )

binary

multicategory

K ( K − 1 )

∼ K

2

Heuristic models classification procedures based on intuitive and simple procedures K-NN, trees

Separation

models

SVM, NN

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

IR

n

{ S

1

,... , S

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

  • overfitted model: statistical model that contains more parameters than can be justified by the data
  • If we have 0 misclassifications in the training overfitting ( some samples will always be

outliers and we’re correctly classifying them as well )

  • There’s a trade off between

03.2 KNN - KEY NEAREST NEIGHBORS

03.3 CLASSIFICATION TREES

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

  1. Each obs. placed in the root note ( list of tree’s active nodes)
  2. If the list L is empty the procedure is stopped, otherwise a node J belonging to L is

selected and used for the next step

  1. The optimal rule to split observations contained in J is based on preset criterions

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 :

  • the cost associated with the p + v correctly classified observations is zero
  • by adequately regulating the relative weight of the two costs of u false negatives and q false positives, it is possible to

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

  • the lift depends on : values on the cumulative gain chart

b / s

a / m

b / s positive obs in 𝒮

a / m positive obs in 𝒟

Receiving operating characteristic

  • visually expresses the information content of a sequence of confusion

matrices (coming from models with varied parameters)

parameters of can be adjusted to maximize tpr

  • allows identification of ideal trade-off between false positives and false

negatives

  • (0,1) ideal classifier, (1,1) predicts 1 obs , (0,1) predicts - 1
  • AUC = area under the curve

asse x : fpr - false positive rate

asse y : tpr - true positive rate

f * ∈ ℱ

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

  • K, distance : hyper-parameters affects model’s acc. and robustness,

There is no systematic way for parameters optimization, it’s an empirical process (comparing scores)

→ ↑ K ⇒

less sentitive to ouliers

less distinction btw classes

score =

#obs of neighbors ∈ selected class

K

recursive (every step repeated for all nodes)

greedy (takes best choice for each node)

∈ L

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

  • categorical attributes should form two categories
  • numerical attributes are separated by threshold values

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

S P L I T T I N G R U L E S

MULTIVARIATE TREES - splitting rule

p.c. : f is a linear combination of explanatory variables

oblique decision trees - separations generate polygonal partition

Univariate vs multivariate

  • multivariate trees have usually higher predictive accuracy , but lower interpretability

than univariate trees

  • With same accuracy, oblique trees usually generate a lower no. of rules (cuts, depth)

:= ϕ ( x

1

, x

2

,... , x

n

) → ϕ ( x ) ≥ | ≤ b

ϕ ( x )

n

j = 1

w

j

x

j

≤ b

misclassification index

Proportion of misclassified examples

has a non derivable point

Entropy

Gini Index

Miscl( q ) = 1 − max

h

p

h

H

h = 1

p

h

log

2

p

h

H

h = 1

p

2

h

Information gain criteria

  1. compares the impurity indices evaluated for the parent node with the same index in the descendant nodes

splitting rule impurity

  1. Chooses the attribute and the partition that max the difference = information gain (≈ minimize the impurity)

I ( q

1

, q

2

,... q

k

K

k = 1

Q

k

Q

I ( q

k

Δ( q , q

1

,... , q

k

information gain

= I ( q )

⏟

father node

− I ( q

1

,... , q

k

descendant nodes

= I

q

K

k = 1

Q

k

Q

I ( q

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

UNIVARIATE SPLITTING CRITERIA -

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:

  1. Max when the records are balanced btw classes
  2. Min when all records same class
  3. Simmetria function with respect to

f ( X

j

f ( X j

p

h

v

h

, h ∈ ℋ

H

h = 1

p

h

I ( q ) = I ( q , p

h

) p

h

p h

03.5 LOGISTIC REGRESSION

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:

  • coefficients of computed by using an iterative method (usually aimed at max the likelihood by minimizing the sum of the

logarithms of predicted probabilities)

03.6 SVM - SUPPORT VECTOR MACHINES

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

  • nodes correspond to the predictive

variables

  • arcs indicate relationships of

stochastic dependence

  • complexity required to compute all possible combinations for estimating the

conditional probabilities, is limited in Bayesian networks,

  • the calculation simply reduces to those conditioning relationships determined by the

precedence links included in the network.

regression technique

adapted for binary [0,1] outcome problems

logistic regression

S ( t ) =

1 + e

− t

P ( y | x )

P ( y = 0 | x ) =

1

1 + e

w

′ x

P ( y = 1 | x ) =

1

e

w

′ x

  • e

w

′ x

w X , w

Classification Regression

log

P ( y = 1 | x )

P ( y = 0 | x )

= w ′ x

⏟

∈𝒞

= z

Binary classification problem is traced

back to the identification of a linear

regression model between the dependent

variable z and the original explanatory

attributes

w ′

Pro Cons

  • Easy to develop
  • Requires low # of variables - does not work well with large datasets - Only binary classification (no multi

class)

  • Only linear boundary

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”

ℱ

ℱ f * ∈ ℱ

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)

  • Maximum number of training points that can be correctly classified by a function

Expresses complexity of the hp space, increases

  • If VC = h then at least one set of h+1 points that cannot be correctly classified by the hp function

, confidence

complexity of hp space

confidence level ( )

ℱ f * f *

( R ( f ) − R

emp

( f ))

number of observations

number or separating planes OR degree of the separating function

R ( f ) ≤

γ log( 2 t / γ ) + 1 − log( η / 4 )

t

ψ ( t , γ , η )

+ R

emp

( t ) ≤ ψ ( t , γ , η ) + R

emp

( f ) ψ ( t , γ , η )

γ ( ↑ γ ⇒ ↑ R )

η ↓ η ⇒ ↑ R

has two critical drawbacks

ERM - empirical risk minimization

induction principle for selecting f *

How do we choose f *? loss function

expected risk

V ( y , f ( x ))

R ( f ) =

V ( y , f ( x )) d P ( x , y )

P() that obs will

fall in that interval

empirical error

removes the probability element

R

emp

( f ) =

t

t

i = 1

V ( y

i

, f ( x

i

but we often don’t know P ( x , y )

SRM - structural risk minimization

Chooses f * ∈ ℱ thatmin ψ ( t , γ , η ) + R

emp

( f )

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

f *

f * ∈ ℱ : min

R ( f ) =

t

t

i = 1

V ( y

i

, f ( x

i

)) + λ ∥ f ∥

2

K

regulizer

λ f *

03.7 NEURAL NETWORKS

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.

  • arcs are associated with a weight
  • For each node an activation function is defined
  • training performed analyzing in sequence the observations contained in the training set one after the other and by modifying at

each iteration the weights associated with the arcs

THE ROSENBLATT PERCEPTRON

  • simplest form of neural network (single neuron)
  • input values = values of attributes

distorsion [constant]

g activation function

  • considers obs one at a time and updates weights at each iteration

N O N L I N E A R S E P A R A T I O N

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?

  • Mercer’s theorem gives sufficient conditions for kernel’s existence (they under

very mild conditions)

    • implies that linear combination of kernels is a kernel function

There have been proposed and neural netwok-based kernels

rbf are not perfectly circular

ϕ ( x

i

)′ ϕ ( x

h

) = k ( x

i

, x

h

rbf : radial based

poly : polynomial

non linear prediction

  • Complementary conditions (KTT th)
  • The observations for which are at a distance 1/||w||

from separating the hyperplane and therefore lie on the

canonical hyperplane = support vector

f ( x ) = sgn

m

i = 1

i

y

i

k ( x

i

, x

h

) − b

i

( y

i

( w ′ x − b ) − 1 + d

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

{ x

1

,... x

m

v

Weights initialization

  • if the model is well built is should converge to the optimal weight in a finite and not too large number of iterations
  • However, the models often depend on the initial values
  • Historically : initialization with small positive numbers

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!

f ( x ) = g ( x

1

w

1

+... + x

n

w

n

− v ) = g ( w ′ x − v )

g (. ) = sgn(. )

g (. ) = S(. ) =

1 + e

(.)

g (. ) = Re L u =

y = 0 x ≤ 0

y = x x > 0

  1. initialize weights and threshold
  2. Input a record and compute its outcome
  3. Update weights according to the error

committed

  1. Repeat steps 2 and 3 until

error < threshold

# iterations > 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

03.8 ENSAMBLE CLASSIFIERS

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

  • number M of hidden units is a free parameter that is adjusted to reach optimum prediction ability (M ≈ order of the final total

function of the network)

  • An alternative is to choose a high M and then add a regularization term to the error function

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

  • Also, training can be stopped early (at each iteration the error on training data is minimized, hence leads to overfitting) when

the error on the validation set in minimum

Cons

  • Long training times
  • Low robustness with noisy data
  • Low interpretability

Optimization of neural networks

Find minimize the prediction error function

  • the prediction problem contains as many components as weights =

hidden nodes of the network

w : min E ( a

j

MULTI-LEVEL FEED-FORWARD NETWORKS

  • Each node operates as perceptron
  • Weights and activation function determined by a back propagation

algorithm (similar to single perceptron)

  • Linear transformations at each layer add up to non linear classification
  • Different function can be used in different nodes from the same

layer and in different layers

Parameters : #layers, #nodes (increasing the # of nodes there is

overfitting risk), types of function

h

Input Nodes Hidden nodes Output Nodes

receive the input x i

apply transformations to input return prediction value

Pro

  • both classification and regression problems

automatic selection of attributes (by regulating w )

i

w

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