Indexing Time Series. Outline Spatial Databases Temporal Databases Spatio-temporal Databases Data Mining Multimedia Databases Text databases Image and.

Slides:



Advertisements
Similar presentations
Alexander Gelbukh Special Topics in Computer Science Advanced Topics in Information Retrieval Lecture 6 (book chapter 12): Multimedia.
Advertisements

Indexing Time Series Based on original slides by Prof. Dimitrios Gunopulos and Prof. Christos Faloutsos with some slides from tutorials by Prof. Eamonn.
Time Series II.
CMU SCS : Multimedia Databases and Data Mining Lecture #23: DSP tools – Fourier and Wavelets C. Faloutsos.
Wavelets Fast Multiresolution Image Querying Jacobs et.al. SIGGRAPH95.
CMU SCS : Multimedia Databases and Data Mining Lecture #22: DSP tools – Fourier and Wavelets C. Faloutsos.
Engineering Mathematics Class #15 Fourier Series, Integrals, and Transforms (Part 3) Sheng-Fang Huang.
Fourier Transform (Chapter 4)
Spatial and Temporal Data Mining
Mining Time Series.
Chapter 5 Orthogonality
Time Series Indexing II. Time Series Data
Indexing Time Series. Time Series Databases A time series is a sequence of real numbers, representing the measurements of a real variable at equal time.
Indexing Time Series Based on Slides by C. Faloutsos (CMU) and D. Gunopulos (UCR)
Efficient Similarity Search in Sequence Databases Rakesh Agrawal, Christos Faloutsos and Arun Swami Leila Kaghazian.
Data Mining: Concepts and Techniques Mining time-series data.
CS490D: Introduction to Data Mining Prof. Chris Clifton
Distance Functions for Sequence Data and Time Series
1. 2 General problem Retrieval of time-series similar to a given pattern.
Based on Slides by D. Gunopulos (UCR)
Basic Concepts and Definitions Vector and Function Space. A finite or an infinite dimensional linear vector/function space described with set of non-unique.
Spatial and Temporal Data Mining
Euripides G.M. PetrakisIR'2001 Oulu, Sept Indexing Images with Multiple Regions Euripides G.M. Petrakis Dept.
Multimedia Databases Text II. Outline Spatial Databases Temporal Databases Spatio-temporal Databases Multimedia Databases Text databases Image and video.
Dimensionality Reduction
Digital Image Processing Final Project Compression Using DFT, DCT, Hadamard and SVD Transforms Zvi Devir and Assaf Eden.
Spatial and Temporal Databases Efficiently Time Series Matching by Wavelets (ICDE 98) Kin-pong Chan and Ada Wai-chee Fu.
Indexing Time Series.
Discrete Time Periodic Signals A discrete time signal x[n] is periodic with period N if and only if for all n. Definition: Meaning: a periodic signal keeps.
Fast Subsequence Matching in Time-Series Databases Christos Faloutsos M. Ranganathan Yannis Manolopoulos Department of Computer Science and ISR University.
Time Series I.
Multimedia and Time-series Data
CHAPTER FIVE Orthogonality Why orthogonal? Least square problem Accuracy of Numerical computation.
Image Processing Fourier Transform 1D Efficient Data Representation Discrete Fourier Transform - 1D Continuous Fourier Transform - 1D Examples.
Transforms. 5*sin (2  4t) Amplitude = 5 Frequency = 4 Hz seconds A sine wave.
Lecture 2 Signals and Systems (I)
1 Chapter 5 Image Transforms. 2 Image Processing for Pattern Recognition Feature Extraction Acquisition Preprocessing Classification Post Processing Scaling.
Dynamic Time Warping Algorithm for Gene Expression Time Series
5 -1 Chapter 5 The Divide-and-Conquer Strategy A simple example finding the maximum of a set S of n numbers.
Wavelet-based Coding And its application in JPEG2000 Monia Ghobadi CSC561 final project
A Query Adaptive Data Structure for Efficient Indexing of Time Series Databases Presented by Stavros Papadopoulos.
Mining Time Series.
Fast Subsequence Matching in Time-Series Databases Author: Christos Faloutsos etc. Speaker: Weijun He.
DCT.
E.G.M. PetrakisSearching Signals and Patterns1  Given a query Q and a collection of N objects O 1,O 2,…O N search exactly or approximately  The ideal.
2005/12/021 Fast Image Retrieval Using Low Frequency DCT Coefficients Dept. of Computer Engineering Tatung University Presenter: Yo-Ping Huang ( 黃有評 )
Chapter 2: Getting to Know Your Data
7- 1 Chapter 7: Fourier Analysis Fourier analysis = Series + Transform ◎ Fourier Series -- A periodic (T) function f(x) can be written as the sum of sines.
Euripides G.M. PetrakisIR'2001 Oulu, Sept Indexing Images with Multiple Regions Euripides G.M. Petrakis Dept. of Electronic.
Fourier Transform.
Intelligent Database Systems Lab Advisor : Dr. Hsu Graduate : Chien-Shing Chen Author : Jessica K. Ting Michael K. Ng Hongqiang Rong Joshua Z. Huang 國立雲林科技大學.
Indexing Time Series. Outline Spatial Databases Temporal Databases Spatio-temporal Databases Multimedia Databases Time Series databases Text databases.
CS 376b Introduction to Computer Vision 03 / 17 / 2008 Instructor: Michael Eckmann.
FastMap : Algorithm for Indexing, Data- Mining and Visualization of Traditional and Multimedia Datasets.
Chapter 13 Discrete Image Transforms
The Frequency Domain Digital Image Processing – Chapter 8.
Digital Image Processing Lecture 8: Fourier Transform Prof. Charlene Tsai.
Keogh, E. , Chakrabarti, K. , Pazzani, M. & Mehrotra, S. (2001)
Time Series Indexing II
Fast Subsequence Matching in Time-Series Databases.
Singular Value Decomposition and its applications
An Example of 1D Transform with Two Variables
Fast Approximate Query Answering over Sensor Data with Deterministic Error Guarantees Chunbin Lin Joint with Etienne Boursier, Jacque Brito, Yannis Katsis,
Distance Functions for Sequence Data and Time Series
Distance Functions for Sequence Data and Time Series
Finding Similar Time Series
Data Mining: Concepts and Techniques — Chapter 8 — 8
Data Mining: Concepts and Techniques — Chapter 8 — 8
Time Series Filtering Time Series
Data Mining: Concepts and Techniques — Chapter 8 — 8
Presentation transcript:

Indexing Time Series

Outline Spatial Databases Temporal Databases Spatio-temporal Databases Data Mining Multimedia Databases Text databases Image and video databases Time Series databases

Time Series Databases A time series is a sequence of real numbers, representing the measurements of a real variable at equal time intervals Stock prices Volume of sales over time Daily temperature readings ECG data A time series database is a large collection of time series

Time Series Data A time series is a collection of observations made sequentially in time. time axis value axis

Time Series Problems (from a database perspective) The Similarity Problem X = x 1, x 2, …, x n and Y = y 1, y 2, …, y n Define and compute Sim(X, Y) E.g. do stocks X and Y have similar movements? Retrieve efficiently similar time series (Indexing for Similarity Queries)

Types of queries whole match vs sub-pattern match range query vs nearest neighbors all-pairs query

Examples Find companies with similar stock prices over a time interval Find products with similar sell cycles Cluster users with similar credit card utilization Find similar subsequences in DNA sequences Find scenes in video streams

day $price 1365 day $price 1365 day $price 1365 distance function: by expert (eg, Euclidean distance)

Problems Define the similarity (or distance) function Find an efficient algorithm to retrieve similar time series from a database (Faster than sequential scan) The Similarity function depends on the Application

Metric Distances What properties should a similarity distance have? D(A,B) = D(B,A)Symmetry D(A,A) = 0Constancy of Self-Similarity D(A,B) >= 0 Positivity D(A,B)  D(A,C) + D(B,C)Triangular Inequality

Euclidean Similarity Measure View each sequence as a point in n-dimensional Euclidean space (n = length of each sequence) Define (dis-)similarity between sequences X and Y as p=1 Manhattan distance p=2 Euclidean distance

Euclidean model Query Q n datapoints S Q Euclidean Distance between two time series Q = {q 1, q 2, …, q n } and S = {s 1, s 2, …, s n } Distance Rank Database n datapoints

Easy to compute: O(n) Allows scalable solutions to other problems, such as indexing clustering etc... Advantages

Dynamic Time Warping [Berndt, Clifford, 1994] Allows acceleration-deceleration of signals along the time dimension Basic idea Consider X = x 1, x 2, …, x n, and Y = y 1, y 2, …, y n We are allowed to extend each sequence by repeating elements Euclidean distance now calculated between the extended sequences X’ and Y’ Matrix M, where m ij = d(x i, y j )

Example Euclidean distance vs DTW

X Y warping path j = i – w j = i + w Dynamic Time Warping [Berndt, Clifford, 1994] x1 x2 x3 y1 y2 y3

Restrictions on Warping Paths Monotonicity Path should not go down or to the left Continuity No elements may be skipped in a sequence Warping Window | i – j | <= w

Formulation Let D(i, j) refer to the dynamic time warping distance between the subsequences x 1, x 2, …, x i y 1, y 2, …, y j D(i, j) = | x i – y j | + min { D(i – 1, j), D(i – 1, j – 1), D(i, j – 1) }

Solution by Dynamic Programming Basic implementation = O(n 2 ) where n is the length of the sequences will have to solve the problem for each (i, j) pair If warping window is specified, then O(nw) Only solve for the (i, j) pairs where | i – j | <= w

Longest Common Subsequence Measures (Allowing for Gaps in Sequences) Gap skipped

Basic LCS Idea X = 3, 2, 5, 7, 4, 8, 10, 7 Y = 2, 5, 4, 7, 3, 10, 8, 6 LCS = 2, 5, 7, 10 Sim(X,Y) = |LCS| or Sim(X,Y) = |LCS| /n Edit Distance is another possibility

Similarity Retrieval Range Query Find all time series S where Nearest Neighbor query Find all the k most similar time series to Q A method to answer the above queries: Linear scan … very slow A better approach GEMINI

GEMINI Solution: Quick-and-dirty' filter: extract m features (numbers, eg., avg., etc.) map into a point in m-d feature space organize points with off-the-shelf spatial access method (‘SAM’) retrieve the answer using a NN query discard false alarms

GEMINI Range Queries Build an index for the database in a feature space using an R-tree Algorithm RangeQuery(Q,  ) 1. Project the query Q into a point q in the feature space 2. Find all candidate objects in the index within  3. Retrieve from disk the actual sequences 4. Compute the actual distances and discard false alarms

GEMINI NN Query Algorithm K_NNQuery(Q, K) 1. Project the query Q in the same feature space 2. Find the candidate K nearest neighbors in the index 3. Retrieve from disk the actual sequences pointed to by the candidates 4. Compute the actual distances and record the maximum 5. Issue a RangeQuery(Q,  max) 6. Compute the actual distances, return best K

GEMINI GEMINI works when: D feature (F(x), F(y)) <= D(x, y) Proof. (see book) Note that, the closer the feature distance to the actual one, the better.

Problem How to extract the features? How to define the feature space? Fourier transform Wavelets transform Averages of segments (Histograms or APCA) Chebyshev polynomials.... your favorite curve approximation...

Fourier transform DFT (Discrete Fourier Transform) Transform the data from the time domain to the frequency domain highlights the periodicities SO?

DFT A: several real sequences are periodic Q: Such as? A: sales patterns follow seasons; economy follows 50-year cycle (or 10?) temperature follows daily and yearly cycles Many real signals follow (multiple) cycles

How does it work? Decomposes signal to a sum of sine and cosine waves. Q:How to assess ‘similarity’ of x with a (discrete) wave? 0 1 n-1 time value x ={x 0, x 1,... x n-1 } s ={s 0, s 1,... s n-1 }

How does it work? A: consider the waves with frequency 0, 1,...; use the inner-product (~cosine similarity) 0 1 n-1 time value freq. f=0 0 1 n-1 time value freq. f=1 (sin(t * 2  n) ) Freq=1/period

How does it work? A: consider the waves with frequency 0, 1,...; use the inner-product (~cosine similarity) 0 1 n-1 time value freq. f=2

How does it work? ‘basis’ functions 0 1 n sine, freq =1 sine, freq = n cosine, f=1 cosine, f=2

How does it work? Basis functions are actually n-dim vectors, orthogonal to each other ‘similarity’ of x with each of them: inner product DFT: ~ all the similarities of x with the basis functions

How does it work? Since e jf = cos(f) + j sin(f) (j=sqrt(-1)), we finally have:

DFT: definition Discrete Fourier Transform (n-point): inverse DFT

DFT: properties Observation - SYMMETRY property: X f = (X n-f )* ( “*”: complex conjugate: (a + b j)* = a - b j ) Thus we use only the first half numbers

DFT: Amplitude spectrum Amplitude Intuition: strength of frequency ‘f’ time count freq. f AfAf freq: 12

DFT: Amplitude spectrum excellent approximation, with only 2 frequencies! so what?

C … Raw Data The graphic shows a time series with 128 points. The raw data used to produce the graphic is also reproduced as a column of numbers (just the first 30 or so points are shown). n = 128

C Fourier Coefficients … Raw Data We can decompose the data into 64 pure sine waves using the Discrete Fourier Transform (just the first few sine waves are shown). The Fourier Coefficients are reproduced as a column of numbers (just the first 30 or so coefficients are shown).

C Truncated Fourier Coefficients C’ We have discarded of the data Fourier Coefficients … Raw Data n = 128 N = 8 C ratio = 1/16

C Sorted Truncated Fourier Coefficients C’ Fourier Coefficients … Raw Data Instead of taking the first few coefficients, we could take the best coefficients

DFT: Parseval’s theorem sum( x t 2 ) = sum ( | X f | 2 ) Ie., DFT preserves the ‘energy’ or, alternatively: it does an axis rotation: x0 x1 x = {x0, x1}

Lower Bounding lemma Using Parseval’s theorem we can prove the lower bounding property! So, apply DFT to each time series, keep first 3-10 coefficients as a vector and use an R- tree to index the vectors R-tree works with euclidean distance, OK.

Wavelets - DWT DFT is great - but, how about compressing opera? (baritone, silence, soprano?) time value

Wavelets - DWT Solution#1: Short window Fourier transform But: how short should be the window?

Wavelets - DWT Answer: multiple window sizes! -> DWT

Haar Wavelets subtract sum of left half from right half repeat recursively for quarters, eightths... Basis functions are step functions with different lenghts

Wavelets - construction x0 x1 x2 x3 x4 x5 x6 x7

Wavelets - construction x0 x1 x2 x3 x4 x5 x6 x7 s1,0 + - d1,0 s1,1d1, level 1

Wavelets - construction d2,0 x0 x1 x2 x3 x4 x5 x6 x7 s1,0 + - d1,0 s1,1d1, s2,0 level 2

Wavelets - construction d2,0 x0 x1 x2 x3 x4 x5 x6 x7 s1,0 + - d1,0 s1,1d1, s2,0 etc...

Wavelets - construction d2,0 x0 x1 x2 x3 x4 x5 x6 x7 s1,0 + - d1,0 s1,1d1, s2,0 Q: map each coefficient on the time-freq. plane t f

Wavelets - construction d2,0 x0 x1 x2 x3 x4 x5 x6 x7 s1,0 + - d1,0 s1,1d1, s2,0 Q: map each coefficient on the time-freq. plane t f

Wavelets - Drill: t f time value Q: baritone/silence/soprano - DWT?

Wavelets - Drill: t f time value Q: baritone/soprano - DWT?

Wavelets - construction Observation1: ‘+’ can be some weighted addition ‘-’ is the corresponding weighted difference (‘Quadrature mirror filters’) Observation2: unlike DFT/DCT, there are *many* wavelet bases: Haar, Daubechies-4, Daubechies-6,...

Advantages of Wavelets Better compression (better RMSE with same number of coefficients) closely related to the processing of the mammalian eye and ear Good for progressive transmission handle spikes well usually, fast to compute (O(n)!)

Feature space Keep the d most “important” wavelets coefficients Normalize and keep the largest Lower bounding lemma: the same as DFT