mlpack
|
#include <mlpack/prereqs.hpp>
#include <mlpack/core/util/io.hpp>
#include <mlpack/core/util/mlpack_main.hpp>
#include "linear_regression.hpp"
Functions | |
BINDING_NAME ("Simple Linear Regression and Prediction") | |
BINDING_SHORT_DESC ("An implementation of simple linear regression and ridge regression using " "ordinary least squares. Given a dataset and responses, a model can be " "trained and saved for later use, or a pre-trained model can be used to " "output regression predictions for a test set.") | |
BINDING_LONG_DESC ("An implementation of simple linear regression and simple ridge regression " "using ordinary least squares. This solves the problem" "\" " y = X * b + e" "\" "where X (specified by "+PRINT_PARAM_STRING("training")+") and y " "(specified either as the last column of the input matrix "+PRINT_PARAM_STRING("training")+" or via the "+PRINT_PARAM_STRING("training_responses")+" parameter) are known and b is" " the desired variable. If the covariance matrix (X'X) is not invertible, " "or if the solution is overdetermined, then specify a Tikhonov " "regularization constant (with "+PRINT_PARAM_STRING("lambda")+") " "greater than 0, which will regularize the covariance matrix to make it " "invertible. The calculated b may be saved with the "+PRINT_PARAM_STRING("output_predictions")+" output parameter." "\" "Optionally, the calculated value of b is used to predict the responses for" " another matrix X' (specified by the "+PRINT_PARAM_STRING("test")+" " "parameter):" "\" " y' = X' * b" "\" "and the predicted responses y' may be saved with the "+PRINT_PARAM_STRING("output_predictions")+" output parameter. This type " "of regression is related to least-angle regression, which mlpack " "implements as the 'lars' program.") | |
BINDING_EXAMPLE ("For example, to run a linear regression on the dataset "+PRINT_DATASET("X")+" with responses "+PRINT_DATASET("y")+", saving " "the trained model to "+PRINT_MODEL("lr_model")+", the following " "command could be used:" "\"+PRINT_CALL("linear_regression", "training", "X", "training_responses", "y", "output_model", "lr_model")+"\" "Then, to use "+PRINT_MODEL("lr_model")+" to predict responses for a " "test set "+PRINT_DATASET("X_test")+", saving the predictions to "+PRINT_DATASET("X_test_responses")+", the following command could be " "used:" "\"+PRINT_CALL("linear_regression", "input_model", "lr_model", "test", "X_test", "output_predictions", "X_test_responses")) | |
BINDING_SEE_ALSO ("Linear/ridge regression tutorial", "@doxygen/lrtutorial.html") | |
BINDING_SEE_ALSO ("@lars", "#lars") | |
BINDING_SEE_ALSO ("Linear regression on Wikipedia", "https://en.wikipedia.org/wiki/Linear_regression") | |
BINDING_SEE_ALSO ("mlpack::regression::LinearRegression C++ class " "documentation", "@doxygen/classmlpack_1_1regression_1_1LinearRegression.html") | |
PARAM_MATRIX_IN ("training", "Matrix containing training set X (regressors).", "t") | |
PARAM_ROW_IN ("training_responses", "Optional vector containing y " "(responses). If not given, the responses are assumed to be the last row " "of the input file.", "r") | |
PARAM_MODEL_IN (LinearRegression, "input_model", "Existing LinearRegression " "model to use.", "m") | |
PARAM_MODEL_OUT (LinearRegression, "output_model", "Output LinearRegression " "model.", "M") | |
PARAM_MATRIX_IN ("test", "Matrix containing X' (test regressors).", "T") | |
PARAM_ROW_OUT ("output_predictions", "If --test_file is specified, this " "matrix is where the predicted responses will be saved.", "o") | |
PARAM_DOUBLE_IN ("lambda", "Tikhonov regularization for ridge regression. If 0," " the method reduces to linear regression.", "l", 0.0) | |
Main function for least-squares linear regression.
mlpack is free software; you may redistribute it and/or modify it under the terms of the 3-clause BSD license. You should have received a copy of the 3-clause BSD license along with mlpack. If not, see http://www.opensource.org/licenses/BSD-3-Clause for more information.