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 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.

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

Copy Link

Version

Install

install.packages('MetricsWeighted')

Monthly Downloads

731

Version

0.1.0

License

GPL (>= 2)

Maintainer

Michael Mayer

Last Published

July 28th, 2019

Functions in MetricsWeighted (0.1.0)

accuracy

Accuracy
precision

Precision
performance

Apply one or more metrics to columns in a data set
weighted_mean

Weighted mean that handles NULL weights
rmse

Root-mean-squared error
mae

Mean absolute error
logLoss

Log Loss/binary cross entropy
r_squared

Pseudo R-squared
recall

Recall
mse

Mean-squared error
mape

Mean absolute percentage error
gini_coefficient

Gini coefficient
deviance_tweedie

Tweedie deviance
deviance_bernoulli

Bernoulli deviance
f1_score

F1 score
AUC

Area under the ROC
deviance_gamma

Gamma deviance
deviance_poisson

Poisson deviance
classification_error

Classification error
deviance_normal

Normal deviance