1

I am studying in machine learning now and I want to build up a recommender system. First, I would like to make a top-N recommendation using two existing methods and they are both written in C++ code. As the file are huge and complex, I want to call them with Python, instead of adding code on that. Which tool is suitable for my case? Thank you in advance!

Ulrich Eckhardt
  • 16,572
  • 3
  • 28
  • 55
codelover123
  • 187
  • 2
  • 14

2 Answers2

1

You can use standard python api , Cython or Boost.python. It is much easier to work with boost.python. You have to add very little code to your c++ library and compile it as a module library which then you can call from python.

with boost you can easily add your classes and their methods. Additionally you can introduce vector of an object which makes it easier to pass data to python and back to your library.

I recommend boost.python but you can look for yourself. There are a lot of tutorials on both cython and boost.python if you google it.

Ashkan
  • 1,050
  • 15
  • 32
0

Definitely use Cython. Useful tools to make the process easier: runcython (simplifies Cython use) and Google's protobuf library (simple / fast messaging serialization library). Here's a really simple example to help people get started: https://github.com/nicodjimenez/python2cpp

nicodjimenez
  • 1,180
  • 17
  • 15