Thanks, on its way to CRAN

Interested in publishing a one-time post on R-bloggers.com? Press here to learn how.
The generic seal of approval from the CRAN team – countless hours spent tabbing between R CMD check and R CMD build logs, ‘Writing R Extensions’ and Stackoverflow approved, with a single line. The equivalent of “Noted, thanks” after a painstakingly well-written e-mail to your professor – except, this has an amazing feeling and a clear meaning: {SLmetrics} (finally) found its way to CRAN!

What is {SLmetrics}? Why should we even care?

{SLmetrics} is a collection of AI/ML performance metrics written in ‘C++’ with three things in mind: scalability, speed and simplicity – all well-known buzzwords on LinkedIn. Below is the results of the benchmark on computing a 2×2 confusion matrix:
Median execution time for constructing 2x2 confusion matrices across R packages.
Median execution time across R packages. For each N, 1000 measures have been taken with {microbenchmark}
{SLmetrics} is much faster, and more memory efficient, than the R-packages in question when computing the confusion matrix – this is an essential difference, as many if not most classification metrics are based off of the confusion matrix.

What’s new?

Since the blog-post on scalability and efficiency in January, many new features have been added. Below is an example on the Relative Root Mean Squared Error:

## 1) actual and predicted
##    values
actual    <- c(0.43, 0.85, 0.22, 0.48, 0.12, 0.88)
predicted <- c(0.46, 0.77, 0.12, 0.63, 0.18, 0.78)

## 2) calculate
##    metric and print
##    values
cat(
  "Mean Relative Root Mean Squared Error", SLmetrics::rrmse(
    actual        = actual,
    predicted     = predicted,
    normalization = 0
  ),
  "Range Relative Root Mean Squared Error (weighted)", SLmetrics::rrmse(
    actual        = actual,
    predicted     = predicted,
    normalization = 1
  ),
  sep = "\n"
)
#> Mean Relative Root Mean Squared Error
#> 0.3284712
#> Range Relative Root Mean Squared Error (weighted)
#> 0.3284712

Created on 2025-03-24 with reprex v2.1.1

Visit the online docs for a quick overview of all the available metrics and features.

Installing {SLmetrics}

{SLmetrics} can be installed via CRAN, or built from source using, for example, {pak}. See below:

Via CRAN

install.packages("SLmetrics")

Build from source

pak::pak(
    pkg = "serkor1/SLmetrics",
    ask = FALSE
)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.