Learn R Programming

MachineShop (version 3.3.0)

performance: Model Performance Metrics

Description

Compute measures of model performance.

Usage

performance(x, ...)

# S3 method for BinomialVariate performance( x, y, weights = NULL, metrics = MachineShop::settings("metrics.numeric"), na.rm = TRUE, ... )

# S3 method for factor performance( x, y, weights = NULL, metrics = MachineShop::settings("metrics.factor"), cutoff = MachineShop::settings("cutoff"), na.rm = TRUE, ... )

# S3 method for matrix performance( x, y, weights = NULL, metrics = MachineShop::settings("metrics.matrix"), na.rm = TRUE, ... )

# S3 method for numeric performance( x, y, weights = NULL, metrics = MachineShop::settings("metrics.numeric"), na.rm = TRUE, ... )

# S3 method for Surv performance( x, y, weights = NULL, metrics = MachineShop::settings("metrics.Surv"), cutoff = MachineShop::settings("cutoff"), na.rm = TRUE, ... )

# S3 method for ConfusionList performance(x, ...)

# S3 method for ConfusionMatrix performance(x, metrics = MachineShop::settings("metrics.ConfusionMatrix"), ...)

# S3 method for MLModel performance(x, ...)

# S3 method for Resample performance(x, ...)

# S3 method for TrainingStep performance(x, ...)

Arguments

x

observed responses; or confusion, trained model fit, resample, or rfe result.

...

arguments passed from the Resample method to the response type-specific methods or from the method for ConfusionList to ConfusionMatrix. Elliptical arguments in the response type-specific methods are passed to metrics supplied as a single MLMetric function and are ignored otherwise.

y

predicted responses if not contained in x.

weights

numeric vector of non-negative case weights for the observed x responses [default: equal weights].

metrics

metric function, function name, or vector of these with which to calculate performance.

na.rm

logical indicating whether to remove observed or predicted responses that are NA when calculating metrics.

cutoff

numeric (0, 1) threshold above which binary factor probabilities are classified as events and below which survival probabilities are classified.

See Also

plot, summary

Examples

Run this code
# NOT RUN {
## Requires prior installation of suggested package gbm to run

res <- resample(Species ~ ., data = iris, model = GBMModel)
(perf <- performance(res))
summary(perf)
plot(perf)

## Survival response example
library(survival)

gbm_fit <- fit(Surv(time, status) ~ ., data = veteran, model = GBMModel)

obs <- response(gbm_fit, newdata = veteran)
pred <- predict(gbm_fit, newdata = veteran)
performance(obs, pred)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab