Learn R Programming

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

yardstick

yardstick is a package to estimate how well models are working using tidy data principals. The package webpage is https://topepo.github.io/yardstick/ for more information.

For example, suppose you create a classification model and predict a data set. You might have data that look like this:

library(yardstick)
library(dplyr)

head(two_class_example)
##    truth  Class1   Class2 predicted
## 1 Class2 0.00359 0.996411    Class2
## 2 Class1 0.67862 0.321379    Class1
## 3 Class2 0.11089 0.889106    Class2
## 4 Class1 0.73516 0.264838    Class1
## 5 Class2 0.01624 0.983760    Class2
## 6 Class1 0.99928 0.000725    Class1

You can use a dplyr-like syntax to compute common performance characteristics of the model and get them back in a data frame:

metrics(two_class_example, truth, predicted)
## # A tibble: 1 x 1
##   accuracy
##      <dbl>
## 1    0.838
# or 

two_class_example %>% roc_auc(truth, Class1)
## [1] 0.939

Quasiquotation can also be used:

# probability columns:
lvl <- levels(two_class_example$truth)

two_class_example %>% mnLogLoss(truth, !! lvl)
## [1] -0.328

Installation

To install the package:

install.packages("yardstick")

## for development version:
require("devtools")
install_github("topepo/yardstick")

Copy Link

Version

Install

install.packages('yardstick')

Monthly Downloads

47,898

Version

0.0.1

License

GPL-2

Issues

Pull Requests

Stars

Forks

Maintainer

Max Kuhn

Last Published

November 12th, 2017

Functions in yardstick (0.0.1)

accuracy

Classification Metrics on Predited Classes
conf_mat

Confusion Matrix for Categorical Data
roc_auc

Metrics Based on Class Probabilities
sens

Calculate sensitivity, specificity and predictive values
solubility_test

Solubility Predictions from MARS Model
summary.conf_mat

Summary Statistics for Confusion Matrices
hpc_cv

Class Probability Predictions
mcc

Other Metrics for 2x2 Tables
two_class_example

Two Class Predictions
metrics

General Function to Estimate Performance
pathology

Liver Pathology Data
recall

Calculate recall, precision and F values
rmse

Calculate Metrics for Numeric Outcomes