tidymodels / yardstick

Tidy methods for measuring model performance
https://yardstick.tidymodels.org/
Other
367 stars 54 forks source link

autoplot.conf_mat() text is hard to read at times #437

Open EmilHvitfeldt opened 1 year ago

EmilHvitfeldt commented 1 year ago

High frequency areas of the conf_mat() can be hard to read because of the contrast. something should be done.

It is hard because sometime the text isn't super needed (at a glance you can read the plot with the grey), and sometimes it would be nice to read the numbers directly

library(yardstick)
library(ggplot2)

two_class_example |>
  conf_mat(truth, predicted) |>
  autoplot(type = "heatmap")

Created on 2023-07-11 with reprex v2.0.2

bappa10085 commented 1 month ago

If I use different color scales, the high-frequency features become more difficult to read like

library(yardstick)
library(ggplot2)
library(colorspace)

two_class_example |>
  conf_mat(truth, predicted) |>
  autoplot(type = "heatmap") +
  scale_fill_continuous_sequential(palette = "Blues") +
  theme(text=element_text(family = "serif", size=15), 
        axis.text.x = element_text(colour="black"), 
        axis.text.y = element_text(colour="black"))

image

It would be much better if the output is rendered in the following way

image