A library created to revitalize C++ as a machine learning front end. Per aspera ad astra.
ML++
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.
Installation
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. intmain(){
...
}
Finally, after you have concluded creating a project, compile it using g++:
g++ main.cpp /usr/local/lib/MLPP.so --std=c++17
Usage
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.
Contents of the Library
Regression
Linear Regression
Logistic Regression
Softmax Regression
Exponential Regression
Probit Regression
CLogLog Regression
Tanh Regression
Deep, Dynamically Sized Neural Networks
Possible Activation Functions
Linear
Sigmoid
Softmax
Swish
Mish
SinC
Softplus
Softsign
CLogLog
Logit
Gaussian CDF
RELU
GELU
Sign
Unit Step
Sinh
Cosh
Tanh
Csch
Sech
Coth
Arsinh
Arcosh
Artanh
Arcsch
Arsech
Arcoth
Possible Optimization Algorithms
Batch Gradient Descent
Mini-Batch Gradient Descent
Stochastic Gradient Descent
Gradient Descent with Momentum
Nesterov Accelerated Gradient
Adagrad Optimizer
Adadelta Optimizer
Adam Optimizer
Adamax Optimizer
Nadam Optimizer
AMSGrad Optimizer
2nd Order Newton-Raphson Optimizer*
Normal Equation*
*Only available for linear regression
Possible Loss Functions
MSE
RMSE
MAE
MBE
Log Loss
Cross Entropy
Hinge Loss
Possible Regularization Methods
Lasso
Ridge
ElasticNet
Possible Weight Initialization Methods
Uniform
Xavier Normal
Xavier Uniform
He Normal
He Uniform
LeCun Normal
LeCun Uniform
Possible Learning Rate Schedulers
Time Based
Epoch Based
Step Based
Exponential
Prebuilt Neural Networks
Multilayer Peceptron
Autoencoder
Softmax Network
Generative Modeling
Tabular Generative Adversarial Networks
Natural Language Processing
Word2Vec (Continous Bag of Words, Skip-Gram)
Stemming
Bag of Words
TFIDF
Tokenization
Auxiliary Text Processing Functions
Computer Vision
The Convolution Operation
Max, Min, Average Pooling
Global Max, Min, Average Pooling
Prebuilt Feature Detectors
Horizontal/Vertical Prewitt Filter
Horizontal/Vertical Sobel Filter
Horizontal/Vertical Scharr Filter
Horizontal/Vertical Roberts Filter
Gaussian Filter
Harris Corner Detector
Principal Component Analysis
Naive Bayes Classifiers
Multinomial Naive Bayes
Bernoulli Naive Bayes
Gaussian Naive Bayes
Support Vector Classification
Primal Formulation (Hinge Loss Objective)
Dual Formulation (Via Lagrangian Multipliers)
K-Means
k-Nearest Neighbors
Outlier Finder (Using z-scores)
Matrix Decompositions
SVD Decomposition
Cholesky Decomposition
Positive Definiteness Checker
QR Decomposition
Numerical Analysis
Numerical Diffrentiation
Univariate Functions
Multivariate Functions
Jacobian Vector Calculator
Hessian Matrix Calculator
Function approximator
Constant Approximation
Linear Approximation
Quadratic Approximation
Cubic Approximation
Diffrential Equations Solvers
Euler's Method
Growth Method
Mathematical Transforms
Discrete Cosine Transform
Linear Algebra Module
Statistics Module
Data Processing Module
Setting and Printing Datasets
Feature Scaling
Mean Normalization
One Hot Representation
Reverse One Hot Representation
Supported Color Space Conversions
RGB to Grayscale
RGB to HSV
RGB to YCbCr
RGB to XYZ
XYZ to RGB
Utilities
TP, FP, TN, FN function
Precision
Recall
Accuracy
F1 score
What's in the Works?
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
- Kernels for SVMs
- Support Vector Regression
Citations
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.