View source: R/evaluator-lib-utils.R
tp | R Documentation |
These functions calculate the tp()
(number of true positives)
of a measurement system compared to the reference results (the "truth").
tp(data, ...)
## S3 method for class 'data.frame'
tp(
data,
truth,
estimate,
estimator = NULL,
na_rm = FALSE,
case_weights = NULL,
event_level = "first",
...
)
tp_vec(
truth,
estimate,
estimator = NULL,
na_rm = FALSE,
case_weights = NULL,
event_level = "first",
...
)
data |
Either a |
... |
Not currently used. |
truth |
The column identifier for the true class results
(that is a |
estimate |
The column identifier for the predicted class
results (that is also |
estimator |
One of: |
na_rm |
A |
case_weights |
The optional column identifier for case weights.
This should be an unquoted column name that evaluates to a numeric column
in |
event_level |
A single string. Either |
A tibble
with columns .metric
, .estimator
, and
.estimate
with 1 row of values.
For grouped data frames, the number of rows returned will be the same as the number of groups.
For tp_vec()
, a single numeric
value (or NA
).
# Two class example data
two_class_example <- data.frame(
truth = as.factor(sample(c("Class1", "Class2"), 100, replace = TRUE)),
predicted = as.factor(sample(c("Class1", "Class2"), 100, replace = TRUE))
)
# Compute number of true positives
tp(two_class_example, truth = truth, estimate = predicted)
tp_vec(two_class_example$truth, two_class_example$predicted)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.