performance | R Documentation |
Applies one or more metrics to a data.frame
containing columns with
actual and predicted values as well as an optional column with case weights.
The results are returned as a data.frame
and can be used in a pipe.
performance(
data,
actual,
predicted,
w = NULL,
metrics = rmse,
key = "metric",
value = "value",
...
)
data |
A |
actual |
The column name in |
predicted |
The column name in |
w |
The optional column name in |
metrics |
Either a function or a named list of functions. Each function represents a metric and has four arguments:
If not a named list but a single function, the name of the function is guessed by
|
key |
Name of the resulting column containing the name of the metric. Defaults to "metric". |
value |
Name of the resulting column with the value of the metric. Defaults to "value". |
... |
Further arguments passed to the metric functions. E.g., if the metric
is |
Data frame with one row per metric and two columns: key
and value
.
ir <- iris
fit_num <- lm(Sepal.Length ~ ., data = ir)
ir$fitted <- fit_num$fitted
performance(ir, "Sepal.Length", "fitted")
performance(ir, "Sepal.Length", "fitted", metrics = r_squared)
performance(
ir,
actual = "Sepal.Length",
predicted = "fitted",
metrics = c(`R-squared` = r_squared, rmse = rmse)
)
performance(
ir,
actual = "Sepal.Length",
predicted = "fitted",
metrics = r_squared,
deviance_function = deviance_gamma
)
performance(
ir,
actual = "Sepal.Length",
predicted = "fitted",
metrics = r_squared,
deviance_function = deviance_tweedie,
tweedie_p = 2
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.