[Problem]:
if the test sample is the same as the training sample, DTW will return distance 0 and likelihood -NA which is wrong. Example, if I take some of the training data as testing data (now the testing sample == training sample), then this problem happens.
[Reason]:
In Line 410 of DTW.cpp, in the function of bool DTW::predict_(MatrixDouble &inputTimeSeries) {...
for(UINT k=0; k<numTemplates; k++){
//Perform DTW
classDistances[k] = computeDistance(templatesBuffer[k]....);
classLikelihoods[k] = 1.0 / classDistances[k];
....
////////! here the classDistances[k] is 0, and then used as divisor in the next line.
I've added a fix for this to the latest dev branch to address this. I'll merge this to the main master branch later this weekend with some other updates.
[Problem]: if the test sample is the same as the training sample, DTW will return distance 0 and likelihood -NA which is wrong. Example, if I take some of the training data as testing data (now the testing sample == training sample), then this problem happens.
[Reason]: In Line 410 of DTW.cpp, in the function of bool DTW::predict_(MatrixDouble &inputTimeSeries) {... for(UINT k=0; k<numTemplates; k++){ //Perform DTW classDistances[k] = computeDistance(templatesBuffer[k]....); classLikelihoods[k] = 1.0 / classDistances[k]; .... ////////! here the classDistances[k] is 0, and then used as divisor in the next line.
[My suggestion]: change the code: classLikelihoods[k] = 1.0 / classDistances[k]; to: classLikelihoods[k] = (classDistances[k] == 0 ? INT_MAX : 1.0 / classDistances[k]);