Learn R Programming

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

MetricsWeighted

The goal of this package is to provide weighted versions of metrics, scoring functions and performance measures for machine learning.

Installation

You can install the released version of MetricsWeighted from CRAN with:

install.packages("MetricsWeighted")

To get the bleeding edge version, you can run

library(devtools)
install_github("mayer79/MetricsWeighted", subdir = "release/MetricsWeighted")

Application

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

Can e.g. be used 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

Copy Link

Version

Install

install.packages('MetricsWeighted')

Monthly Downloads

1,041

Version

0.5.3

License

GPL (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Michael Mayer

Last Published

June 6th, 2021

Functions in MetricsWeighted (0.5.3)

gini_coefficient

Gini Coefficient
murphy_diagram

Murphy diagram
multi_metric

Multiple Metrics
prop_within

Proportion Within
performance

Performance
r_squared

Generalized R-Squared
precision

Precision
medae

Median Absolute Error
mse

Mean-Squared Error
recall

Recall
r_squared_poisson

Pseudo R-Squared regarding Poisson deviance
logLoss

Log Loss/Binary Cross Entropy
rmse

Root-Mean-Squared Error
f1_score

F1 Score
weighted_cor

Weighted Pearson Correlation
weighted_quantile

Weighted Quantiles
mape

Mean Absolute Percentage Error
mae

Mean Absolute Error
r_squared_gamma

Pseudo R-Squared regarding Gamma deviance
r_squared_bernoulli

Pseudo R-Squared regarding Bernoulli deviance
weighted_median

Weighted Median
weighted_mean

Weighted Mean
weighted_var

Weighted Variance
deviance_poisson

Poisson Deviance
deviance_bernoulli

Bernoulli Deviance
accuracy

Accuracy
classification_error

Classification Error
deviance_normal

Normal Deviance
deviance_gamma

Gamma Deviance
elementary_score

Elementary Scoring Function for Expectiles and Quantiles
AUC

Area under the ROC
deviance_tweedie

Tweedie Deviance