Weighted Metrics and Performance Measures for Machine Learning

Provides weighted versions of several metrics and performance measures used in machine learning, including average unit deviances of the Bernoulli, Tweedie, Poisson, and Gamma distributions, see Jorgensen B. (1997, ISBN: 978-0412997112). The package also contains a weighted version of generalized R-squared, see e.g. Cohen, J. et al. (2002, ISBN: 978-0805822236). Furthermore, 'dplyr' chains are supported.


{MetricsWeighted}

R-CMD-check Codecov test coverage CRAN_Status_Badge

Overview

{MetricsWeighted} provides weighted and unweighted versions of metrics and performance measures for machine learning.

Installation

# From CRAN
install.packages("MetricsWeighted")

# Development version
devtools::install_github("mayer79/MetricsWeighted")

Usage

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.

Example 1: Standard interface

library(MetricsWeighted)

y <- 1:10
pred <- c(2:10, 14)

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

Example 2: data.frame interface

Useful, e.g., in a {dplyr} chain.

dat <- data.frame(y = y, pred = pred)

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.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("MetricsWeighted")

1.0.4 by Michael Mayer, a year ago


https://github.com/mayer79/MetricsWeighted


Report a bug at https://github.com/mayer79/MetricsWeighted/issues


Browse source code at https://github.com/cran/MetricsWeighted


Authors: Michael Mayer [aut, cre] , Christian Lorentzen [ctb]


Documentation:   PDF Manual  


GPL (>= 2) license


Imports graphics, stats

Suggests knitr, rmarkdown, testthat


Imported by flashlight, mrIML, tidyrules.


See at CRAN