#' @title A light weight implementation of a linear combination model.
#'
#' @description
#'
#' A model class for linear model.
#'
#' @export
#'
#' @examples
#'
#' lm_mod <- lm(speed ~ dist, cars)
#' my_form <- speed ~ dist
#' Mod <- ModelLinear$new(lm_mod$coefficients, formula = my_form)
#' Mod
#' head(Mod$predict(cars))
ModelLinear <- R6::R6Class(
classname = "ModelLinear",
inherit = ModelBase,
public = list(
#' @description
#'
#' Initialisation function
#'
#' @param params a `data.frame` object.
#' @param formula a `formula` object.
#' @param preprocessing_fn a pre-processing function that gets applied to the
#' data given to the `predict` method before making the prediction.
#'
#' @return NULL
initialize = function(params, formula, preprocessing_fn = NULL) {
super$initialize(params = params,
formula = formula,
type = "linear",
preprocessing_fn = preprocessing_fn)
invisible(NULL)
},
#' @description
#'
#' A predict method.
#'
#' @param newdata a data.frame.
#'
#' @return a numeric vector.
predict = function(newdata) {
private$.compute_linear_combination(newdata)
}
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.