Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

explain() breaks the compliation of .Rmd to pdf with LaTeX #473

Closed
hbaniecki opened this issue Nov 14, 2021 · 6 comments
Closed

explain() breaks the compliation of .Rmd to pdf with LaTeX #473

hbaniecki opened this issue Nov 14, 2021 · 6 comments
Labels
bug 💣 Bug to fix R 🐳 Related to R

Comments

@hbaniecki
Copy link
Member

hbaniecki commented Nov 14, 2021

OS: Windows 10. Compilation to HTML works fine.

Reproducible example (use in test.rmd):

library("DALEX")
library("ranger")
library("modelStudio")

# fit a model
model <- ranger(score ~., data = happiness_train)

# create an explainer for the model    
explainer <- explain(model,
                     data = happiness_test,
                     y = happiness_test$score,
                     label = "Random Forest")

Outcome:

image

Fix: use verbose = FALSE.

library("DALEX")
library("ranger")
library("modelStudio")

# fit a model
model <- ranger(score ~., data = happiness_train)

# create an explainer for the model    
explainer <- explain(model,
                     data = happiness_test,
                     y = happiness_test$score,
                     label = "Random Forest",
                     verbose = FALSE)

We should find the symbol in verbose output that breaks this.

@hbaniecki hbaniecki added bug 💣 Bug to fix R 🐳 Related to R labels Nov 14, 2021
@piotrpiatyszek
Copy link
Member

1b in hex = 33 in oct

The problem is with escape character, that is used to create colors (https://en.wikipedia.org/wiki/ANSI_escape_code).
We use it there

color_codes <- list(yellow_start = "\033[33m", yellow_end = "\033[39m",
                    red_start = "\033[31m", red_end = "\033[39m",
                    green_start = "\033[32m", green_end = "\033[39m")

@pbiecek
Copy link
Member

pbiecek commented Nov 15, 2021

Colors are not rendered correctly through Rmd->html engine.
One option is to set verbose = FALSE
Second and less invasive is to set colorize = FALSE in the explain() function

@hbaniecki
Copy link
Member Author

Potentially set colorize = !isTRUE(getOption('knitr.in.progress')) as a new default.

pbiecek added a commit that referenced this issue Feb 16, 2022
@pbiecek
Copy link
Member

pbiecek commented Feb 16, 2022

@hbaniecki please check if b4889ed solves this issue

@pbiecek
Copy link
Member

pbiecek commented Feb 16, 2022

version bumped to 2.4.0 due to the change in defaults

@hbaniecki
Copy link
Member Author

Thanks, it works well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 💣 Bug to fix R 🐳 Related to R
Projects
None yet
Development

No branches or pull requests

3 participants