linear_regression_train: Simple Linear Regression

View source: R/linear_regression_train.R

linear_regression_trainR Documentation

Simple Linear Regression

Description

Train a linear regression model.

Usage

linear_regression_train(
  training,
  lambda = 0,
  training_responses = NA,
  verbose = getOption("mlpack.verbose", FALSE)
)

Arguments

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).

Details

An implementation of simple linear regression and simple ridge regression using ordinary least squares. This solves the problem

y = X * b + e

Value

A list with several components defining the class attributes:

output_model

Output LinearRegression model (LinearRegression).

Author(s)

mlpack developers

Examples

# 
# #' # \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)
#   }

mlpack documentation built on July 23, 2026, 1:08 a.m.