LASSO Regularization in C++.
This repository contains a source code of LASSO () regularization for simple polynomial regression implemented from scratch in C++17.
The solution was tested on the simple task of the sine function approximation by polynomials, but it could work for any regression tasks (i hope it does).
In a nutshell, LASSO regularization iteratively updates regression weights using coordinate descent algorithm taking into account the penalty for absolute values of weights. So, it minimizes the above cost function:
Optimized regression weights can be obtained such way:
#include "DataSet.h"
#include "LassoRegression.h"
int main() {
DataSet dataSet;
LassoRegression *lasso = new LassoRegression(dataSet.sample, dataSet.target);
double tolerance = 0.001, alpha = 0.01;
double *weights = lasso->cyclicalCoordinateDescent(tolerance, alpha);
}
For your custom regression tasks you only need to change the implementation of DataSet class that encapsulates a training set.