Learn R Programming

h2o (version 2.8.4.4)

h2o.performance: Performance Measures

Description

Evaluate the predictive performance of a model via various measures.

Usage

h2o.performance(data, reference, measure = "accuracy", thresholds, gains = TRUE, ...)

Arguments

data
An H2OParsedData object containing the predicted outcome scores. Must be a single column with the same number of rows as reference.
reference
An H2OParsedData object containing the actual outcomes for comparison. Must be a single binary column with all entries in {0,1}.
measure
A character string indicating the performance measure to optimize. Must be one of the following:
  • F1: F1 score, equal to$2*(Precision*Recall)/{Precision + Recall}$
accuracy: Accuracy of model, esti

Value

  • An object of class H2OPerfModel with slots cutoffs, measure, perf (the performance measure selected), roc (data frame used to plot ROC) and model, where the last is a list of the following components:
  • aucArea under the curve.
  • giniGini coefficient.
  • best_cutoffThreshold value that optimizes the performance measure.
  • F1F1 score at best cutoff.
  • accuracyAccuracy value at best cutoff.
  • precisionPrecision value at best cutoff.
  • recallRecall value at best cutoff.
  • specificitySpecificity value at best cutoff.
  • max_per_class_errMaximum per class error at best cutoff.
  • confusionConfusion matrix at best cutoff.

item

  • thresholds
  • gains
  • ...

Examples

Run this code
library(h2o)
localH2O = h2o.init()

# Run GBM classification on prostate.csv
prosPath = system.file("extdata", "prostate.csv", package = "h2o")
prostate.hex = h2o.importFile(localH2O, path = prosPath, key = "prostate.hex")
prostate.gbm = h2o.gbm(y = 2, x = 3:9, data = prostate.hex)

# Calculate performance measures at threshold that maximizes precision
prostate.pred = h2o.predict(prostate.gbm)
head(prostate.pred)
h2o.performance(prostate.pred[,3], prostate.hex$CAPSULE, measure = "precision")

Run the code above in your browser using DataLab