knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "inst/imgs/README-" )
scorer
is a set of tools for quickly scoring models in data science and machine learning. This toolset is written in C++, where possible, for blazing fast performance. This toolset's API follows that of Python's sklearn.metrics as closely as possible so one can easily switch back and forth between R and Python without too much cognitive dissonance. The following types of metrics are currently implemented in scorer
:
The following types of metrics are soon to be implemented in scorer
:
You can install the latest development version from CRAN:
install.packages("scorer") ```` Or from GitHub with: ```R if (packageVersion("devtools") < 1.6) { install.packages("devtools") } devtools::install_github("paulhendricks/scorer")
If you encounter a clear bug, please file a minimal reproducible example on GitHub.
library("scorer") packageVersion("scorer") data(mtcars)
library("ggplot2") ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point() + geom_smooth(method = 'lm') + expand_limits(x = c(0, 6), y = c(0, 40))
set.seed(1) n_train <- floor(nrow(mtcars) * 0.60) n_test <- nrow(mtcars) - n_train mask <- sample(c(rep(x = TRUE, times = n_train), rep(x = FALSE, times = n_test))) mtcars[, "Type"] <- ifelse(mask, "Train", "Test") train_mtcars <- mtcars[mask, ] test_mtcars <- mtcars[!mask, ] ggplot(mtcars, aes(x = wt, y = mpg, color = Type)) + geom_point() + expand_limits(x = c(0, 6), y = c(0, 40))
model <- lm(mpg ~ wt, data = train_mtcars)
test_mtcars[, "predicted_mpg"] <- predict(model, newdata = test_mtcars)
scorer::mean_absolute_error(test_mtcars[, "mpg"], test_mtcars[, "predicted_mpg"]) scorer::mean_squared_error(test_mtcars[, "mpg"], test_mtcars[, "predicted_mpg"])
final_model <- lm(mpg ~ wt, data = mtcars)
mtcars[, "predicted_mpg"] <- predict(final_model, newdata = mtcars)
scorer::explained_variance_score(mtcars[, "mpg"], mtcars[, "predicted_mpg"]) scorer::unexplained_variance_score(mtcars[, "mpg"], mtcars[, "predicted_mpg"]) scorer::total_variance_score(mtcars[, "mpg"], mtcars[, "predicted_mpg"]) scorer::r2_score(mtcars[, "mpg"], mtcars[, "predicted_mpg"])
To cite package ‘scorer’ in publications use:
Paul Hendricks (2016). scorer: Quickly Score Models in Data Science and Machine Learning. R package version 0.2.0. https://CRAN.R-project.org/package=scorer
A BibTeX entry for LaTeX users is
@Manual{, title = {scorer: Quickly Score Models in Data Science and Machine Learning}, author = {Paul Hendricks}, year = {2016}, note = {R package version 0.2.0}, url = {https://CRAN.R-project.org/package=scorer}, }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.