Machine Learning with C++

Yunusemre
2 min readFeb 18, 2024

Introduction

Machine learning is widely coded in Python. It would be okay for training, but we have to make it faster for our productions and integrate deployed applications. For this purpose, I decided to provide tutorials on that. These tutorials help engineers and researchers. All codes are available in a Github repo. If you are working on PyTorch, you can check this series for PyTorch in c++.

Installation

We will use the mlpack library which is a machine-learning library in c++. To install the mlpack, you can follow the below steps.

Install armadillo

sudo apt-get install liblapack-dev
sudo apt-get install libblas-dev
sudo apt-get install libboost-dev
sudo apt-get install libarmadillo-dev

Install ensmallen

git clone https://github.com/mlpack/ensmallen.git
cd ensmallen
mkdir build & cd build
cmake ..
sudo make install

Install Cereal

sudo apt-get install libcereal-dev

Install mlpack

git clone https://github.com/mlpack/mlpack.git
cd mlpack
mkdir build && cd build
cmake ..
sudo make install

After these steps, we can include mlpack.hpp in out c++ code.

Conclude

In this blog, I briefly introduced machine learning in c++ series and gave steps of installation mlpack. We will learn how to implement/use machine learning algorithms in c++ in the following blogs of this series. All codes are available in a Github repo.

--

--

Yunusemre

Graduate Student at Hacettepe University, R&D Engineer