From 467fcd1fa5386338d42912f9c2280a38525d990a Mon Sep 17 00:00:00 2001 From: Bernd Bischl Date: Fri, 8 Nov 2024 20:04:20 +0100 Subject: [PATCH] sup-classif:nb fix dec bound plot --- slides/supervised-classification/rsrc/fig-disc_cod.R | 1 - slides/supervised-classification/rsrc/fig-nb-db.R | 10 +++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/slides/supervised-classification/rsrc/fig-disc_cod.R b/slides/supervised-classification/rsrc/fig-disc_cod.R index 4768f37ca..3b8374e87 100644 --- a/slides/supervised-classification/rsrc/fig-disc_cod.R +++ b/slides/supervised-classification/rsrc/fig-disc_cod.R @@ -80,5 +80,4 @@ plot <- ggplot(plot_data, aes(x = dimension, y = classif.ce, color = learner_id, legend.title = element_text(face = "bold", size = 20), legend.text = element_text(face = "bold", size = 16) ) -print(plot) ggsave("../figure/disc_cod.png", plot = plot, width = plot_width, height = plot_height, dpi = plot_dpi) diff --git a/slides/supervised-classification/rsrc/fig-nb-db.R b/slides/supervised-classification/rsrc/fig-nb-db.R index 0d2b9516e..d7d6af4ed 100644 --- a/slides/supervised-classification/rsrc/fig-nb-db.R +++ b/slides/supervised-classification/rsrc/fig-nb-db.R @@ -10,8 +10,6 @@ library(mvtnorm) # common settings set.seed(1234) -plot_width <- 20 -plot_height <- 10 plot_dpi <- 300 line_size <- 5 base_size <- 40 @@ -29,16 +27,17 @@ n = 300 classa = data.frame(mvrnorm(n = n, mu = c(2, 2), - Sigma = matrix(c(2, 0, 0, 2), + Sigma = matrix(c(1, 0.1, 0.1, 1), ncol = 2, byrow = TRUE))) classb = data.frame(mvrnorm(n = n, mu = c(10, 7), - Sigma = matrix(c(8, -6, -6, 8), + Sigma = matrix(c(5, -2, -2, 1), ncol = 2, byrow = TRUE))) + df = cbind(classa, factor(rep("a", ncol(classa)))) colnames(df) = c("x1", "x2", "y") @@ -92,6 +91,7 @@ pl = ggplot() + scale_fill_manual(values = c("a" = "#E69F00", "b" = "#56B4E9")) + scale_color_manual(values = c("a" = "#E69F00", "b" = "#56B4E9")) + labs(x = expression(x[1]), y = expression(x[2]), color = "class", fill = "class") + + coord_fixed(ratio = 1) + theme_minimal() + scale_alpha(range = c(0.1, 0.5), guide = 'none') + theme( @@ -103,4 +103,4 @@ pl = ggplot() + ) # Save directly to PNG -ggsave(filename = "../figure/nb-db.png", plot = pl, width = plot_width, height = plot_height, dpi = plot_dpi) +ggsave(filename = "../figure/nb-db.png", plot = pl, dpi = plot_dpi)