Machine learning is a vast and exiciting discipline, garnering attention from specialists of many fields. Unfortunately, for C++ programmers and enthusiasts, there appears to be a lack of support in the field of machine learning. To fill that void and give C++ a true foothold in the ML sphere, this library was written. The intent with this library is for it to act as a crossroad between low-level developers and machine learning engineers.
Begin by downloading the header files for the ML++ library. You can do this by cloning the repository and extracting the MLPP directory within it:
git clone https://github.com/novak-99/MLPP
Next, execute the "buildSO.sh" shell script:
sudo ./buildSO.sh
After doing so, maintain the ML++ source files in a local directory and include them in this fashion:
#include "MLPP/Stat/Stat.hpp" // Including the ML++ statistics module.
int main(){
...
}
Finally, after you have concluded creating a project, compile it using g++:
g++ main.cpp /usr/local/lib/MLPP.so --std=c++17
Please note that ML++ uses the std::vector<double>
data type for emulating vectors, and the std::vector<std::vector<double>>
data type for emulating matrices.
Begin by including the respective header file of your choice.
#include "MLPP/LinReg/LinReg.hpp"
Next, instantiate an object of the class. Don't forget to pass the input set and output set as parameters.
LinReg model(inputSet, outputSet);
Afterwards, call the optimizer that you would like to use. For iterative optimizers such as gradient descent, include the learning rate, epoch number, and whether or not to utilize the UI panel.
model.gradientDescent(0.001, 1000, 0);
Great, you are now ready to test! To test a singular testing instance, utilize the following function:
model.modelTest(testSetInstance);
This will return the model's singular prediction for that example.
To test an entire test set, use the following function:
model.modelSetTest(testSet);
The result will be the model's predictions for the entire dataset.
*Only available for linear regression
ML++, like most frameworks, is dynamic, and constantly changing. This is especially important in the world of ML, as new algorithms and techniques are being developed day by day. Here are a couple of things currently being developed for ML++:
- Convolutional Neural Networks
<p>
- Kernels for SVMs
</p>
<p>
- Support Vector Regression
</p>
Various different materials helped me along the way of creating ML++, and I would like to give credit to several of them here. This article by TutorialsPoint was a big help when trying to implement the determinant of a matrix, and this article by GeeksForGeeks was very helpful when trying to take the adjoint and inverse of a matrix.