nickgillian / grt

gesture recognition toolkit
859 stars 285 forks source link

How to enable nullrejection in HMM discrete? #106

Open ShivaAlsharif opened 7 years ago

ShivaAlsharif commented 7 years ago

Hello everybody, I have defined a discrete HMM with 4 states and 10 symbols. The discreteHMM recognizes gestures with the accuracy of almost 92%. However, null rejection doesn't work. I have already enabled the null rejection function: hmm.enableNullRejection(1); Any test data, even with one sample, is assigned to a class. The classLikelihood for the test data with one sample is almost near to 1 (no wonder that null rejection can not effect) .

if( useNullRejection ){ if( maxLikelihood > nullRejectionThresholds[ bestIndex ] ){ predictedClassLabel = classLabels[ bestIndex ]; } else predictedClassLabel = GRT_DEFAULT_NULL_CLASS_LABEL; } Could anyone help, how I can fix this issue?

nickgillian commented 7 years ago

I just had a quick review of the HMM predict function, and noticed that the null rejection is being run on the normalized likelihoods, this isn't the best option (as it just takes one not-so-bad raw likelihood to turn into a vale close to 1 when normalized, as you are observing with concious data being pumped though the model).

I can fix this over the weekend to give better null rejection support, alternatively you can have a stab at fixing it and do a pull request so others can take advantage of your improvement).

The simplest way to fix it is to store the best un-normalized likelihood, then use this as the input to the null rejection threshold logic at the end of the predict function.