tidymodels / tidyposterior

Bayesian comparisons of models using resampled statistics
https://tidyposterior.tidymodels.org
Other
102 stars 10 forks source link

metric_sets #30

Open topepo opened 5 years ago

topepo commented 5 years ago

yardstick will return multiple metrics in a stacked format. We should have an option to use this format directly.

library(tidymodels)
#> ── Attaching packages ──────────────────────────────────────────────────────────────────────────────────── tidymodels 0.0.2 ──
#> ✔ broom     0.5.1       ✔ purrr     0.3.2  
#> ✔ dials     0.0.2       ✔ recipes   0.1.5  
#> ✔ dplyr     0.8.0.1     ✔ rsample   0.0.4  
#> ✔ ggplot2   3.1.1       ✔ tibble    2.1.1  
#> ✔ infer     0.4.0       ✔ yardstick 0.0.2  
#> ✔ parsnip   0.0.2
#> ── Conflicts ─────────────────────────────────────────────────────────────────────────────────────── tidymodels_conflicts() ──
#> ✖ purrr::discard() masks scales::discard()
#> ✖ dplyr::filter()  masks stats::filter()
#> ✖ dplyr::lag()     masks stats::lag()
#> ✖ recipes::step()  masks stats::step()

# Multiple regression metrics
multi_metric <- metric_set(rmse, rsq, ccc)

# The returned function has arguments:
# fn(data, truth, estimate, na_rm = TRUE, ...)
multi_metric(solubility_test, truth = solubility, estimate = prediction)
#> # A tibble: 3 x 3
#>   .metric .estimator .estimate
#>   <chr>   <chr>          <dbl>
#> 1 rmse    standard       0.722
#> 2 rsq     standard       0.879
#> 3 ccc     standard       0.934

Created on 2019-05-18 by the reprex package (v0.2.1)