Hi, everyone! I don’t understand the parameters in ei_classifier_smooth_init. ei_classifier_smooth_init(&smooth, 10 /* no. of readings /, 7 / min. readings the same /, 0.8 / min. confidence /, 0.3 / max anomaly */);
aurel
March 7, 2022, 10:44am
#2
Hi @future_verse ,
This function can be used to avoid printing predictions when the classification changes for 1 single reading only. You can read more about the function here:
/** * Initialize a smooth structure. This is useful if you don't want to trust * single readings, but rather want consensus * (e.g. 7 / 10 readings should be the same before I draw any ML conclusions). * This allocates memory on the heap! * @param smooth Pointer to an uninitialized ei_classifier_smooth_t struct * @param n_readings Number of readings you want to store * @param min_readings_same Minimum readings that need to be the same before concluding (needs to be lower than n_readings) * @param classifier_confidence Minimum confidence in a class (default 0.8) * @param anomaly_confidence Maximum error for anomalies (default 0.3) */ void ei_classifier_smooth_init(ei_classifier_smooth_t *smooth, size_t n_readings, uint8_t min_readings_same, float classifier_confidence = 0.8, float anomaly_confidence = 0.3) { smooth->last_readings = (int*)ei_malloc(n_readings * sizeof(int)); for (size_t ix = 0; ix < n_readings; ix++) { smooth->last_readings[ix] = -1; // -1 == uncertain } smooth->last_readings_size = n_readings; smooth->min_readings_same = min_readings_same; smooth->classifier_confidence = classifier_confidence;
Aurelien