A Bayesian Hybrid Approach to Unsupervised Time Series ... · TAAI-2010 Prior mean of the Gaussian...

27
A Bayesian Hybrid Approach to Unsupervised Time Series Discretization Yoshitaka Kameya Tokyo Institute of Technology 20/Nov/2010 1 TAAI-2010 Gabriel Synnaeve Grenoble University Andrei Doncescu LAAS-CNRS Katsumi Inoue National Institute of Informatics Taisuke Sato Tokyo Institute of Technology

Transcript of A Bayesian Hybrid Approach to Unsupervised Time Series ... · TAAI-2010 Prior mean of the Gaussian...

Page 1: A Bayesian Hybrid Approach to Unsupervised Time Series ... · TAAI-2010 Prior mean of the Gaussian for level k Weight (Pseudo count) Expected counts of staying at level k Expected

A Bayesian Hybrid Approach to Unsupervised Time Series Discretization

Yoshitaka KameyaTokyo Institute of Technology

20/Nov/2010 1TAAI-2010

Gabriel SynnaeveGrenoble University

Andrei DoncescuLAAS-CNRS

Katsumi InoueNational Institute of Informatics

Taisuke SatoTokyo Institute of Technology

Page 2: A Bayesian Hybrid Approach to Unsupervised Time Series ... · TAAI-2010 Prior mean of the Gaussian for level k Weight (Pseudo count) Expected counts of staying at level k Expected

Outline

• Review: Unsupervised discretization of time series data

– Preliminary experimental results

• Hybrid discretization method based on variational Bayes

• Experimental results

• Summary and future work

20/Nov/2010 2TAAI-2010

Page 3: A Bayesian Hybrid Approach to Unsupervised Time Series ... · TAAI-2010 Prior mean of the Gaussian for level k Weight (Pseudo count) Expected counts of staying at level k Expected

Discretization

• ... converts numeric data into symbolic data

• ... is a preprocessing task in knowledge discovery

• ... may lead to noise reduction and a good data abstraction

– We wish to have interpretable discrete levels

• ... may help symbolic data mining

– Frequent pattern mining

– Inductive logic programming

20/Nov/2010 3

3.22.80.16.4...

mediummedium

lowhigh...

TAAI-2010

........ .........

......

............

.... .... ......

Selection

Preprocessing Transformation

Datamining

Interpretation/Evaluation

Target data

Preprocesseddata

Transformeddata

Patterns

Knowledge

[Fayyad et al. 1995]

Page 4: A Bayesian Hybrid Approach to Unsupervised Time Series ... · TAAI-2010 Prior mean of the Gaussian for level k Weight (Pseudo count) Expected counts of staying at level k Expected

Unsupervised discretization of time series data

• Binning:– Equal width binning– Equal frequency binning– ...

• Clustering:– Hierarchical clustering [Dimitrova et al. 05]

– K-means– Gaussian mixture models [Mörchen et al. 05b]

– ...

• Smoothing:– Regression trees [Geurts 01]

– Smoothing filters• Moving averaging• Savitzky-Golay filters [Mörchen et al. 05b]

– ...

• All-in-one methods:– SAX [Lin et al. 07]

– Persist [Mörchen et al. 05a]

– Continuous hidden Markov models[Mörchen et al. 05a]

20/Nov/2010 4TAAI-2010

Common strategy:

– Smoothing at the time (x) axis

– Binning or clustering at the measurement (y) axis

combined sequentiallyor simultaneously

SAXtime

measurement

b a a b c c b c

Page 5: A Bayesian Hybrid Approach to Unsupervised Time Series ... · TAAI-2010 Prior mean of the Gaussian for level k Weight (Pseudo count) Expected counts of staying at level k Expected

Persist [Mörchen et al. 05a]

• Assumption:Time series tries to stay at one of the discrete levels (= states)as long as possible

• Persist greedily chooses the breakpoints so that less state changes occur a role of smoothing

20/Nov/2010 5

Breakpoints S1

S2

S3

S4

state changes

TAAI-2010

Page 6: A Bayesian Hybrid Approach to Unsupervised Time Series ... · TAAI-2010 Prior mean of the Gaussian for level k Weight (Pseudo count) Expected counts of staying at level k Expected

Continuous hidden Markov models

• Two-step procedure– Train the HMM

– Find the most probable state sequence by the Viterbi algorithm State sequence = Discrete time series

20/Nov/2010 6

Positions and shapes of Gaussians

are adjusted by EM

X1 X2 X3 X4 X5 X6 X7 X8

S1 S2 S3 S4 S5 S6 S7 S8

State 1

State 2

State 3

Mean at State 1

Mean at State 2

Mean at State 3

TAAI-2010

discrete state

Gaussianoutput

(measurement)

Page 7: A Bayesian Hybrid Approach to Unsupervised Time Series ... · TAAI-2010 Prior mean of the Gaussian for level k Weight (Pseudo count) Expected counts of staying at level k Expected

Preliminary experiment [Mörchen et al. 05]

• Comparison on the predictive performance among the discretizers

• We used an artificial dataset called the “enduring-state” dataset

20/Nov/2010 7

How well do the discretizers recover

the answers?

– SAX– Persist– HMMs– Equal width binning

(EQW)– Equal frequency

binning (EQF)– Gaussian mixture

model (GMM)

TAAI-2010

noises

outliers

Page 8: A Bayesian Hybrid Approach to Unsupervised Time Series ... · TAAI-2010 Prior mean of the Gaussian for level k Weight (Pseudo count) Expected counts of staying at level k Expected

Preliminary experiment (Cont’d)

20/Nov/2010 8

• Error analysis: Persist– Levels are correctly identified

– However many noises go across the boundaries5 levels5 % outliers

TAAI-2010

Page 9: A Bayesian Hybrid Approach to Unsupervised Time Series ... · TAAI-2010 Prior mean of the Gaussian for level k Weight (Pseudo count) Expected counts of staying at level k Expected

Preliminary experiment (Cont’d)

20/Nov/2010 9

• Error analysis: HMMs– Some levels are misidentified

– Small noises are correctly smoothed5 levels5 % outliers

TAAI-2010

Page 10: A Bayesian Hybrid Approach to Unsupervised Time Series ... · TAAI-2010 Prior mean of the Gaussian for level k Weight (Pseudo count) Expected counts of staying at level k Expected

• From preliminary experiments, we can see:

– Persist:robust in identifying the discrete levels(because its heuristic score captures the global behaviorof the time series)

– HMMs: good at local smoothing

Motivation

20/Nov/2010 10TAAI-2010

Our proposal:Hybridization of heterogeneous discretizersbased on variational Bayes

Page 11: A Bayesian Hybrid Approach to Unsupervised Time Series ... · TAAI-2010 Prior mean of the Gaussian for level k Weight (Pseudo count) Expected counts of staying at level k Expected

• Efficient technique for Bayesian learning [Beal 03]

– Empirically known as robust against outliers

– Gives a principled way of determining # of discrete levels

• An HMM is modeled as: p(x, z,q ) = p(q ) p(x, z | q )

– x: input time series

– z: hidden state sequence(discretized time series)

– q : parameters

– p(q ): prior

– p(x, z | q ): likelihood

• Prior of means and variances in HMMs:

Variational Bayes

20/Nov/2010 11

X1 X2 X3 X4 X5 X6 X7 X8

S1 S2 S3 S4 S5 S6 S7 S8

x:

z:

TAAI-2010

Normal-Gamma distribution(conjugate prior)

hyperparameters

Page 12: A Bayesian Hybrid Approach to Unsupervised Time Series ... · TAAI-2010 Prior mean of the Gaussian for level k Weight (Pseudo count) Expected counts of staying at level k Expected

• Variational Bayesian EM in general form:

– We try to find q = q* that maximizes the variational free energy F[q]:

– F[q] is a lower bound of the marginal likelihood L(x):

F[q*] is a good approximation of L(x)

– To get q*, assuming q(z,q ) ≈ q(z)q(q ), we iterate the two steps

alternately:

– From L(x) – F[q*] = KL(q*(z,q ), p(z,q | x)), q* is a good approximation

of the posterior distribution and so used for discretization

Variational Bayes (Cont’d)

20/Nov/2010 12

zzxpzqpq

dzxpqzq

)|,(log)(exp)()(:step M-VB

))|,(log)(exp)(:step E-VB

qqq

qqq

zd

zq

zxpzqqF q

q

qq

),(

),,(log),(][

zdzxpxpxL qq ),,(log)(log)(

TAAI-2010

Page 13: A Bayesian Hybrid Approach to Unsupervised Time Series ... · TAAI-2010 Prior mean of the Gaussian for level k Weight (Pseudo count) Expected counts of staying at level k Expected

• The means of Gaussians are updated by:

• We simply set where bk are the breakpointsobtained by Persist

• In a similar way, we can alsocombine HMMs with SAX

breakpoints

1/3

1/3

1/3

Hybridization

20/Nov/2010 13

breakpoints S1

S2

S3

S4

TAAI-2010

Prior mean ofthe Gaussian for level k Weight (Pseudo count)

Expected counts of staying at level k

Expected mean ofthe Gaussian for level k

We aim to control the HMM

by the settings of t and mk

Page 14: A Bayesian Hybrid Approach to Unsupervised Time Series ... · TAAI-2010 Prior mean of the Gaussian for level k Weight (Pseudo count) Expected counts of staying at level k Expected

Experiment 1: “Enduring-state” dataset

20/Nov/2010 14

Weight t = 0.5, 1, 5, 10, 20, 50, 70, 100

TAAI-2010ratio of outliers

raw time series (input)

Page 15: A Bayesian Hybrid Approach to Unsupervised Time Series ... · TAAI-2010 Prior mean of the Gaussian for level k Weight (Pseudo count) Expected counts of staying at level k Expected

Experiment 1: “Enduring-state” dataset

20/Nov/2010 15

Weight t = 0.5, 1, 5, 10, 20, 50, 70, 100

TAAI-2010ratio of outliers

raw time series (input)

Page 16: A Bayesian Hybrid Approach to Unsupervised Time Series ... · TAAI-2010 Prior mean of the Gaussian for level k Weight (Pseudo count) Expected counts of staying at level k Expected

Experiment 1: “Enduring-state” dataset

20/Nov/2010 16

Weight t = 0.5, 1, 5, 10, 20, 50, 70, 100

TAAI-2010ratio of outliers

raw time series (input)

Page 17: A Bayesian Hybrid Approach to Unsupervised Time Series ... · TAAI-2010 Prior mean of the Gaussian for level k Weight (Pseudo count) Expected counts of staying at level k Expected

Experiment 1: “Enduring-state” dataset

20/Nov/2010 17

Weight t = 0.5, 1, 5, 10, 20, 50, 70, 100

TAAI-2010ratio of outliers

raw time series (input)

Page 18: A Bayesian Hybrid Approach to Unsupervised Time Series ... · TAAI-2010 Prior mean of the Gaussian for level k Weight (Pseudo count) Expected counts of staying at level k Expected

Experiment 1: “Enduring-state” dataset

20/Nov/2010 18

Weight t = 0.5, 1, 5, 10, 20, 50, 70, 100

TAAI-2010ratio of outliers

raw time series (input)

Page 19: A Bayesian Hybrid Approach to Unsupervised Time Series ... · TAAI-2010 Prior mean of the Gaussian for level k Weight (Pseudo count) Expected counts of staying at level k Expected

Experiment 1: “Enduring-state” dataset

20/Nov/2010 19

Weight t = 0.5, 1, 5, 10, 20, 50, 70, 100

Under accuracy

HMM+Persist issignificantly better than Persist except several cases with a large # of levels and many outliers

Under NMI

HMM+Persist issignificantly betterthan Persist for all cases

according to Wilcoxon’srank sum test (p = 0.01)

TAAI-2010ratio of outliers

Page 20: A Bayesian Hybrid Approach to Unsupervised Time Series ... · TAAI-2010 Prior mean of the Gaussian for level k Weight (Pseudo count) Expected counts of staying at level k Expected

Experiment 2: Background

• Also based on [Mörchen et al. 05a]

• Data on muscle activation of a professional inline speed skater

– Nearly 30,000 points recorded in log-scale

20/Nov/2010 TAAI-2010 20

Page 21: A Bayesian Hybrid Approach to Unsupervised Time Series ... · TAAI-2010 Prior mean of the Gaussian for level k Weight (Pseudo count) Expected counts of staying at level k Expected

• Estimating a plausible # of discrete levels automaticallywith variational Bayes

• An expert prefers to have 3 levels [Mörchen et al. 05a]

Experiment 2: Goal

20/Nov/2010 TAAI-2010 21

Last kick to the groundto move forward

Gliding phase (muscle isused to keep stability)

Page 22: A Bayesian Hybrid Approach to Unsupervised Time Series ... · TAAI-2010 Prior mean of the Gaussian for level k Weight (Pseudo count) Expected counts of staying at level k Expected

Experiment 2: Settings

• Having so many (30,000) data points, we need to:

– Use large pseudo counts ( 500)

– Use PAA (used in SAX) to compress the time series

20/Nov/2010 TAAI-2010 22

(frame size = 50)

Page 23: A Bayesian Hybrid Approach to Unsupervised Time Series ... · TAAI-2010 Prior mean of the Gaussian for level k Weight (Pseudo count) Expected counts of staying at level k Expected

Experiment 2: Discretization by CHMMs (Cont’d)

• PAA disabled• Savitzky-Golay filter enabled with half-window size = 100• Pseudo counts = 1

20/Nov/2010 TAAI-2010 23

# of levels

Page 24: A Bayesian Hybrid Approach to Unsupervised Time Series ... · TAAI-2010 Prior mean of the Gaussian for level k Weight (Pseudo count) Expected counts of staying at level k Expected

Experiment 2: Discretization by CHMMs (Cont’d)

• PAA disabled• Pseudo counts = 1000

20/Nov/2010 TAAI-2010 24

# of levels

Page 25: A Bayesian Hybrid Approach to Unsupervised Time Series ... · TAAI-2010 Prior mean of the Gaussian for level k Weight (Pseudo count) Expected counts of staying at level k Expected

Experiment 2: Discretization by CHMMs (Cont’d)

• PAA enabled with frame size = 10• Pseudo counts = 1

20/Nov/2010 TAAI-2010 25

# of levels

Page 26: A Bayesian Hybrid Approach to Unsupervised Time Series ... · TAAI-2010 Prior mean of the Gaussian for level k Weight (Pseudo count) Expected counts of staying at level k Expected

Experiment 2: Discretization by CHMMs (Cont’d)

• PAA enabled with frame size = 20• Pseudo counts = 1

20/Nov/2010 TAAI-2010 26

# of levels

Page 27: A Bayesian Hybrid Approach to Unsupervised Time Series ... · TAAI-2010 Prior mean of the Gaussian for level k Weight (Pseudo count) Expected counts of staying at level k Expected

Summary

• Unsupervised discretization of time series data

• Hybridizing heterogeneous discritizers via variational Bayes

– Fast approximate Bayesian inference

– Robust against noises

– Automatic finding of the plausible number of discrete levels

20/Nov/2010 TAAI-2010 27

Future work• Histogram-based discretizer