Learn R Programming

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

ModelMetrics: Rapid Calculation of Model Metrics

Tyler Hunt thunt@snapfinance.com

Introduction

ModelMetrics is a much faster and reliable package for evaluating models. ModelMetrics is written in using Rcpp making it faster than the other packages used for model metrics.

Installation

You can install this package from CRAN:

install.packages("ModelMetrics")

Or you can install the development version from Github with devtools:

devtools::install_github("JackStat/ModelMetrics")

Benchmark and comparison

N = 100000
Actual = as.numeric(runif(N) > .5)
Predicted = as.numeric(runif(N))

actual = Actual
predicted = Predicted

s1 <- system.time(a1 <- ModelMetrics::auc(Actual, Predicted))
s2 <- system.time(a2 <- Metrics::auc(Actual, Predicted))
# Warning message:
# In n_pos * n_neg : NAs produced by integer overflow
s3 <- system.time(a3 <- pROC::auc(Actual, Predicted))
s4 <- system.time(a4 <- MLmetrics::AUC(Predicted, Actual))
# Warning message:
# In n_pos * n_neg : NAs produced by integer overflow
s5 <- system.time({pp <- ROCR::prediction(Predicted, Actual); a5 <- ROCR::performance(pp, 'auc')})


data.frame(
  package = c("ModelMetrics", "pROC", "ROCR")
  ,Time = c(s1[[3]],s3[[3]],s5[[3]])
)

# MLmetrics and Metrics could not calculate so they are dropped from time comparison
#        package   Time
# 1 ModelMetrics  0.030
# 2         pROC 50.359
# 3         ROCR  0.358

Copy Link

Version

Install

install.packages('ModelMetrics')

Monthly Downloads

82,348

Version

1.2.2.1

License

GPL (>= 2)

Maintainer

Last Published

January 13th, 2020

Functions in ModelMetrics (1.2.2.1)

testDF

Test data
tnr

Specificity, True negative rate
rmse

Root-Mean Square Error
mauc

Multiclass Area Under the Curve
brier

Brier Score
auc

Area Under the Curve
confusionMatrix

Confusion Matrix
rmsle

Root Mean Squared Log Error
mcc

Matthews Correlation Coefficient
kappa

kappa statistic
ppv

Positive Predictive Value
gini

GINI Coefficient
recall

Recall, Sensitivity, tpr
mae

Mean absolute error
ce

Classification error
f1Score

F1 Score
logLoss

Log Loss
mlogLoss

Multiclass Log Loss
msle

Mean Squared Log Error
npv

Negative Predictive Value
mse

Mean Square Error
fScore

F Score