/// <summary> /// Aggregates the input features and executes the <see cref="Dtw"/> algorithm. /// </summary> /// <param name="signature1"></param> /// <param name="signature2"></param> /// <returns>Cost between <paramref name="signature1"/> and <paramref name="signature2"/></returns> public double Pair(Signature signature1, Signature signature2) { Progress = 0; Dtw dtwAlg = new Dtw(distanceMethod); double[][] testSig1 = signature1.GetAggregateFeature(InputFeatures).ToArray(); double[][] testSig2 = signature2.GetAggregateFeature(InputFeatures).ToArray(); Progress = 50;//.. double cost = dtwAlg.Compute(testSig1, testSig2); Log(LogLevel.Info, $"Paired SigID {signature1.ID} with SigID {signature2.ID}"); Log(LogLevel.Debug, $"Pairing result of SigID {signature1.ID} with SigID {signature2.ID}: {cost}"); Progress = 100; return(cost); }
public void TestComputeOneDimension() { double[][] signature1 = new double[3][]; //One dimension points. signature1[0] = new double[] { 4 }; signature1[1] = new double[] { 5 }; signature1[2] = new double[] { 8 }; double[][] signature2 = new double[3][]; signature2[0] = new double[] { 4 }; signature2[1] = new double[] { 5 }; signature2[2] = new double[] { 8 }; var dtw = new Dtw(); double cost = dtw.Compute(signature1, signature2); double expectedCost = 0; Assert.AreEqual(expectedCost, cost); }
public void TestComputeTwoDimension() { double[][] signature1 = new double[3][]; //Two dimension points. another test required for one dimension points. signature1[0] = new double[] { 1, 4 }; signature1[1] = new double[] { 2, 5 }; signature1[2] = new double[] { 3, 8 }; double[][] signature2 = new double[3][]; signature2[0] = new double[] { 1, 5 }; signature2[1] = new double[] { 2, 6 }; signature2[2] = new double[] { 3, 8 }; var dtw = new Dtw(); double cost = dtw.Compute(signature1, signature2); double expectedCost = 0; Assert.AreEqual(expectedCost, cost); }
public void TestSameInput() { double[][] signature1 = new double[3][]; //Two dimension points. another test required for one dimension points. signature1[0] = new double[] { 1, 4 }; signature1[1] = new double[] { 2, 5 }; signature1[2] = new double[] { 3, 8 }; double[][] signature2 = new double[3][]; signature2[0] = new double[] { 1, 4 }; signature2[1] = new double[] { 2, 5 }; signature2[2] = new double[] { 3, 8 }; var dtw = new Dtw(); double cost = dtw.Compute(signature1, signature2); double expectedCost = 0; double expectedDistance = 0; double distance = dtw.Distance(signature1[1], signature2[1]); Assert.AreEqual(expectedDistance, distance); Assert.AreEqual(expectedCost, cost); }
public void TestComputeDifferentLenghtInput() //SameLengthInput already tested in the previous tests. { double[][] signature1 = new double[3][]; //Two dimension points. another test required for one dimension points. signature1[0] = new double[] { 1, 4 }; signature1[1] = new double[] { 2, 5 }; signature1[2] = new double[] { 3, 8 }; double[][] signature2 = new double[4][]; signature2[0] = new double[] { 1, 6 }; signature2[1] = new double[] { 2, 7 }; signature2[2] = new double[] { 3, 10 }; signature2[3] = new double[] { 4, 12 }; var dtw = new Dtw(); double cost = dtw.Compute(signature1, signature2); double expectedCost = 0.25; double expectedDistance = 2; double distance = dtw.Distance(signature1[1], signature2[1]); Assert.AreEqual(expectedDistance, distance); Assert.AreEqual(expectedCost, cost); }