Learn R Programming

LPStimeSeries (version 1.0-5)

computeSimilarity: Compute similarity between time series based on learned patterns

Description

Compute similarity between time series. Raw time series can be provided together with learnPattern object so that the representation for the time series are generated internally and similarity is computed based on these representations. The other option is to provide the representations (instead of raw time series) and to compute the similarity without a need for learnPattern object.

Usage

computeSimilarity(object=NULL,testseries=NULL,refseries=NULL, maxdepth=NULL,which.tree=NULL,sim.type=0, terminal=TRUE, testrepresentation,refrepresentation)

Arguments

object
an object of class learnPattern.
refseries
reference time series.
testseries
test time series.
maxdepth
maximum depth level to be used to generate representations for similarity computations.
which.tree
array of trees to be used for similarity computation.
sim.type
type of the similarity to compute. If set to zero, dissimilarity (absolute differences of the number of patterns) is computed. If set to one, similarity (minimum number of the matching patterns) is computed.
terminal
TRUE if similarity is computed over the learned representations.
testrepresentation
learned representation for test time series.
refrepresentation
learned representation for reference time series.

Value

A similarity matrix of size ``the number of test series`` by ``the number of reference series`` is returned. Similarity between test series and reference series is defined as the number of mismatching patterns based on the representation generated by the trees. See LPS paper for details.

References

Baydogan, M. G. (2013), ``Learned Pattern Similarity``, Homepage: http://www.mustafabaydogan.com/learned-pattern-similarity-lps.html.

See Also

learnPattern, predict.learnPattern

Examples

Run this code

data(GunPoint)
set.seed(71)
## Learn patterns on GunPoint training series with default parameters
ensemble=learnPattern(GunPoint$trainseries)

## Find the similarity between test and training series
sim=computeSimilarity(ensemble,GunPoint$testseries,GunPoint$trainseries)

## Find similarity using representations, 
## First generate representations
trainRep=predict(ensemble, GunPoint$trainseries, nodes=TRUE)
testRep=predict(ensemble, GunPoint$testseries, nodes=TRUE)

## Then compute the similarity (city-block distance), 
## takes longer but we keep the representation
sim2=computeSimilarity(testrepresentation=testRep,refrepresentation=trainRep)

## Find the similarity based on first 100 trees
sim=computeSimilarity(ensemble,GunPoint$testseries,GunPoint$trainseries,which.tree=c(1:100))


Run the code above in your browser using DataLab