Hello, this is my third article about how to use modern C++ for solving machine learning problems. This time I will show how to make a model for polynomial regression problem , with well known linear algebra library called Eigen.
Eigen was chosen because it is widely used and has a long history, it is highly optimized for CPUs, and it is a header only library. One of the famous project using it is TensorFlow. I found Eigen as the most useful library for linear algebra in C++. It has intuitive interfaces and implements modern C++ approaches, for example you can use std::move
to eliminate matrix coping in some cases. Also it has great documentation with examples and search engine. It supports Intel® Math Kernel Library (MKL), which provides highly optimized multi-threaded mathematical routines for x86-compatible architectures. And it can be used in CUDA kernels, but this is still an experimental feature.
Content
- Preparations
- Loading data to Eigen data-structures
- Standardization
- Generating additional polynomial components
- Batch gradient descent implementation
- Generating new data for testing model predictions
- Making predictions
- Plotting
It is the last article about linear algebra libraries for C++, I’m going to continue with articles about full featured ML frameworks for C++.
Continue reading the article and source code here.