























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!
























__________________________________________ (^) Statistical Learning for Automation Systems __________________________________________ Learning feasibility
T input variable y output variable f : X → Y target function h ∈ H generic model g : X → Y candidate model (with tuned parameters) D (^) N ={( x ( 1 ) , y
( 2 ) , y
( N ) , y
} dataset Learning is impossible from a deterministic point of view because we there is no assumption on how data is generated and we cannot hypothesize how the model performs outside the datapoints It becomes possible in a probabilistic framework assuming that data is i.i.d. from a certain distribution. Learning is meaningful if: A pattern exists The pattern cannot be derived mathematically We have data E (^) ¿ ( g )= 1 N ∑ i = 1 N ⟦ g ( x
⟧ ∈ [ 0 , 1 ] in-sample error
Hoeffding’s inequality provides a probabilistic bound on how much the empirical error deviates from the true error → P (^) (| E (^) ¿ ( g )− E (^) out ( g )|> ε (^) ) ≤ 2 M e − 2 ε 2 N Objectives of learning Fitting (minimizing E (^) ¿ ( g )) Generalization (minimizing (^) |^ E^ ¿ (^ g^ )−^ E^ out (^ g^ )|) Linear regression^ y^ =∑ i = 0 n w (^) i x (^) i
E (^) out ( w )= E [( y −∑ i = 0 ¿ n w (^) i x (^) i ) 2 ] The goal of OLS (Ordinary Least Squares) is to minimize the sum of the squared errors between predicted output and actual output E (^) ¿ ( w )= 1 N ∑ j = 0 N
( j ) − ^ y ( j )
2 = 1 N ∑ j = 0 N ( y ( j ) −∑ i = 0 n w (^) i x (^) i ( j ) ) 2 w^ ^ = argmin w E (^) ¿ ( w )= argmin w 1 N
2
T
− 1 X T Y Learning a linear model equals to fitting the values of w (^) i that minimize E (^) ¿ ( w ) Necessary and sufficient conditions for w^ to be a minimum:
− 1 X T Y null gradient
2 E (^) ¿ ( w ) ∂ w (^2) | ^ w > 0 hessian of E (^) ¿ is a positive definite Generalization → E (^) out ( w )= E (^) ¿ ( w ) + O ( n N ) Linear classification ^^ y^ ( j ) = sign ( i∑ = 0 n w (^) i x (^) i ( j ) ) = sign ( w T x ) → perceptron E (^) ¿ ( g )= 1 N ∑ j = 0 N
( j )
( j )
2 g ( x )= w T x Learning a perceptron is equal to finding the values of w (^) i that minimize the number of missclassified points. The idea is to move the hyperplane to correctly classify every point PLA update rule: w ( 0 ) can be a random guess of values w ( k + 1 )= w ( k ) + y (^ j^ )^ ( k ) x (^ j^ )^ ( k ) Generalization → E (^) out ( w )= E (^) ¿ ( w ) + O (√ n N ln N (^) ) Logistic regression^ h^ (^ s^ )= e s 1 + e s ^^ y^ ∈^ [^0 ,^1 ]
Bias measures the error of the model due to simplifying assumptions between the average model and the target function Variance rapresents the sensitivity to fluctuation in the training data measuring the deviation of the model from the average model A model with high variance depends to much on the given data and might perform poorly on new unseen data leading to overfitting, while a model with high bias does not capture the underlying trend of the data well and might lead to underfitting When we find ourselves in an overfitting scenario, to improve model performance we can: Reduce the number of features of our model Use regularization techniques to penalize large coefficients Use cross-validation to find the right complexity for the model Increase the size of the training dataset to generalize better Model selection Regularization When working in optimality conditions, regularization adds a penalty term to the linear regression cost function E (^) ¿ to discourage the model from being too complex λ Penalità Effetto su w Effetto sul modello 0 nessuna liberi di crescere massima flessibilità (overfitting) medio moderata più contenuti modello più regolare grand e forte vicini a zero modello molto semplice (underfitting) E (^) aug ( w )= E (^) ¿ ( w ) + λ N w T w Cross-validation Cross-validation helps measure how complex a model should be by computing E (^) cv , which is an estimate of E (^) out , and compairing it with the ones of other model families With cross-validation we can tune hyperparameters that control complexity We partition D (^) N into a training dataset D (^) train (size N − k ), which will be used to train the model, and a validation
dataset D (^) val (size k ), which will give us a proxy of the out- of-sample performance E (^) val ≈ E (^) out ( ^ w ) as k increases
-^ E^ val is an unbiased estimation of^ E^ out →
( 1 k ) Rule of thumb:^ k^ =
5 Leave-one-out cross validation ( k = 1 ) → there are N ways to partition D (^) N into a training set and a validation set Each of the N times we partition the dataset, we compute a new model based on N − 1 points and test it on the remaining one E (^) cv = 1 N ∑ j = 1 N E (^) val ( j )
−( j )
1 N ∑ j = 1 N E (^) D [ E (^) val ( j )
−( j ) ( x ) ) (^) ]= 1 N
−( j )
N large
Nonlinear models
the separating surface Neural networks Neural networks are a biologically inspired tool that deals with complexity by combining many elements MLP Neural Networks To implement simple functions we use perceptrons, and we connect them with logical operations that are also modeled by perceptrons Increasing the number of perceptrons, we can obtain separating sufaces (=functions) of arbitrary complexity The activation function must be the same for all nodes MLP-NN are FF-NN that have at least one hidden layer
T
T
Volnoi tessalletion of the input space K nearest neighbor → assigns the label of the majority of the closest points ^ y = sign ( i∑ = 1 k y ( x ( i ) ) )
If N , k → ∞ but k N → (^0) , E (^) ¿ ( h ) → E (^) out ( h ) (^) and E (^) out ( h ) (^) is the minimun available error Classifier qualificators Missclassification error ( E (^) ¿ for training set, E (^) cv for validation set) Confusion matrix [ true p false p false n true n ] Accuracy:^ A^ = true p + true n true p + true n + false p + false n Precision: PPV = true p true p + false p Recall:^ TPR^ = true p true p + false n F1-score: F 1 =
Precision and recall are very useful when we want to know how good a model works in a situation where there is a significant size difference between the classes Clustering (unsupervised learning) The goal is to partition the input space in k clusters to easily predict the label of any new point x ¿ → k sets S with corresponding centroids μ Lloyd’s algorithm ( k means) Initialize the controids^ μ^1 ,…^ ,^ μ^ k Set S (^) j is the set of all points closer to μ (^) j ∀ j Update che position of the centroids → μ (^) j = 1 n (^) j ∑ j ∈ S (^) j x ( j ) Repeat the previous two steps until E (^) ¿ stops decreasing
How to select k if it’s not given a priori? In the E (^) ¿− k graph, we can observe that the optimal value of k is in the “knee” of the graph → the error function does not decrease significally anymore Hierarchical clustering In this approach E (^) ¿ is computed for each k (starting at zero error when the number of clusters is equal to the number of points) Data preprocessing
White noise → e ( s , t ) wn ( μ , λ 2 )^ γ^ e (^ τ^ )=^0 ∀^ τ^ ≠^0 Spectral density function Γ ( ω )= (^) ∑ τ =− ∞
Non negativity Γ ( ω ) ≥ 0 ∀ ω ∈ R Symmetry Γ ( ω )= Γ (− ω ) ∀ ω ∈ R Periodicity Γ ( ω )= Γ ( ω + 2 kπ ) ∀ ω ∈ R , k ∈ Z Inverse transform: γ ( τ )= 1 2 π ∫ − π π Γ ( ω ) e jωτ dω Learning with SP The out-of-sample error of an estimator can be written as E (^) out [ ^ Q (^) N ]= E [ ( Q − Q ¿ ) 2 ] + E (^) [( Q^ (^) N − Q ¿ ) 2 ] Correctness → E (^) [ ^ Q (^) N ]= Q ¿= Q Consistency → E (^) [( Q ¿− ^ Q (^) N ) 2 ]^ →^0 as^ N^ →^ ∞
correct
) e − jωτ Linear trends x ( s , t )= x (^) SSP ( t ) + linear trend
v ( t )= kt + q → v^ ( t )= argmin k , q E (^) [ ( x ( t )−( kt + q ) ) 2 ] Seasonality x ( s , t )= x (^) SSP ( t ) + seasonal behaviour v ( t )= v ( t + kT ) → v^ ( t )= 1 M ∑ h = 0 M − 1 x ( t + hT ) Supervised learning = learn from labeled data to predict outcomes (perceptrons, linear/logistic regression,k-NN) Unsupervised learning = learn from unlabeled data to discover hidden structure (k means) Parametric classification Nonparametric classification Pros Cons Pros Cons Computationally cheap Low storage Fast prediction of the output Good generalization Limited flexibility Requires correct model assumption Very flexible Few assumptions High memory usage Computationally expensive Sensitive to noise Advantages Disadvantages Linear Regression Continuous output, fast prediction Cannot adjust to nonlinear behaviours of data Perceptron Rapid class prediction Rigid binary output Logistic Regression Interpretable, threshold to divide classes can be suitably tuned, coefficient indicate the relative importance of a feature, converges to a global optimum (convex f) Computationally expensive (GD), assumes a linear relationship between inputs and log- odds of the target variable Neural Networks Useful when dealing with complex multilayer patterns, layers help the model in learning and generalizing, efficient on large datasets, adapts to changing data distributions A lot of layers can lead to overfitting and also require more computational capacity Linear regression with nonlinear input Enhances the performance of linear regression significantly, approximate nonlinear relationships with a simple model, physical interpretability Limited to interactions specified by the features (cannot learn new patterns) k-Nearest Neighbour No assumptions about data distribution, can Computationally expensive, sensitive to the
Division of the leading terms Mutiplication Subtraction Example: W ( z )= z − 1 1 − 1 2 z − 1 z − 1 1 − 1 2 z − 1 − z − 1
1 2 z − 2 0000 + 1 2 z − 2 0000 − 1 2 z − 2
1 4 z − 3 00000000 + 1 4 z − 3 z − 1
1 2 z − 2 Transformation from IR to TF W ( z )= Z ( ω ( t ) )=∑ t = 0 ∞ ω ( t ) z − t → useless because we would neeed a noise-free dataset and all the infinite values of the IR Transformation from SS to IR ω ( t )= { 0 t ≤ 0 H F t − 1 G t > 0 Observability and controllabilit y The system is fully controllable from output y ( t ) iff the observability matrix O (^) n = [
n − 1 ]^ is full rank Rank ( O )= n The system is fully controllable from input u ( t ) iff the
Rank ( R )= n BB identification in a non- parametric way using SS representatio The key task of subspace-based SS identification is moving from a measured experimental IR to a SS model 4-SID algorithm (noise-free IR dataset)
n in time domain H (^) n = [ ω (^1 ) ω (^2 ) ω ( 2 ) ω ( 3 ) ⋯ ω ( n ) ⋯ ω ( n + 1 ) ⋯ i ω ( n ) ω ( n − 1 ) i i ⋯ ω ( 2 n − 1 ) ]
We did a huge rank reduction
F^ ^ =( O 1 T O (^1) ) − 1 O (^1) T O (^2) 4-SID is optimal because it makes the best possible rank reduction of ~ H (^) qd BB identification in a parametric way using TF representatio n in time domain Prediction theory for DT dynamic linear system
2
ARMA models y ( t )= a 1 y ( t − 1 ) + a 2 y ( t − 2 ) + …+ a (^) n y ( t − n ) + c 0 e ( t ) + c 1 e ( t − 1 ) + p …+ c (^) m e
error to signal ratio Estimation of ARMA models from data
2 sample variance of 1 step ahead prediction
ϑ^ ^ N =[ ∑ t = 1 N φ ( t ) φ T ( t ) ] − 1 [ (^) t∑ = 1 N φ ( t ) y ( t ) ] J (^) N ( ϑ ) is a convex function → iterative method, (^1)! solution J (^) N ( ϑ ) is not convex → iterative method with multiple random initializations (can get stuck in local minima) For ARMA ( n , m ) and MA ( m ) models:
J (^) N ( ϑ )= 1 N ∑ i = 1 N ( A ( z , ϑ ) C ( z , ϑ ) y ( t ) ) 2 → to minime this function an iterative mthod with local quadratic approximation is used (Newton’s method or even better quasi-Newton’s method, that guarantees a positive second order approximation)
a (^1) ⋮ a (^) n b (^0) ⋮ b (^) p c (^1) ⋮ c (^) m