View source: R/linear_regression_train.R
| linear_regression_train | R Documentation |
Train a linear regression model.
linear_regression_train(
training,
lambda = 0,
training_responses = NA,
verbose = getOption("mlpack.verbose", FALSE)
)
training |
Matrix containing training set X (regressors) (numeric matrix). |
lambda |
Tikhonov regularization for ridge regression. If 0, the method reduces to linear regression. Default value "0" (numeric). |
training_responses |
Optional vector containing y (responses). If not given, the responses are assumed to be the last row of the input file (numeric row). |
verbose |
Display informational messages and the full list of parameters and timers at the end of execution. Default value "getOption("mlpack.verbose", FALSE)" (logical). |
An implementation of simple linear regression and simple ridge regression using ordinary least squares. This solves the problem
y = X * b + e
A list with several components defining the class attributes:
output_model |
Output LinearRegression model (LinearRegression). |
mlpack developers
#
# #' # \dontrun{
# suppressMessages(library(mlpack)) # in case 'mlpack' is not yet loaded
# X <-
# as.matrix(read.csv("https://datasets.mlpack.org/admission_predict.csv",
# header=FALSE))
# y <-
# as.matrix(read.csv("https://datasets.mlpack.org/admission_predict.responses
# .csv", header=FALSE))
# pp <- preprocess_split(input=X, input_label=as.matrix(1:nrow(X)),
# test_ratio=0.2)
# X_train <- pp[["training"]]
# X_test <- pp[["test"]]
# # labels are indices to operate on both factors or numeric data
# y_train <- y[as.integer(pp[["training_labels"]]), 1]
# y_test <- y[as.integer(pp[["test_labels"]]), 1]
#
# model <- linear_regression_train(training=X_train,
# training_responses=y_train)
# }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.