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")

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: Directly apply the metrics

library(MetricsWeighted)

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

rmse(y, pred)
rmse(y, pred, w = 1:10)

r_squared(y, pred)
r_squared(y, pred, deviance_function = deviance_gamma)

Example 2: Call the metrics through a common function that can be used within a dplyr chain

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

performance(dat, actual = "y", predicted = "pred")
performance(dat, actual = "y", predicted = "pred", metrics = r_squared)
performance(dat, actual = "y", predicted = "pred", 
            metrics = list(rmse = rmse, `R-squared` = r_squared))
performance(dat, actual = "y", predicted = "pred",
            metrics = list(deviance = deviance_gamma, pseudo_r2 = r_squared_gamma))

Copy Link

Version

Install

install.packages('MetricsWeighted')

Monthly Downloads

1,041

Version

0.5.1

License

GPL (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Michael Mayer

Last Published

April 18th, 2020

Functions in MetricsWeighted (0.5.1)

accuracy

Accuracy
classification_error

Classification Error
deviance_poisson

Poisson Deviance
elementary_score

Elementary Scoring Function for Expectiles and Quantiles
deviance_gamma

Gamma Deviance
deviance_bernoulli

Bernoulli Deviance
deviance_tweedie

Tweedie Deviance
gini_coefficient

Gini Coefficient
deviance_normal

Normal Deviance
AUC

Area under the ROC
multi_metric

Multiple Metrics
logLoss

Log Loss/Binary Cross Entropy
performance

Performance
precision

Precision
weighted_mean

Weighted Mean
prop_within

Proportion Within
r_squared

Pseudo R-Squared
weighted_cor

Weighted Pearson Correlation
r_squared_bernoulli

Pseudo R-Squared regarding Bernoulli deviance
medae

Median Absolute Error
r_squared_poisson

Pseudo R-Squared regarding Poisson deviance
mse

Mean-Squared Error
weighted_var

Weighted Variance
r_squared_gamma

Pseudo R-Squared regarding Gamma deviance
weighted_median

Weighted Median
weighted_quantile

Weighted Quantiles
f1_score

F1 Score
mae

Mean Absolute Error
mape

Mean Absolute Percentage Error
recall

Recall
rmse

Root-Mean-Squared Error