Learn R Programming

⚠️There's a newer version (1.0.4) of this package.Take me there.

{MetricsWeighted}

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.

Copy Link

Version

Install

install.packages('MetricsWeighted')

Monthly Downloads

919

Version

1.0.0

License

GPL (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Michael Mayer

Last Published

April 16th, 2023

Functions in MetricsWeighted (1.0.0)

medae

Median Absolute Error
mse

Mean-Squared Error
AUC

Area under the ROC
elementary_score

Elementary Scoring Function for Expectiles and Quantiles
deviance_tweedie

Tweedie Deviance
r_squared_poisson

Pseudo R-Squared regarding Poisson deviance
deviance_gamma

Gamma Deviance
deviance_normal

Normal Deviance
weighted_cor

Weighted Pearson Correlation
mape

Mean Absolute Percentage Error
gini_coefficient

Gini Coefficient
logLoss

Log Loss/Binary Cross Entropy
mae

Mean Absolute Error
weighted_mean

Weighted Mean
prop_within

Proportion Within
performance

Performance
r_squared

Generalized R-Squared
weighted_median

Weighted Median
rmse

Root-Mean-Squared Error
precision

Precision
weighted_quantile

Weighted Quantiles
recall

Recall
r_squared_gamma

Pseudo R-Squared regarding Gamma deviance
r_squared_bernoulli

Pseudo R-Squared regarding Bernoulli deviance
weighted_var

Weighted Variance
classification_error

Classification Error
deviance_poisson

Poisson Deviance
deviance_bernoulli

Bernoulli Deviance
f1_score

F1 Score
accuracy

Accuracy
murphy_diagram

Murphy diagram
multi_metric

Multiple Metrics