Skip to content

Qiqil677/MetricsWeighted

 
 

Repository files navigation

MetricsWeighted

CRAN version

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

About

R package for weighted model metrics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • R 100.0%