Generated C code of SVM algorithm not accurate

3 次查看(过去 30 天)
Hello,
I have created an SVM-Linear kernel algorithm script on MATLAB for classification of my data. The training gives 98% of validation accuracy and also the prediction for the new data is almost accurate everytime on MATLAB. I have generated C code of the trained model using MATLAB coder for an ARM cortex M4 controller and successfully implemented it. The problem now is the classification result for the new data on the microcontroller as stand-alone is not so accurate as on PC (MATLAB). It predicts the wrong class most of the times. I wonder what the reasons might be. Please help. Thanks.
Regards,
Nikhil
  1 个评论
Sachin Sharma
Sachin Sharma 2022-9-23
Hi, I am also facing the same issues. Did you got the solution for this?
With Regards
Sachin Sharma

请先登录,再进行评论。

回答(1 个)

Harsh Sharma
Harsh Sharma 2024-10-7
Hi Nikhiliesh,
I believe the generated C code is correct and there could be several reasons for mismatch in accuracy achieved on MATLAB and the “ARM cortex M4 controller, such as
  1. Preprocessing - Make sure that any data preprocessing you did in MATLAB, like normalizing or scaling your input data, is also done on the microcontroller.
  2. Numerical Precision - MATLAB uses high precision for calculations such as double-precision floating-point numbers. However, the ARM Cortex M4 microcontroller might use single-precision calculations or even integers. This can lead to differences in results.
  3. Memory Limitations - Microcontrollers have limited memory compared to PCs. This can affect how data is stored and processed, potentially leading to errors if the data is too large or if memory handling isn't optimized.
I hope that this answers your question. Happy Coding!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by