Is there way to call scikit-learn's functions from c++? I have the rest of most my code in C++ with opencv. I would like to be able use the classifiers scikit-learn provides. As far as I understand, there's no easy way - I need to use boost::python or swig. I also came across this project (https://github.com/spillai/numpy-opencv-converter) which shows interop between numpy arrays <==> cv::Mat objects, but I know only how to use to call C++ code from my python script, not the other way around.
4 Answers
Have you looked at native C++ libraries like shogun and mlpack? These might be much easier for you to use.
3 Comments
Cloud Cho
Please, share if there are any new C++ tools since your answer in 2015, thanks.
Avrdan
Does Shogun support DBSCAN?
Andreas Mueller
@Avrdan it doesn't look like it but MLPack does: mlpack.org/doc/stable/cli_documentation.html#mlpack_dbscan just check both of their documentations.
Following up from the original answer, There seem to be two approaches today to solve the problem
Comments
You can do it in a pretty straightforward way, by including python headers and just calling your python script and/or scikit methods via Py* wrappers.
See https://docs.python.org/2/extending/embedding.html#pure-embedding for a thorough example.
Comments
For some supported models, it may be possible to convert them to ONNX runtime an run that via C++.