Learn R Programming

MetricsWeighted (version 0.5.4)

prop_within: Proportion Within

Description

Calculates weighted proportion of predictions that are within a given tolerance around the actual values. The larger the value, the better.

Usage

prop_within(actual, predicted, w = NULL, tol = 1, ...)

Value

A numeric vector of length one.

Arguments

actual

Observed values.

predicted

Predicted values.

w

Optional case weights.

tol

Predictions in the closed interval from actual - tol to actual + tol count as within.

...

Further arguments passed to weighted_mean.

Examples

Run this code
prop_within(1:10, c(1:9, 12))
prop_within(1:10, c(1:9, 12), w = 1:10)
data <- data.frame(act = 1:10, pred = c(1:9, 12), w = 1:10)
multi <- multi_metric(fun = prop_within, tol = 0:3)
performance(data, actual = "act", predicted = "pred", w = "w",
  metrics = multi, key = "Proportion within")

Run the code above in your browser using DataLab