randomForest (version 4.3-2)

margin: Margins of randomForest Classifier

Description

Compute or plot the margin of predictions from a randomForest classifier.

Usage

margin(rf, observed)
## S3 method for class 'margin':
plot(x, sort=TRUE, ...)

Arguments

rf
an object of class randomForest, whose type is not regression.
observed
the response variable (a factor) used to train rf.
x
an object of class margin, as returned by the function margin.
sort
Should the data be sorted by their class labels?
...
other graphical parameters to be passed to plot.default.

Value

  • For margin, the margin of observations from the randomForest classifier. The margin of a data point is defined as the proportion of votes for the correct class minus maximum proportion of votes for the other classes. Thus under majority votes, positive margin means correct classification, and vice versa.

See Also

randomForest

Examples

Run this code
set.seed(1)
data(iris)
iris.rf <- randomForest(Species ~ ., iris, keep.forest=FALSE)
plot(margin(iris.rf, iris$Species))

Run the code above in your browser using DataCamp Workspace