An R package for common supervised machine learning metrics.
This package is distributed from CRAN. From the R prompt, run install.packages("Metrics")
.
This repository contains code for the Metrics package in R. Metrics was created by Ben Hamner and came from this github repo. Hamner’s repo contains packages for common machine learning metrics in several programming languages, not just R. On 2017-04-21, CRAN orphaned the R package. To revive the status of the R package, I cloned the original and created this repo. I have added new metrics, improved documentation, and fixed bugs. This repository will be the home of active development on the Metrics R package moving forward.
If you notice anything wrong with the Metrics package or have any ideas on how to improve it, please create an issue in this github repository that describes your issue. I also welcome improvements to this package via a pull request. This is a simple R package, which makes it perfect for first time open source contributors. Here is a guide that walks you through how to make an open source contribution.
All functions in the Metrics package take at least two arguments: actual
and predicted
. In the table below, I abbreviate actual
as x and predicted
as y for the sake of mathematical brevity.
Metric Type | Metric Name | Function Name | Formula |
---|---|---|---|
regression | Squared Error | se | |
regression | Mean Squared Error | mse | |
regression | Root Mean Squared Error | rmse | |
regression | Absolute Error | ae | |
regression | Mean Absolute Error | mae | |
regression | Absolute Percent Error | ape | |
regression | Mean Absolute Percent Error | mape | |
regression | Symmetric Mean Absolute Percent Error | smape | |
regression | Squared Log Error | sle | |
regression | Mean Squared Log Error | msle | |
regression | Root Mean Squared Log Error | rmsle | |
regression | Relative Squared Error | rse | |
regression | Root Relative Squared Error | rrse | |
regression | Relative Absolute Error | rae | |
time series | Mean Absolute Scaled Error | mase | |
classification | Classification Error | ce | |
classification | Accuracy | accuracy | |
classification | F1 Score | f1 | |
binary classification | Area Under ROC Curve | auc | . help(auc) for details. |
binary classification | Log Loss | ll | |
binary classification | Mean Log Loss | logloss | |
binary classification | Precision | precision | |
binary classification | Recall | recall | |
binary classification | F-beta Score | fbeta_score |