LARS
An implementation of Least Angle Regression (Stagewise/laSso), also known as LARS.
Available Predicates
- initModelNoDataNoGram/4
- initModelNoDataWithGram/7
- initModelWithDataNoGram/10
- initModelWithDataWithGram/13
- activeSet/2
- beta/2
- betaPath/3
- computeError/7
- lambdaPath/2
- matUtriCholFactor/3
- predict/6
- train/9
initModelNoDataNoGram/4
Only initialize the LARS model.
%% part of the predicate definition
initModelNoDataNoGram( +integer,
+float32, +float32, +float32).
Parameters
Name | Type | Description | Default |
---|---|---|---|
useCholesky | +integer(bool) | Whether or not to use Cholesky decomposition when solving linear system (as opposed to using the full Gram matrix). | (0)false |
lambda1 | +float | Regularization parameter for l1-norm penalty. | 0.0 |
lambda2 | +float | Regularization parameter for l2-norm penalty. | 0.0 |
tolerance | +float | Run until the maximum correlation of elements in (X^T y) is less than this. | 1e-16 |
initModelNoDataWithGram/7
Initialize LARS model, and pass in a precalculated Gram matrix but dont train the model.
%% part of the predicate definition
initModelNoDataWithGram( +integer,
+pointer(float_array), +integer, +integer,
+float32, +float32, +float32).
Parameters
Name | Type | Description | Default |
---|---|---|---|
useCholesky | +integer(bool) | Whether or not to use Cholesky decomposition when solving linear system (as opposed to using the full Gram matrix). | (0)false |
gramMatrix | +matrix | Gram matrix. | - |
lambda1 | +float | Regularization parameter for l1-norm penalty. | 0.0 |
lambda2 | +float | Regularization parameter for l2-norm penalty. | 0.0 |
tolerance | +float | Run until the maximum correlation of elements in (X^T y) is less than this. | 1e-16 |
initModelWithDataNoGram/10
Initialize LARS model, and train the model.
%% part of the predicate definition
initModelWithDataNoGram( +pointer(float_array), +integer, +integer,
+pointer(float_array), +integer,
+integer,
+integer,
+float32, +float32, +float32).
Parameters
Name | Type | Description | Default |
---|---|---|---|
data | +matrix | Input data. | - |
responses | +vector | A vector of targets. | - |
transposeData | +integer(bool) | Should be true if the input data is column-major and false otherwise. | (1)true |
useCholesky | +integer(bool) | Whether or not to use Cholesky decomposition when solving linear system (as opposed to using the full Gram matrix). | (0)false |
lambda1 | +float | Regularization parameter for l1-norm penalty. | 0.0 |
lambda2 | +float | Regularization parameter for l2-norm penalty. | 0.0 |
tolerance | +float | Run until the maximum correlation of elements in (X^T y) is less than this. | 1e-16 |
initModelWithDataWithGram/13
Initialize LARS model, pass in a precalculated Gram matrix and train the model.
%% part of the predicate definition
initModelWithDataWithGram( +pointer(float_array), +integer, +integer,
+pointer(float_array), +integer,
+integer,
+integer,
+pointer(float_array), +integer, +integer,
+float32, +float32, +float32).
Parameters
Name | Type | Description | Default |
---|---|---|---|
data | +matrix | Input data. | - |
responses | +vector | A vector of targets. | - |
transposeData | +integer(bool) | Should be true if the input data is column-major and false otherwise. | (1)true |
useCholesky | +integer(bool) | Whether or not to use Cholesky decomposition when solving linear system (as opposed to using the full Gram matrix). | (0)false |
gramMatrix | +matrix | Gram matrix. | - |
lambda1 | +float | Regularization parameter for l1-norm penalty. | 0.0 |
lambda2 | +float | Regularization parameter for l2-norm penalty. | 0.0 |
tolerance | +float | Run until the maximum correlation of elements in (X^T y) is less than this. | 1e-16 |
activeSet/2
Get the set of active dimensions
%% part of the predicate definition
activeSet(-pointer(float_array), -integer).
Parameters
Name | Type | Description | Default |
---|---|---|---|
activeSet | -vector | Get the set of active dimensions | - |
beta/2
Get the solution coefficients.
%% part of the predicate definition
beta(-pointer(float_array), -integer).
Parameters
Name | Type | Description | Default |
---|---|---|---|
beta | -vector | Get the solution coefficients. | - |
betaPath/3
Get the set of coefficients after each iteration. The solution is the last element.
%% part of the predicate definition
betaPath(-pointer(float_array), -integer, -integer).
Parameters
Name | Type | Description | Default |
---|---|---|---|
betaPath | -matrix | Get the set of coefficients after each iteration. The solution is the last element. | - |
computeError/7
Compute cost error of the given data matrix using the currently-trained LARS model.
Only ||y-beta*X||2 is used to calculate cost error.
%% part of the predicate definition
computeError( +pointer(float_array), +integer, +integer,
+pointer(float_array), +integer,
+integer,
[-float32]).
Parameters
Name | Type | Description | Default |
---|---|---|---|
matX | +matrix | Column-major input data (or row-major input data if rowMajor = true). | - |
y | +vector | responses A vector of targets. | - |
rowMajor | +integer(bool) | Should be true if the data points matrix is row-major and false otherwise. | (0)false |
error | -float | The minimum cost error. | - |
lambdaPath/2
Get the set of values for lambda1 after each iteration; the solution is the last element.
%% part of the predicate definition
lambdaPath(-pointer(float_array), -integer).
Parameters
Name | Type | Description | Default |
---|---|---|---|
lambdaPath | -vector | Get the set of values for lambda1 after each iteration; the solution is the last element. | - |
matUtriCholFactor/3
Get the upper triangular cholesky factor.
%% part of the predicate definition
matUtriCholFactor(-pointer(float_array), -integer, -integer).
Parameters
Name | Type | Description | Default |
---|---|---|---|
factor | -matrix | Get the upper triangular cholesky factor. | - |
predict/6
Predict y_i for each data point in the given data matrix using the currently-trained LARS model.
%% part of the predicate definition
predict( +pointer(float_array), +integer, +integer,
-pointer(float_array), -integer,
+integer).
Parameters
Name | Type | Description | Default |
---|---|---|---|
points | +matrix | The data points to regress on. | - |
predictions | -vector | y, which will contained calculated values on completion. | - |
rowMajor | +integer(bool) | Should be true if the data points matrix is row-major and false otherwise. | (0)false |
train/9
Train the LARS model with the given data.
The input matrix (like all mlpack matrices) should be column-major – each column is an observation and each row is a dimension. However, because LARS is more efficient on a row-major matrix, this method will (internally) transpose the matrix. If this transposition is not necessary (i.e., you want to pass in a row-major matrix), pass 'false' for the transposeData parameter.
%% part of the predicate definition
train( +pointer(float_array), +integer, +integer,
+pointer(float_array), +integer,
-pointer(float_array), -integer,
+integer,
[-integer]).
Parameters
Name | Type | Description | Default |
---|---|---|---|
data | +matrix | Column-major input data (or row-major input data if rowMajor = true). | - |
responses | +vector | A vector of targets. | - |
beta | -vector | Vector to store the solution (the coefficients) in. | - |
transposeData | +integer(bool) | Set to false if the data is row-major. | (1)true |
error | -float | minimum cost error( |
Connected Links/Resources
If you want a more detailed explanation, then go to the python documentation. There is most of the time a good explanation on how the methods work and what the parameters do.
added some of the links from the python documentation