rFerns (version 3.0.0)

merge.rFerns: Merge two random ferns models

Description

This function combines two compatible (same decision, same training data structure and same depth) models into a single ensemble. It can be used to distribute model training, perform it on batches of data, save checkouts or precisely investigate its course.

Usage

# S3 method for rFerns
merge(x, y, dropModel = FALSE,
  ignoreObjectConsistency = FALSE, trueY = NULL, ...)

Arguments

x

Object of a class rFerns; a first model to be merged.

y

Object of a class rFerns; a second model to be merged. Can also be NULL, x is immediately returned in that case. Has to have be built on the same kind of training data as x, with the same depth.

dropModel

If TRUE, model structure will be dropped to save size. This disallows prediction using the merged model, but retains importance and OOB approximations.

ignoreObjectConsistency

If TRUE, merge will be done even if both models were built on a different sets of objects. This drops OOB approximations.

trueY

Copy of the training decision, used to re-construct OOB error and confusion matrix. Can be omitted, OOB error and confusion matrix will disappear in that case; ignored when ignoreObjectConsistency is TRUE.

...

Ignored, for S3 gerneric/method consistency.

Value

An object of class rFerns, which is a list with the following components:

model

The merged model in case both x and y had model structures included and dropModel was FALSE. Otherwise NULL.

oobErr

OOB approximation of accuracy, if can be computed. Namely, when oobScores could be and trueY is provided.

importance

The merged importance scores in case both x and y had importance calculated. Shadow importance appears only if both models had it enabled.

oobScores

OOB scores, if can be computed; namely if both models had it calculated and ignoreObjectConsistency was not used.

oobPreds

A vector of OOB predictions of class for each object in training set, if can be computed.

oobConfusionMatrix

OOB confusion matrix, if can be computed. Namely, when oobScores could be and trueY is provided.

timeTaken

Time used to train the model, calculated as a sum of training times of x and y.

parameters

Numerical vector of three elements: classes, depth and ferns.

classLabels

Copy of levels(Y) after purging unused levels.

isStruct

Copy of the train set structure.

merged

Set to TRUE to mark that merging was done.

Examples

Run this code
# NOT RUN {
set.seed(77)
#Fetch Iris data
data(iris)
#Build models
rFerns(Species~.,data=iris)->modelA
rFerns(Species~.,data=iris)->modelB
modelAB<-merge(modelA,modelB)
print(modelA)
print(modelAB)
# }

Run the code above in your browser using DataCamp Workspace