predict.rFerns.Rd 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. % Generated by roxygen2: do not edit by hand
  2. % Please edit documentation in R/ferns.R
  3. \name{predict.rFerns}
  4. \alias{predict.rFerns}
  5. \title{Prediction with random ferns model}
  6. \usage{
  7. \method{predict}{rFerns}(object, x, scores = FALSE, ...)
  8. }
  9. \arguments{
  10. \item{object}{Object of a class \code{rFerns}; a model that will be used for prediction.}
  11. \item{x}{Data frame containing attributes; must have corresponding names to training set (although order is not important) and do not introduce new factor levels.
  12. If this argument is not given, OOB predictions on the training set will be returned.}
  13. \item{scores}{If \code{TRUE}, the result will contain score matrix instead of simple predictions.}
  14. \item{...}{Additional parameters.}
  15. }
  16. \value{
  17. Predictions.
  18. If \code{scores} is \code{TRUE}, a factor vector (for many-class classification) or a logical data.frame (for multi-class classification) with predictions, else a data.frame with class' scores.
  19. }
  20. \description{
  21. This function predicts classes of new objects with given \code{rFerns} object.
  22. }
  23. \examples{
  24. set.seed(77)
  25. #Fetch Iris data
  26. data(iris)
  27. #Split into tRain and tEst set
  28. iris[c(TRUE,FALSE),]->irisR
  29. iris[c(FALSE,TRUE),]->irisE
  30. #Build model
  31. rFerns(Species~.,data=irisR)->model
  32. print(model)
  33. #Test
  34. predict(model,irisE)->p
  35. print(table(
  36. Predictions=p,
  37. True=irisE[["Species"]]))
  38. err<-mean(p!=irisE[["Species"]])
  39. print(paste("Test error",err,sep=" "))
  40. #Show first OOB scores
  41. head(predict(model,scores=TRUE))
  42. }