how it works 1_class library ?
Hello ,
I'm trying to figure out how the 1_class library works. In the Emulator tab of the NanoedgeAI Studio software, I can see that the sensor indicates that the input pattern is detected as an outlier (outside the class considered), as shown in the following image:

But when embedded on microcontrollers, according to my code the orange LED should be flashing, but it's the green LED. I can't figure it out. Is my code correct? How can I retrieve the function output, which should be 0 for belongs to the class or 1 for outside of the class?
Thanks for your help.
A part of my code :
/*________________1_class_____________________*/
neai_state = neai_oneclass_init(knowledge);
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
if (drdy) {
/* Reset data ready variable */
drdy = 0;
/* Read watermark flag */
iis3dwb_fifo_status_get(&dev_ctx, &fifo_status);
if (fifo_status.fifo_th) {
num = fifo_status.fifo_level;
if (data_left > num) {
data_left -= num;
}
else {
num = data_left;
data_left = 0;
}
iis3dwb_get_buffer_from_fifo(num);
if (data_left == 0) {
/* Stop FIFO mode, set it in BYPASS mode */
iis3dwb_fifo_mode_set(&dev_ctx, IIS3DWB_BYPASS_MODE);
#if NEAI_MODE
uint32_t cycles_cnt = 0;
/* ############################## Partie Mode 1-class #######################################################*/
/*ici*/
KIN1_ResetCycleCounter();
neai_similarity = neai_oneclass(neai_buffer, &oneclass_result);
cycles_cnt = KIN1_GetCycleCounter();
if (neai_similarity == 0)
{
/*HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_RESET);
HAL_Delay(1000);
HAL_GPIO_WritePin(LED2_GPIO_Port, LED2_Pin, GPIO_PIN_SET);*/
printf("Regular");
HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin);
HAL_Delay(1000);
/*HAL_GPIO_WriteMultipleStatePin(LED1_GPIO_Port, LED1_Pin, LED2_Pin);*/
}
if(neai_similarity == 1){
/*
HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_SET);
HAL_GPIO_WritePin(LED2_GPIO_Port, LED2_Pin, GPIO_PIN_RESET); */
printf("Abnormal");
HAL_GPIO_TogglePin(LED2_GPIO_Port, LED2_Pin);
HAL_Delay(1000);
}
neai_time = (cycles_cnt * 1000000.0) / HAL_RCC_GetSysClockFreq();
printf("\n");
printf("NEAI learn return: %d.\n", neai_similarity);
