R/predict.mlkit.class.fit.R

Defines functions predict.mlkit.class.fit

Documented in predict.mlkit.class.fit

#' Model Predictions for Classifier Models
#'
#' @description Custom implementation for prediction using model fits obtained
#' resulting from multiclass classification models in the \code{mlkit} package.
#'
#' @method predict mlkit.class.fit
#'
#' @param object \code{mlkit.class.fit} object generated by a call to a
#' classifier method in the \code{mlkit} package that is used for prediction.
#' @param newdata optional matrix of explanatory variables to use in prediction.
#' Default is \code{NULL} in which case the in-sample predictions are returned.
#' @param ... additional arguments affecting the predictions produced.
#'
#' @return Atomic vector containing predictions based on the given model and
#' explanatory variables.
#'
#' @export
#'
predict.mlkit.class.fit = function(object, newdata=NULL, ...) {
  if (is.null(newdata)) return(object$y.hat)
  return(object$classifier(newdata))
}
Accelerytics/mlkit documentation built on Dec. 31, 2020, 9:46 a.m.