rFerns {rFerns} | R Documentation |
Classification with random ferns
Description
This function builds a random ferns model on the given training data.
Usage
rFerns(x, ...)
## S3 method for class 'formula'
rFerns(formula, data = .GlobalEnv, ...)
## S3 method for class 'matrix'
rFerns(x, y, ...)
## Default S3 method:
rFerns(
x,
y,
depth = 5,
ferns = 1000,
importance = "none",
saveForest = TRUE,
consistentSeed = NULL,
threads = 0,
...
)
Arguments
x |
Data frame containing attributes; must have unique names and contain only numeric, integer or (ordered) factor columns.
Factors must have less than 31 levels. No |
... |
For formula and matrix methods, a place to state parameters to be passed to default method.
For the print method, arguments to be passed to |
formula |
alternatively, formula describing model to be analysed. |
data |
in which to interpret formula. |
y |
A decision vector. Must a factor of the same length as |
depth |
The depth of the ferns; must be in 1–16 range. Note that time and memory requirements scale with |
ferns |
Number of ferns to be build. |
importance |
Set to calculate attribute importance measure (VIM);
|
saveForest |
Should the model be saved? It must be |
consistentSeed |
PRNG seed used for shadow importance only.
Must be either a 2-element integer vector or |
threads |
Number or OpenMP threads to use. The default value of |
Value
An object of class rFerns
, which is a list with the following components:
model |
The built model; |
oobErr |
OOB approximation of accuracy. Ignores never-OOB-tested objects (see oobScores element). |
importance |
The importance scores or |
oobScores |
A matrix of OOB scores of each class for each object in training set.
Rows correspond to classes in the same order as in |
oobPreds |
A vector of OOB predictions of class for each object in training set. Never-OOB-tested objects (see above) have predictions equal to |
oobConfusionMatrix |
Confusion matrix build from |
timeTaken |
Time used to train the model (smaller than wall time because data preparation and model final touches are excluded; however it includes the time needed to compute importance, if it applies).
An object of |
parameters |
Numerical vector of three elements: |
classLabels |
Copy of |
consistentSeed |
Consistent seed used; only present for |
isStruct |
Copy of the train set structure, required internally by predict method. |
Note
The unused levels of the decision will be removed; on the other hand unused levels of categorical attributes will be preserved, so that they could be present in the data later predicted with the model. The levels of ordered factors in training and predicted data must be identical.
Do not use formula interface for a data with large number of attributes; the overhead from handling the formula may be significant.
References
Ozuysal M, Calonder M, Lepetit V & Fua P. (2009). Fast Keypoint Recognition using Random Ferns, IEEE Transactions on Pattern Analysis and Machine Intelligence, 32(3), 448-461.
Kursa MB (2014). rFerns: An Implementation of the Random Ferns Method for General-Purpose Machine Learning, Journal of Statistical Software, 61(10), 1-13.
Examples
set.seed(77)
#Fetch Iris data
data(iris)
#Build model
rFerns(Species~.,data=iris)
##Importance
rFerns(Species~.,data=iris,importance="shadow")->model
print(model$imp)