classification_result: Create a 'classification_result' instance

View source: R/mvpa_result.R

classification_resultR Documentation

Create a classification_result instance

Description

Constructs a classification result object based on the observed and predicted values, as well as other optional parameters.

Usage

classification_result(
  observed,
  predicted,
  probs,
  testind = NULL,
  test_design = NULL,
  predictor = NULL
)

Arguments

observed

A vector of observed or true values.

predicted

A vector of predicted values.

probs

A matrix of predicted probabilities, with one column per level.

testind

The row indices of the test observations (optional).

test_design

An optional design for the test data.

predictor

An optional predictor object.

Value

A classification result object, which can be one of: regression_result, binary_classification_result, or multiway_classification_result.

See Also

Other classification_result: binary_classification_result(), multiway_classification_result(), regression_result()

Examples

# A vector of observed values
yobs <- factor(rep(letters[1:4], 5))

# Predicted probabilities
probs <- data.frame(a = runif(1:20), b = runif(1:20), c = runif(1:20), d = runif(1:20))
probs <- sweep(probs, 1, rowSums(probs), "/")

# Get the max probability per row and use this to determine the predicted class
maxcol <- max.col(probs)
predicted <- levels(yobs)[maxcol]

# Construct a classification result
cres <- classification_result(yobs, predicted, probs)

# Compute default performance measures (Accuracy, AUC)
performance(cres)

bbuchsbaum/rMVPA documentation built on April 28, 2024, 6:30 a.m.