Machine-Learning for SEQUENTIAL data Pr. Fabien Moutarde Center for Robotics MINES ParisTech PSL Université Paris Fabien.Moutarde@mines-paristech.fr http://people.mines-paristech.fr/fabien.moutarde Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 1 Outline • Specificities of SEQUENTIAL data • Alignment of sequences by DTW • Model sequential data with HMM Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 2
Specificities of SEQUENTIAL data • 2 specific problems: – How to compare sequences? – Length often VARIABLE! Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 3 Handling COMPARISON of sequences • 2 main types of approaches: – Alignment of sequences à Dynamic Time Warping (DTW) – Model-based method (e.g. Hidden Markov Model, HMM) Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 4
Handling VARIABLE LENGTH of sequences • 2 main types of approaches: – Time Resampling (but unapplicable for “stream” inline recognition) – Model-based methods: streaming successive inputs into a fixed-size model • Hidden Markov Model (HMM) • Recurrent Neural Network (RNN) Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 5 Outline • Specificities of SEQUENTIAL data • Alignment of sequence by DTW • Model sequential data with HMM Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 6
Dynamic Time Warping • Principle of DTW: 1. Align sequences and compute an adapted similarity measure 2. Perform recognition by template-matching with k Nearest Neighbors (using DTW similarity) Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 7 Alignment of sequences [Slide from Elena Tsiporkova] Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 8
Warping function [Slide from Elena Tsiporkova] Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 9 Time-Normalized Distance Measure [Slide from Elena Tsiporkova] Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 10
Optimizing DTW algorithm [Slide from Elena Tsiporkova] Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 11 Usual restrictions on Warping function [Slide from Elena Tsiporkova] Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 12
Other restrictions on Warping function [Slide from Elena Tsiporkova] Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 13 Slope constraints on Warping function [Slide from Elena Tsiporkova] Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 14
Choice of weighting coefficients [Slide from Elena Tsiporkova] Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 15 Pros and Cons of DTW • Pros – Allows speed-insensitive and flexible alignment • Cons – Computationally expansive (especially for multi-variate time-series) – Vanilla version is OFFLINE (i.e. after gesture) BUT “STREAM DTW” version solves this issue Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 16
Outline • Specificities of SEQUENTIAL data • Alignment of sequence by DTW • Model sequential data with HMM Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 17 What is a HMM? Stochastic (probabilistic) model obtained by statistical analysis of sequences of many examples of same class Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 18
Markovian?? « The future is independent of the past, given the present » Andreï Andreïevitch Markov Андрей Андреевич Марков 2 June 1856 - 20 July 1921 Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 19 Markov chains • Set of N States, {S 1 , S 2 ,… S N } • Sequence of states Q ={q 1 , q 2 ,…} • Initial probabilities π={π 1 , π 2 ,… π N } – π i =P(q 1 =S i ) • Transition matrix A NxN • a ij =P(q t+1 =S j | q t =S i ) Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 20
Example of Markov chain Weather model: • 3 states {sunny, rainy, cloudy} Problem: S S S S S 1 1 2 2 1 • Forecast weather state, based on the current weather state Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 21 Markov chain in action Let’s pick arbitrarily some numbers for ! " # " #$% and draw a probabilistic finite state | automaton 0,2 0,4 0,4 S 2 2 S 1 S 3 0,2 0,2 0,4 0,4 0,4 0,4 0,4 0,4 0,4 S 5 S 4 0,4 0,2 0,2 Question Given that now the state is S 2 , what’s the probability that next state will be S 3 AND the state after will be S 4 ? Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 22
Answer to Question S 2 S 3 S 4 This translates into: ' ( " ) = ' & , " % = ' ) * ! " ) = ' & , " & = ' ( +" % = ' ) = ! " & = | | ! " ) = ' & " % = ' ) ' ( " ) = ' & * | = ! " & = | ! " ) = ' & " % = ' ) = 0,4 * 0,4 = 0,16 You can also think this as moving through the automaton, multiplying the probabilities Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 23 λ=(A, B, π): Hidden Markov Model • A={a ij }: Transition probabilities between HIDDEN states – a ij =P(q t+1 =S j | q t =S i ) Β={b i ( x )}: Emission probabilities for observation given hidden • state – b i ( Ο t )=P(Ο t = x | q t =S i ) • π={π i }: Initial state probabilistic distribution – π i =P(q 1 =S i ) Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 24
Left to right (A) Left to right (B) S S S S S S S S 1 2 3 4 1 2 3 4 Left to right (C) Ergodic S S S S S S 1 2 4 6 1 3 S 2 S S 3 5 Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 25 • Evaluation – O, λ → P(O|λ) • Uncover the hidden part – O, λ → Q that P(Q|O, λ) is maximum • Learning – {Ο} → λ such that P(O|λ) is maximum Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 26
O, λ → P(O|λ ) ? • Solved by the Forward algorithm Applications a 11 a 22 a 33 a 44 a 55 a 66 – Find some likely samples – Evaluation of a sequence of S S S S S S 3 4 5 6 1 2 observations a 12 a 23 a a 23 a 34 a 45 a 56 – Change detection x � x � x � x � x � x � b 1 ( x ) b 2 ( x ) b 3 ( x ) b 4 ( x ) b 5 ( x ) b 6 ( x ) conditionally independent Induction Termination Initialisation Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 27 • {Ο} → λ such that P(O|λ) is maximum • No analytic solution • Solved by Baum-Welch algorithm (which is particular case of Expectation Maximization [EM] algo ) when some g data is missing (the states) • Applications max – Unsupervised Learning (single HMM) – Supervised Learning (multiple HMM) θ η Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 29
• Typically, learn ONE HMM per class, and then sequentially feed data in all HMM, so each one updates likelihood of sequence Μ 1 Likelihood computation Sequence of observations Μ 2 Gesture recognition Maximum likelihood Likelihood computation computation …. …. …. O(t) 1:7 Μ 4 Likelihood computation Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 30 Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 31
Pros and Cons of HMM • Pros – Natural handling of variable length • Cons – Many hyper-parameters (ARCHITECTURE and # of hidden states) Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 32 Synthesis • Sequential data raise specific problems: – what similarity measure should be used? (cf alignment problem) – Often variable length input • Two main shallow ML approaches adapted to this specificities: – Dynamic Time Warping (DTW) – Hidden Markov Model (HMM) Deep-Learning à Deep RECURRENT Neural Nets (LSTM, GRU) or 1D ConvNet over time Machine-Learning for SEQUENTIAL data, Pr. Fabien Moutarde, Center for Robotics, MINES ParisTech, PSL, June 2020 33
Recommend
More recommend