R/predict.PDEbayes.R

Defines functions predict.PDEbayes

Documented in predict.PDEbayes

predict.PDEbayes= function(object, newdata, type = c("class", "response","prob"), ...) {
  if (missing(newdata)) {
    stop("Please supply `newdata` to predict()", call. = FALSE)
  }
  type <- match.arg(type)

  res=Predict_naiveBayes(Data=newdata,Model=object,...)
  
  switch (type,
          prob = {
            out=res$Posteriors
          },
          class={
            out=factor(res$Cls, levels = sort(unique(res$Cls)))
          },
          response={
            out=res$Cls
          }
  )
  return(out)
}

Try the PDEnaiveBayes package in your browser

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

PDEnaiveBayes documentation built on Nov. 17, 2025, 5:07 p.m.