{MetricsWeighted} provides weighted and unweighted versions of metrics and performance measures for machine learning.
# From CRAN
install.packages("MetricsWeighted")
# Development version
::install_github("mayer79/MetricsWeighted") devtools
There are two ways to apply the package. We will go through them in the following examples. Please have a look at the vignette on CRAN for further information and examples.
library(MetricsWeighted)
<- 1:10
y <- c(2:10, 14)
pred
rmse(y, pred) # 1.58
rmse(y, pred, w = 1:10) # 1.93
r_squared(y, pred) # 0.70
r_squared(y, pred, deviance_function = deviance_gamma) # 0.78
Useful, e.g., in a {dplyr} chain.
<- data.frame(y = y, pred = pred)
dat
performance(dat, actual = "y", predicted = "pred")
> metric value
> rmse 1.581139
performance(
dat, actual = "y",
predicted = "pred",
metrics = list(rmse = rmse, `R-squared` = r_squared)
)
> metric value
> rmse 1.5811388
> R-squared 0.6969697
Check out the vignette for more applications.