merge.rFerns.Rd 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. % Generated by roxygen2: do not edit by hand
  2. % Please edit documentation in R/tools.R
  3. \name{merge.rFerns}
  4. \alias{merge.rFerns}
  5. \title{Merge two random ferns models}
  6. \usage{
  7. \method{merge}{rFerns}(x, y, dropModel = FALSE,
  8. ignoreObjectConsistency = FALSE, trueY = NULL, ...)
  9. }
  10. \arguments{
  11. \item{x}{Object of a class \code{rFerns}; a first model to be merged.}
  12. \item{y}{Object of a class \code{rFerns}; a second model to be merged.
  13. Can also be \code{NULL}, \code{x} is immediately returned in that case.
  14. Has to have be built on the same kind of training data as \code{x}, with the same depth.}
  15. \item{dropModel}{If \code{TRUE}, model structure will be dropped to save size.
  16. This disallows prediction using the merged model, but retains importance and OOB approximations.}
  17. \item{ignoreObjectConsistency}{If \code{TRUE}, merge will be done even if both models were built on a different sets of objects.
  18. This drops OOB approximations.}
  19. \item{trueY}{Copy of the training decision, used to re-construct OOB error and confusion matrix.
  20. Can be omitted, OOB error and confusion matrix will disappear in that case; ignored when \code{ignoreObjectConsistency} is \code{TRUE}.}
  21. \item{...}{Ignored, for S3 gerneric/method consistency.}
  22. }
  23. \value{
  24. An object of class \code{rFerns}, which is a list with the following components:
  25. \item{model}{The merged model in case both \code{x} and \code{y} had model structures included and \code{dropModel} was \code{FALSE}.
  26. Otherwise \code{NULL}.}
  27. \item{oobErr}{OOB approximation of accuracy, if can be computed.
  28. Namely, when \code{oobScores} could be and \code{trueY} is provided.}
  29. \item{importance}{The merged importance scores in case both \code{x} and \code{y} had importance calculated.
  30. Shadow importance appears only if both models had it enabled.}
  31. \item{oobScores}{OOB scores, if can be computed; namely if both models had it calculated and \code{ignoreObjectConsistency} was not used.}
  32. \item{oobPreds}{A vector of OOB predictions of class for each object in training set, if can be computed.}
  33. \item{oobConfusionMatrix}{OOB confusion matrix, if can be computed.
  34. Namely, when \code{oobScores} could be and \code{trueY} is provided.}
  35. \item{timeTaken}{Time used to train the model, calculated as a sum of training times of \code{x} and \code{y}.}
  36. \item{parameters}{Numerical vector of three elements: \code{classes}, \code{depth} and \code{ferns}.}
  37. \item{classLabels}{Copy of \code{levels(Y)} after purging unused levels.}
  38. \item{isStruct}{Copy of the train set structure.}
  39. \item{merged}{Set to \code{TRUE} to mark that merging was done.}
  40. }
  41. \description{
  42. This function combines two compatible (same decision, same training data structure and same depth) models into a single ensemble.
  43. It can be used to distribute model training, perform it on batches of data, save checkouts or precisely investigate its course.
  44. }
  45. \note{
  46. In case of different training object sets were used to build the merged models, merged importance is calculated but mileage may vary; for substantially different sets it may become biased.
  47. Your have been warned.
  48. Shadow importance is only merged when both models have shadow importance and the same \code{consistentSeed} value; otherwise shadow importance would be biased down.
  49. The order of objects in \code{x} and \code{y} is not important; the only exception is merging with \code{NULL}, in which case \code{x} must be an \code{rFerns} object for R to use proper merge method.
  50. }
  51. \examples{
  52. set.seed(77)
  53. #Fetch Iris data
  54. data(iris)
  55. #Build models
  56. rFerns(Species~.,data=iris)->modelA
  57. rFerns(Species~.,data=iris)->modelB
  58. modelAB<-merge(modelA,modelB)
  59. print(modelA)
  60. print(modelAB)
  61. }