R/dal_predictor.R

Defines functions action.predictor fit.predictor predictor

Documented in predictor

#'@title DAL Predict
#'@description Ancestor class for regression and classification
#'It provides basis for fit and predict methods.
#'Besides, action method proxies to predict.
#'
#' An example of learner is a decision tree (cla_dtree)
#'@return a predictor object
#'@examples
#'#See ?cla_dtree for a classification example using a decision tree
#'@export
predictor <- function() {
  obj <- dal_learner()
  class(obj) <- append("predictor", class(obj))
  return(obj)
}

#'@export
fit.predictor <- function(obj, data, ...) {
  obj$x <- setdiff(colnames(data), obj$attribute)
  return(obj)
}

#'@export
action.predictor <- function(obj, ...) {
  thiscall <- match.call(expand.dots = TRUE)
  thiscall[[1]] <- as.name("predict")
  result <- eval.parent(thiscall)
  return(result)
}

Try the daltoolbox package in your browser

Any scripts or data that you put into this service are public.

daltoolbox documentation built on May 29, 2024, 1:57 a.m.