MATLAB Answers

How to use a KNN classifier from Matlab in c++

1 view (last 30 days)
deams
deams on 29 May 2017
Answered: Bernhard Suhm on 20 Sep 2018
Hi,
I have been tinkering with the machine learning toolbox in Matlab for a while. Now that I managed to get a good classifier, I would like to test it out of the lab. I was happy to see that Matlab has a built-in code generation tool, but it seems that KNN classifiers are not included.
How would I go about using the trained KNN from Matlab in a c++ program?
Would I have to write my own KNN implementation and use the parameters from the trained one in Matlab? If so, is there such an implementation already?

Answers (1)

Bernhard Suhm
Bernhard Suhm on 20 Sep 2018
Little late, but with MATLAB Coder you can convert a prediction function for KNN to C/C++ code, and then use that with your other code for feature extraction (which you could write in MATLAB also, and then convert - for supported functions).

Community Treasure Hunt

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

Start Hunting!

Translated by