Package ai.libs.jaicore.basic.metric
Class TransformDistance
- java.lang.Object
-
- ai.libs.jaicore.basic.metric.AWeightedTrigometricDistance
-
- ai.libs.jaicore.basic.metric.TransformDistance
-
- All Implemented Interfaces:
org.api4.java.common.math.IMetric<double[]>
,IDistanceMetric
public class TransformDistance extends AWeightedTrigometricDistance
Implementation of the Transform Distance (TD) measure as published in "Non-isometric transforms in time series classification using DTW" by Tomasz Gorecki and Maciej Luczak (2014). Building up on their work of the Derivate Distance, the authors were looking for functions other than the derivative which can be used in a similar manner, what leads them to use transform instead of derivates. Given a distance measured
, the Transform Distance for the two time seriesA
andB
is:a * d(A, B) + b * d(t(A), t(B))
, wheret(A)
andt(B)
are transforms (@see jaicore.ml.tsc.filter.transform) ofA
andB
respec. and0 <= a <= 1, 0 <= b <= 1>
are parameters of the measure. The parametersa
andb
are set via analpha
value, that isa=cos(alpha)
andb=sin(alpha)
. The Transform Distance that uses Dynamic Time Warping as underlying distance measure is commonly denoted as TD_DTW. The Transform Distance that uses the Euclidean distance as underlying distance measure is commonly denoted as TD_ED.It is also possible to use a distinct distance measure to calculate the distance between the time series and its transforms.
-
-
Constructor Summary
Constructors Constructor Description TransformDistance(double alpha, IVectorTransform transform, IDistanceMetric distance)
Constructor that uses the same distance measures for the function and transform values.TransformDistance(double alpha, IVectorTransform transform, IDistanceMetric timeSeriesDistance, IDistanceMetric transformDistance)
Constructor with individual distance measures for the function and transform values.TransformDistance(double alpha, IDistanceMetric distance)
Constructor that uses the same distance measures for the function and transform values that uses theCosineTransform
as transformation.TransformDistance(double alpha, IDistanceMetric timeSeriesDistance, IDistanceMetric transformDistance)
Constructor with individual distance measures for the function and transform values that uses theCosineTransform
as transformation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
distance(double[] a, double[] b)
Calculates the distance between two time series.-
Methods inherited from class ai.libs.jaicore.basic.metric.AWeightedTrigometricDistance
getA, getAlpha, getB, setAlpha
-
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
-
TransformDistance
public TransformDistance(double alpha, IVectorTransform transform, IDistanceMetric timeSeriesDistance, IDistanceMetric transformDistance)
Constructor with individual distance measures for the function and transform values.- Parameters:
alpha
-transform
- The transform calculation to use.timeSeriesDistance
- The distance measure to use to calculate the distance of the transform values.transformDistance
- The distance measure to use to calculate the distance of the transform values.- See Also:
,0 = alpha = pi/2.
-
TransformDistance
public TransformDistance(double alpha, IDistanceMetric timeSeriesDistance, IDistanceMetric transformDistance)
Constructor with individual distance measures for the function and transform values that uses theCosineTransform
as transformation.- Parameters:
alpha
- The distance measure to use to calculate the distance of the function values.0 <= alpha <= pi/2
.timeSeriesDistance
- The distance measure to use to calculate the distance of the transform values.transformDistance
- The distance measure to use to calculate the distance of the transform values.
-
TransformDistance
public TransformDistance(double alpha, IVectorTransform transform, IDistanceMetric distance)
Constructor that uses the same distance measures for the function and transform values.- Parameters:
alpha
- The distance measure to use to calculate the distance of the function values.0 <= alpha <= pi/2
.transform
- The transform calculation to use.distance
- The distance measure to use to calculate the distance of the function and transform values.
-
TransformDistance
public TransformDistance(double alpha, IDistanceMetric distance)
Constructor that uses the same distance measures for the function and transform values that uses theCosineTransform
as transformation.- Parameters:
alpha
- The distance measure to use to calculate the distance of the function values.0 <= alpha <= pi/2
.distance
- The distance measure to use to calculate the distance of the function and transform values.
-
-
Method Detail
-
distance
public double distance(double[] a, double[] b)
Description copied from interface:IDistanceMetric
Calculates the distance between two time series.- Parameters:
a
- The influence of distance of the function values to the overall distance measure.b
- The influence of distance of the transform values to the overall distance measure.- Returns:
- Distance between the first and second time series.
-
-