performance: Predictor performance calculation

View source: R/MPMutils.R

performanceR Documentation

Predictor performance calculation

Description

Compute sensitivity, speciticity, precision, F1 score, and accuracy for a set of predictions.

Usage

performance(obs = NULL, pred = NULL, C = NULL, y = "0,1", ...)

Arguments

obs

A vector of observed values.

pred

A vector of predicted values.

C

2x2 contingency table (alternative to obs and pred). If obs and pred are given, the contingency table is automatically computed. The contingency table has the observed values as rows and the predicted ones as columns. By default, true negatives are located at position [1, 1], while true positives at [2, 2] (see below).

y

Contingenty table orientation. If y = "0,1" (default), true negatives are located at position [1, 1], while true positives at position [2, 2]. If y = "1,0", these positions are inverted.

...

Currently ignored.

Value

A list of 6 objects:

  1. "ctable", 2x2 contingency table of predicted vs. observed values;

  2. "sensitivity", Se = TP/(TP + FN);

  3. "specificity", Sp = TN/(TN + FP);

  4. "precision", PPV = TP/(TP + FP), also called "positive predictive value";

  5. "NPV", NPV = TN/(TN + FN), "negative predictive value";

  6. "F1", F1 = 2*Se*PPV/(Se + PPV);

  7. "accuracy", (TP + TN)/(TP + TN + FP + FN).

Author(s)

Fernando Palluzzi fernando.palluzzi@gmail.com

See Also

us.predict

Examples


# RBM performance
p <- predict(mpm.rbm$fit, dichotomize(mpm.us[2:15], asFactor = TRUE),
             type = "response")
y.hat <- ifelse(p > 0.5, 1, 0)
rbm <- performance(mpm.us$y, y.hat)

# Compare RBM and RFC F1 scores
print(rbm$F1)
print(mpm.rfc$performance$F1)


Morphonodepredictivemodel/morphonode documentation built on Feb. 15, 2023, 4:51 a.m.