Learn R Programming

rcppmlpackexamples (version 0.0.1)

randomForest: Run a Random Forest classificatio

Description

Run a Random Forest Classifier

Usage

randomForest(dataset, labels, pct = 0.3, nclasses = 7L, ntrees = 10L)

Value

A list object

Arguments

dataset

A matrix of explanatory variables, i.e. “features”

labels

A vector of the dependent variable as integer values, i.e. “labels”

pct

A numeric value for the percentage of data to be retained for the test set

nclasses

An integer value for the number of a distinct values in labels

ntrees

An integer value for the number of trees

Details

This function performs a Random Forest classification on a subset of the standard ‘covertype’ data set

See Also

covertype_small

Examples

Run this code
data(covertype_small)                         # see help(covertype_small)
res <- randomForest(covertype_small[-55,],    # features (already transposed)
                    covertype_small[55,],     # labels now in [0, 6] range
                    0.3)                      # percentage used for testing
str(res)  # accuracy varies as method is randomized but not seed set here

Run the code above in your browser using DataLab