Package ai.libs.jaicore.ml.tsc.distances
Class WeightedDynamicTimeWarping
- java.lang.Object
-
- ai.libs.jaicore.ml.tsc.distances.WeightedDynamicTimeWarping
-
- All Implemented Interfaces:
ITimeSeriesDistance
public class WeightedDynamicTimeWarping extends java.lang.Object implements ITimeSeriesDistance
Implementation of the Dynamic Time Warping (DTW) measure as published in "Weighted dynamic time warping for time series classification" by Young-Seon Jeong, Myong K. Jeong and Olufemi A. Omitaomu. DTW does not account for the relative importance regarding the phase difference between a reference point and a testing point. This may lead to misclassification especially in applications where the shape similarity between two sequences is a major consideration for an accurate recognition. Therefore, [the authors] propose a novel distance measure, called a weighted DTW (WDTW), which is a penalty-based DTW. [Their] approach penalizes points with higher phase difference between a reference point and a testing point in order to prevent minimum distance distortion caused by outliers.
-
-
Constructor Summary
Constructors Constructor Description WeightedDynamicTimeWarping(double g, double maximumWeight, IScalarDistance d)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected double[]calculateWeights(int length)Calculates the weight vector via the Modified logistic weight function (see paper 4.2).doubledistance(double[] a, double[] b)Calculates the distance between two time series.
-
-
-
Constructor Detail
-
WeightedDynamicTimeWarping
public WeightedDynamicTimeWarping(double g, double maximumWeight, IScalarDistance d)Constructor.- Parameters:
g- Controls the penelization in weights for points with larger phase difference.maximumWeight- The desired upper bound for the weight parameter that is used to penalize points with higher phase difference.
-
-
Method Detail
-
distance
public double distance(double[] a, double[] b)Description copied from interface:ITimeSeriesDistanceCalculates the distance between two time series.- Specified by:
distancein interfaceITimeSeriesDistance- Parameters:
a- First time series.b- Second time series.- Returns:
- Distance between the first and second time series.
-
calculateWeights
protected double[] calculateWeights(int length)
Calculates the weight vector via the Modified logistic weight function (see paper 4.2). Uses memoization to avoid multiple calculations for the same length.- Parameters:
length- Length of the time series, i.e. length of the weight vector. Is guaranteed to be greater 0 within this class.- Returns:
- Resulting weight vector.
-
-