Learn R Programming

h2o (version 2.8.4.4)

h2o.hitRatio: Compute Hit Ratio from H2O Classification Predictions

Description

Compute the hit ratios from a prediction dataset and a column of actual (reference) responses in H2O. The hit ratio is the percentage of instances where the actual class of an observation is in the top k classes predicted by the model, where k is specified by the user. Note that the hit ratio can only be calculated for classification models.

Usage

h2o.hitRatio(prediction, reference, k = 10, seed = 0)

Arguments

prediction
An H2OParsedData object that represents the predicted response values. Must have the same number of rows as reference.
reference
An H2OParsedData object that represents the actual response values. (Must be a single column).
k
A positive integer indicating the maximum number of labels to use for hit ratio computation. Cannot be larger than the size of the response domain.
seed
(Optional) Random number seed for breaking ties between equal probabilities.

Value

  • Returns a numeric vector with the hit ratio for every level in the reference domain.

See Also

H2OParsedData

Examples

Run this code
library(h2o)
localH2O = h2o.init()
irisPath = system.file("extdata", "iris.csv", package = "h2o")
iris.hex = h2o.importFile(localH2O, path = irisPath)
iris.gbm = h2o.gbm(x = 1:4, y = 5, data = iris.hex)
iris.pred = h2o.predict(iris.gbm)
h2o.hitRatio(iris.pred, iris.hex[,5], k = 3)

Run the code above in your browser using DataLab