mlr3book icon indicating copy to clipboard operation
mlr3book copied to clipboard

Auto-generate tables for dictionaries

Open jemus42 opened this issue 3 years ago • 1 comments

Example would be table of resamplings in the performance chapter, which is currently manually created. This is both tedious and prone to error, see e.g. the omission of custom_cv (#399).

For cases like this I'd like to auto-generate tables from dictionaries with auto-linked help pages, and I came up with something along those lines (which could of course be improved/generalized, but the idea is straight forward):

library(mlr3)
resampling_dt <- as.data.table(mlr_resamplings)[, c("label", "key")]
resampling_dt$key <- vapply(resampling_dt$key, function(x) {
  mlr3book::ref(topic = paste0("mlr_resamplings_", x), text = sprintf("\"%s\"", x))
}, character(1))

knitr::kable(
  resampling_dt, escape = FALSE,
  col.names = c("Name", "Identifier"),
  caption = "Resampling strategies included in mlr3"
)
Name Identifier
Bootstrap "bootstrap"
Custom Splits "custom"
Custom Split Cross-Validation "custom_cv"
Cross-Validation "cv"
Holdout "holdout"
Insample Resampling "insample"
Leave-One-Out "loo"
Repeated Cross-Validation "repeated_cv"
Subsampling "subsampling"

Resampling strategies included in mlr3

Created on 2022-09-09 with reprex v2.0.2

jemus42 avatar Sep 09 '22 14:09 jemus42

We already do so in the mlr3website. You could copy the logic from there.

pat-s avatar Sep 14 '22 14:09 pat-s

I don't think we should necessarily do this. The tables we currently have already don't provide enough info to be valuable to the user, in your example it would be useful to add a column that very briefly explains each method.

RaphaelS1 avatar Oct 19 '22 15:10 RaphaelS1

I guess it makes sense in the HTML context where it's a clickable link to the docs, as a "further reading" - but I see how in the printed/offline-PDF context it's not necessarily valuable.

Depends on whether the "overview of things available via " is considered useful/suitable for the (printed) book or if it should always be a link to up-to-date docs/website anyway.

jemus42 avatar Oct 19 '22 15:10 jemus42

General issue unfortunately. Agreed for online we want it to always be up-to-date but of course this isn't possible for the book. My preference is to pick consistency based on the book and accept this is sub-optimal (happy to be convinced otherwise).

RaphaelS1 avatar Oct 19 '22 15:10 RaphaelS1

Could be appendices that are not included in the print version? I also agree that we want this online, but I don't think it would add much value for the book.

larskotthoff avatar Oct 20 '22 08:10 larskotthoff

Or we could do something similar to the learner search but for all our dictionaries?

RaphaelS1 avatar Oct 20 '22 09:10 RaphaelS1