Understanding ei_classifier_smooth_update()

I’m looking through the ei_classifier_smooth_update() definition (in ei_classifier_smooth.h), as a student is asking about this function. I’d like to make sure I understand what it’s doing.

From what I can tell, the function looks at the previous 10 inferences. If a label has the highest score over classifier_confidence (e.g. 0.8) min_readings_same (e.g. 7) out of n_readings (e.g. 10), it will be returned as the chosen label (otherwise, you’ll get “unknown”).

Am I on the right track?

Hi @ShawnHymel,

I haven’t tried it yet myself but I do understand the same from the code than what you’ve just explained.
As a return you will get either the label, uncertain or anomaly:

Best regards,


Correct. We also have a moving-average filter in the code which can be used to smooth out results.

Thanks all!

Is the moving average filter a separate part of the same ei_classifier_smooth_update() function? I’m not seeing it if so. Or are you referring to the part where it requires e.g. 7 out of the previous 10 readings to be above a threshold?

No, it’s actually here: https://github.com/edgeimpulse/inferencing-sdk-cpp/blob/6b402ac113af8e602246fbdcd49bcdaf06b826ce/classifier/ei_run_classifier.h#L133

We use it for smoothing out audio in continuous classification.


Got it, thank you! I remember seeing the MAF in the audio example…I just didn’t see it in the motion example :slight_smile:

1 Like