Package ai.libs.jaicore.basic.metric
Class WeightedDynamicTimeWarping
- java.lang.Object
-
- ai.libs.jaicore.basic.metric.WeightedDynamicTimeWarping
-
- All Implemented Interfaces:
org.api4.java.common.math.IMetric<double[]>,IDistanceMetric
public class WeightedDynamicTimeWarping extends java.lang.Object implements IDistanceMetric
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.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.api4.java.common.metric.IDistanceMetric
getDistance
-
-
-
-
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:IDistanceMetricCalculates the distance between two time series.- Specified by:
distancein interfaceIDistanceMetric- 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.
-
-