calculate.error: Error calculation.

View source: R/variable_selection.R

calculate.errorR Documentation

Error calculation.

Description

Calculates errors by comparing predictions with the true values. For regression and probability mode, it will give root mean squared error (rmse) and pseudo R-squared (rsq). For classification mode, overall accuracy (acc), overall error (err), Matthews correlation coefficient (mcc), sensitivity (sens) and specificity (spec) are returned.

Usage

calculate.error(rf, true, test.set = NULL)

Arguments

rf

Object of class ranger

true

vector with true value for each sample

test.set

matrix or data.frame of predictor variables for test set with variables in columns and samples in rows (Note: missing values are not allowed)

Value

numeric vector with two elements for regression and probability estimation (rmse, rsq) and five elements for classification (acc, err, mcc, sens, spec)

Examples

# simulate toy data set
data = simulation.data.cor(no.samples = 100, group.size = rep(10, 6), no.var.total = 200)

# random forest
rf = wrapper.rf(x = data[, -1], y = data[, 1],
                type = "regression")

# error
calculate.error(rf = rf, true = data[, 1])

silkeszy/Pomona documentation built on March 31, 2022, 11:13 p.m.