diff --git a/latex-math/basic-ml.tex b/latex-math/basic-ml.tex index 5c315b05..1b43efcc 100644 --- a/latex-math/basic-ml.tex +++ b/latex-math/basic-ml.tex @@ -154,12 +154,14 @@ \newcommand{\Lxyt}{L\left(y, \fxt\right)} % loss with f parameterized \newcommand{\Lxyit}{L\left(\yi, \fxit\right)} % loss of observation with f parameterized \newcommand{\Lxym}{L\left(\yi, f\left(\bm{\tilde{x}}^{(i)} ~|~ \thetab\right)\right)} % loss of observation with f parameterized +\newcommand{\Lpiy}{L\left(y, \pi\right)} % loss in classification \newcommand{\Lpixy}{L\left(y, \pix\right)} % loss in classification \newcommand{\Lpiv}{L\left(y, \piv\right)} % loss in classification \newcommand{\Lpixyi}{L\left(\yi, \pixii\right)} % loss of observation in classification \newcommand{\Lpixyt}{L\left(y, \pixt\right)} % loss with pi parameterized \newcommand{\Lpixyit}{L\left(\yi, \pixit\right)} % loss of observation with pi parameterized \newcommand{\Lhxy}{L\left(y, \hx\right)} % L(y, h(x)), loss function on discrete classes +\newcommand{\Lhy}{L\left(y, h\right)} % L(y, h), loss function on discrete classes \newcommand{\Lr}{L\left(r\right)} % L(r), loss defined on residual (reg) / margin (classif) \newcommand{\lone}{|y - \fx|} % L1 loss \newcommand{\ltwo}{\left(y - \fx\right)^2} % L2 loss diff --git a/slides/advriskmin/chapter-order.tex b/slides/advriskmin/chapter-order.tex index 98e85d46..4a0cc57e 100644 --- a/slides/advriskmin/chapter-order.tex +++ b/slides/advriskmin/chapter-order.tex @@ -4,11 +4,11 @@ % slides-advriskmin-regression-l2 % slides-advriskmin-regression-l1 % slides-advriskmin-regression-further-losses -% slides-advriskmin-cassification-01 -% slides-advriskmin-cassification-bernoulli +% slides-advriskmin-classification-01 +% slides-advriskmin-classification-bernoulli % slides-advriskmin-logreg-deepdive -% slides-advriskmin-cassification-brier -% slides-advriskmin-cassification-furtherlosses +% slides-advriskmin-classification-brier +% slides-advriskmin-classification-furtherlosses % slides-advriskmin-classification-deepdive % slides-advriskmin-max-likelihood-l2 % slides-advriskmin-max-likelihood-other diff --git a/slides/advriskmin/figure/bernoulli.png b/slides/advriskmin/figure/bernoulli.png new file mode 100644 index 00000000..dfe6cb63 Binary files /dev/null and b/slides/advriskmin/figure/bernoulli.png differ diff --git a/slides/advriskmin/figure/bernoulli_margin.png b/slides/advriskmin/figure/bernoulli_margin.png new file mode 100644 index 00000000..64b5539b Binary files /dev/null and b/slides/advriskmin/figure/bernoulli_margin.png differ diff --git a/slides/advriskmin/figure/bernoulli_prob.png b/slides/advriskmin/figure/bernoulli_prob.png new file mode 100644 index 00000000..c87f2c78 Binary files /dev/null and b/slides/advriskmin/figure/bernoulli_prob.png differ diff --git a/slides/advriskmin/figure/brier.png b/slides/advriskmin/figure/brier.png new file mode 100644 index 00000000..0d378748 Binary files /dev/null and b/slides/advriskmin/figure/brier.png differ diff --git a/slides/advriskmin/figure/exponential.png b/slides/advriskmin/figure/exponential.png new file mode 100644 index 00000000..386c5eaf Binary files /dev/null and b/slides/advriskmin/figure/exponential.png differ diff --git a/slides/advriskmin/figure/hinge.png b/slides/advriskmin/figure/hinge.png new file mode 100644 index 00000000..2a0414a8 Binary files /dev/null and b/slides/advriskmin/figure/hinge.png differ diff --git a/slides/advriskmin/figure/hinge_squared.png b/slides/advriskmin/figure/hinge_squared.png new file mode 100644 index 00000000..697ce391 Binary files /dev/null and b/slides/advriskmin/figure/hinge_squared.png differ diff --git a/slides/advriskmin/figure/logistic.png b/slides/advriskmin/figure/logistic.png new file mode 100644 index 00000000..f6d1fde5 Binary files /dev/null and b/slides/advriskmin/figure/logistic.png differ diff --git a/slides/advriskmin/figure/logistic_inverse.png b/slides/advriskmin/figure/logistic_inverse.png new file mode 100644 index 00000000..ef462233 Binary files /dev/null and b/slides/advriskmin/figure/logistic_inverse.png differ diff --git a/slides/advriskmin/figure/overview_classif.png b/slides/advriskmin/figure/overview_classif.png new file mode 100644 index 00000000..d29956c4 Binary files /dev/null and b/slides/advriskmin/figure/overview_classif.png differ diff --git a/slides/advriskmin/figure/plot_bernoulli.png b/slides/advriskmin/figure/plot_bernoulli.png deleted file mode 100644 index 18fd9979..00000000 Binary files a/slides/advriskmin/figure/plot_bernoulli.png and /dev/null differ diff --git a/slides/advriskmin/figure/plot_bernoulli_plusmin_encoding.png b/slides/advriskmin/figure/plot_bernoulli_plusmin_encoding.png deleted file mode 100644 index 9f67d924..00000000 Binary files a/slides/advriskmin/figure/plot_bernoulli_plusmin_encoding.png and /dev/null differ diff --git a/slides/advriskmin/figure/plot_bernoulli_prob.png b/slides/advriskmin/figure/plot_bernoulli_prob.png deleted file mode 100644 index ca301226..00000000 Binary files a/slides/advriskmin/figure/plot_bernoulli_prob.png and /dev/null differ diff --git a/slides/advriskmin/figure/plot_brier.png b/slides/advriskmin/figure/plot_brier.png deleted file mode 100644 index af91e867..00000000 Binary files a/slides/advriskmin/figure/plot_brier.png and /dev/null differ diff --git a/slides/advriskmin/figure/plot_loss_01.png b/slides/advriskmin/figure/plot_loss_01.png deleted file mode 100644 index ce94d58a..00000000 Binary files a/slides/advriskmin/figure/plot_loss_01.png and /dev/null differ diff --git a/slides/advriskmin/figure/plot_loss_exponential.png b/slides/advriskmin/figure/plot_loss_exponential.png deleted file mode 100644 index 70e8aac8..00000000 Binary files a/slides/advriskmin/figure/plot_loss_exponential.png and /dev/null differ diff --git a/slides/advriskmin/figure/plot_loss_hinge.png b/slides/advriskmin/figure/plot_loss_hinge.png deleted file mode 100644 index 2ef76f61..00000000 Binary files a/slides/advriskmin/figure/plot_loss_hinge.png and /dev/null differ diff --git a/slides/advriskmin/figure/plot_loss_hinge_squared.png b/slides/advriskmin/figure/plot_loss_hinge_squared.png deleted file mode 100644 index be899a19..00000000 Binary files a/slides/advriskmin/figure/plot_loss_hinge_squared.png and /dev/null differ diff --git a/slides/advriskmin/figure/plot_loss_overview_classif.png b/slides/advriskmin/figure/plot_loss_overview_classif.png deleted file mode 100644 index 0c316d3d..00000000 Binary files a/slides/advriskmin/figure/plot_loss_overview_classif.png and /dev/null differ diff --git a/slides/advriskmin/figure/plot_loss_overview_classif_2.png b/slides/advriskmin/figure/plot_loss_overview_classif_2.png deleted file mode 100644 index 8ad6880a..00000000 Binary files a/slides/advriskmin/figure/plot_loss_overview_classif_2.png and /dev/null differ diff --git a/slides/advriskmin/figure/plot_loss_squared_scores.png b/slides/advriskmin/figure/plot_loss_squared_scores.png deleted file mode 100644 index 97959a65..00000000 Binary files a/slides/advriskmin/figure/plot_loss_squared_scores.png and /dev/null differ diff --git a/slides/advriskmin/figure/squared_scores.png b/slides/advriskmin/figure/squared_scores.png new file mode 100644 index 00000000..297313d3 Binary files /dev/null and b/slides/advriskmin/figure/squared_scores.png differ diff --git a/slides/advriskmin/figure/zero_one.png b/slides/advriskmin/figure/zero_one.png new file mode 100644 index 00000000..a439c87f Binary files /dev/null and b/slides/advriskmin/figure/zero_one.png differ diff --git a/slides/advriskmin/rsrc/bernoulli.R b/slides/advriskmin/rsrc/bernoulli.R new file mode 100644 index 00000000..946e3ad9 --- /dev/null +++ b/slides/advriskmin/rsrc/bernoulli.R @@ -0,0 +1,57 @@ +# ------------------------------------------------------------------------------ +# classification bernoulli + +# FIG: Bernoulli loss (1) on margin (2) on probability (3) on margin no quote +# ------------------------------------------------------------------------------ + +library(ggplot2) +theme_set(theme_minimal()) + +# DATA ------------------------------------------------------------------------- + +x_1 <- seq(-4, 4, by = 0.01) +y <- log(1L + exp(-x_1)) + +bernoulli = function(y, pix){ + -y * log(pix) - (1 - y) * log(1 - pix) +} + +x_2 <- seq(0, 1, by = 0.001) +df <- data.frame(x = x_2, y = 1L, pi = bernoulli(1L, x_2)) +df <- rbind(df, data.frame(x = x_2, y = 0L, pi = bernoulli(0L, x_2))) +df$y <- as.factor(df$y) + +# PLOTS ------------------------------------------------------------------------ + +p_1 <- ggplot(data.frame(x_1, y), aes(x = x_1, y = y)) + + geom_line(size = 1.2) + + xlab(expression(yf)) + + ylab(expression(L(y, f))) + +p_1 <- p_1 + + annotate( + "text", + x = 2, + y = 2, + label = expression(L(y, f) == ln(1 + exp(-y * f))), + size = 7) + +p_1 <- p_1 + theme(text = element_text(size = 20)) + +ggsave("../figure/bernoulli_margin.png", p_1, height = 4, width = 9) + +p_2 <- ggplot(data = df, aes(x = x, y = pi, color = y)) + + geom_line(size = 1.2) + + xlab(expression(pi)) + + ylab(expression(L(y, pi))) + + theme(text = element_text(size = 20)) + + scale_color_viridis_d(end = 0.9) + +ggsave("../figure/bernoulli_prob.png", p_2, height = 4, width = 6) + +p_3 <- ggplot(data.frame(x_1, y), aes(x = x_1, y = y)) + + geom_line(size = 1.6) + + xlab(expression(yf)) + + ylab(expression(L(y, f))) + +ggsave("../figure/bernoulli.png", p_3, height = 2.85, width = 5) diff --git a/slides/advriskmin/rsrc/make_loss_brier_plot.R b/slides/advriskmin/rsrc/brier.R similarity index 54% rename from slides/advriskmin/rsrc/make_loss_brier_plot.R rename to slides/advriskmin/rsrc/brier.R index d68ef245..d54a50d7 100644 --- a/slides/advriskmin/rsrc/make_loss_brier_plot.R +++ b/slides/advriskmin/rsrc/brier.R @@ -1,31 +1,29 @@ -# ------------------------------------------------------------------------------ -# FIG: BRIER SCORE -# ------------------------------------------------------------------------------ - -library(ggplot2) - -# DATA ------------------------------------------------------------------------- - -x <- seq(0L, 1L, by = 0.01) - -df <- rbind( - data.frame(x, y = 1L, pi = (1 - x)^2), - data.frame(x, y = 0L, pi = x^2)) - -df$y <- as.factor(df$y) - -# PLOTS ------------------------------------------------------------------------ - -p <- ggplot2::ggplot(data = df, aes(x = x, y = pi, color = y)) + - geom_line(size = 1.2) + - xlab(expression(pi(x))) + - ylab(expression(L(y, pi(x)))) + - theme_minimal() + - theme(text = element_text(size = 20L)) + - scale_color_viridis_d(end = 0.9) - -ggplot2::ggsave( - "../figure/plot_brier.png", - p, - height = 4L, - width = 10L) +# ------------------------------------------------------------------------------ +# classification brier + +# FIG: Brier score +# ------------------------------------------------------------------------------ + +library(ggplot2) + +# DATA ------------------------------------------------------------------------- + +x <- seq(0, 1, by = 0.01) + +df <- rbind( + data.frame(x, y = 1, pi = (1 - x)^2), + data.frame(x, y = 0, pi = x^2)) + +df$y <- as.factor(df$y) + +# PLOTS ------------------------------------------------------------------------ + +p <- ggplot(data = df, aes(x = x, y = pi, color = y)) + + geom_line(size = 1.2) + + xlab(expression(pi)) + + ylab(expression(L(y, pi))) + + theme_minimal() + + theme(text = element_text(size = 20)) + + scale_color_viridis_d(end = 0.9) + +ggsave("../figure/brier.png", p, height = 4, width = 9) diff --git a/slides/advriskmin/rsrc/make_loss_exponential_plot.R b/slides/advriskmin/rsrc/exponential.R similarity index 52% rename from slides/advriskmin/rsrc/make_loss_exponential_plot.R rename to slides/advriskmin/rsrc/exponential.R index d9b31323..576b625a 100644 --- a/slides/advriskmin/rsrc/make_loss_exponential_plot.R +++ b/slides/advriskmin/rsrc/exponential.R @@ -1,27 +1,25 @@ -# ------------------------------------------------------------------------------ -# FIG: EXPONENTIAL LOSS -# ------------------------------------------------------------------------------ - -library(ggplot2) - -# DATA ------------------------------------------------------------------------- - -x <- seq(-4L, 4L, by = 0.01) -y <- exp(-x) - -# PLOTS ------------------------------------------------------------------------ - -p <- ggplot2::ggplot(data.frame(x, y), aes(x = x, y = y)) + - geom_line(size = 1.2) + - scale_x_continuous(breaks = seq(-4L, 4L)) + - xlab(expression(yf(x))) + - ylab(expression(L(y, f(x)))) + - theme_minimal() + - theme(text = element_text(size = 30L)) - -ggplot2::ggsave( - "../figure/plot_loss_exponential.png", - p, - height = 4L, - width = 12L) - +# ------------------------------------------------------------------------------ +# classification further losses + +# FIG: exponential loss +# ------------------------------------------------------------------------------ + +library(ggplot2) + +# DATA ------------------------------------------------------------------------- + +x <- seq(-4, 4, by = 0.01) +y <- exp(-x) + +# PLOTS ------------------------------------------------------------------------ + +p <- ggplot(data.frame(x, y), aes(x = x, y = y)) + + geom_line(size = 1.2) + + scale_x_continuous(breaks = seq(-4, 4)) + + xlab(expression(yf)) + + ylab(expression(L(y, f))) + + theme_minimal() + + theme(text = element_text(size = 30)) + +ggsave("../figure/exponential.png", p, height = 4, width = 12) + diff --git a/slides/advriskmin/rsrc/make_loss_hinge_plot.R b/slides/advriskmin/rsrc/hinge.R similarity index 56% rename from slides/advriskmin/rsrc/make_loss_hinge_plot.R rename to slides/advriskmin/rsrc/hinge.R index ce373437..8e70482c 100644 --- a/slides/advriskmin/rsrc/make_loss_hinge_plot.R +++ b/slides/advriskmin/rsrc/hinge.R @@ -1,56 +1,57 @@ -# ------------------------------------------------------------------------------ -# FIG: HINGE LOSS -# ------------------------------------------------------------------------------ - -library(ggplot2) - -# DATA ------------------------------------------------------------------------- - -x <- seq(-1L, 2L, by = 0.01) -l_01 <- as.numeric(x < 0L) -l_hinge <- ifelse(x < 1L, 1L - x, 0L) -l_hinge_squared <- ifelse(x < 1L, (1L - x)^2, 0L) - -df <- tidyr::gather( - data.frame(x, l_hinge_squared, l_hinge, l_01), - "loss", - "value", - -x) - -# PLOTS ------------------------------------------------------------------------ - -p_1 <- ggplot2::ggplot( - df[df$loss != "l_hinge_squared", ], - aes(x = x, y = value, col = loss)) + - geom_line(size = 1.2) + - scale_color_viridis_d( - end = 0.9, - name = "Loss", - labels = c("0-1", "hinge"), - direction = -1L) + - xlab(expression(yf(x))) + - ylab(expression(L(y, f(x)))) + - theme_minimal() + - theme(text = element_text(size = 30L)) - -ggplot2::ggsave("../figure/plot_loss_hinge.png", p_1, height = 4L, width = 12L) - -p_2 <- ggplot2::ggplot( - df, - aes(x = x, y = value, col = loss)) + - geom_line(size = 1.2) + - scale_color_viridis_d( - end = 0.9, - name = "Loss", - labels = c("0-1", "hinge", "squared hinge"), - direction = -1L) + - xlab(expression(r = yf(x))) + - ylab(expression(L(y, f(x)))) + - theme_minimal() + - theme(text = element_text(size = 30L)) - -ggplot2::ggsave( - "../figure/plot_loss_hinge_squared.png", - p_2, - height = 6L, - width = 12L) +# ------------------------------------------------------------------------------ +# classification further losses + +# FIG: +# (1) hinge loss & 0-1 loss +# (2) hinge loss , 0-1 loss & hige-squared loss +# ------------------------------------------------------------------------------ + +library(ggplot2) +library(tidyr) + +# DATA ------------------------------------------------------------------------- + +x <- seq(-1, 2, by = 0.01) +l_01 <- as.numeric(x < 0) +l_hinge <- ifelse(x < 1, 1 - x, 0) +l_hinge_squared <- ifelse(x < 1, (1 - x)^2, 0) + +df <- gather( + data.frame(x, l_hinge_squared, l_hinge, l_01), + "loss", + "value", + -x) + +# PLOTS ------------------------------------------------------------------------ + +p_1 <- ggplot( + df[df$loss != "l_hinge_squared", ], + aes(x = x, y = value, col = loss)) + + geom_line(size = 1.2) + + scale_color_viridis_d( + end = 0.9, + name = "Loss", + labels = c("0-1", "hinge"), + direction = -1L) + + xlab(expression(yf)) + + ylab(expression(L(y, f))) + + theme_minimal() + + theme(text = element_text(size = 30)) + +ggsave("../figure/hinge.png", p_1, height = 4, width = 12) + +p_2 <- ggplot( + df, + aes(x = x, y = value, col = loss)) + + geom_line(size = 1.2) + + scale_color_viridis_d( + end = 0.9, + name = "Loss", + labels = c("0-1", "hinge", "squared hinge"), + direction = -1L) + + xlab(expression(r = yf)) + + ylab(expression(L(y, f))) + + theme_minimal() + + theme(text = element_text(size = 30)) + +ggsave("../figure/hinge_squared.png", p_2, height = 6, width = 12) diff --git a/slides/advriskmin/rsrc/logistic.R b/slides/advriskmin/rsrc/logistic.R new file mode 100644 index 00000000..ca37f66e --- /dev/null +++ b/slides/advriskmin/rsrc/logistic.R @@ -0,0 +1,54 @@ +# ------------------------------------------------------------------------------ +# classification bernoulli + +# FIG: logistic function and its inverse logit function +# ------------------------------------------------------------------------------ + +library(ggplot2) +theme_set(theme_minimal()) + +# DATA ------------------------------------------------------------------------- + +logistic = function(f){ + 1 / (1 + exp(-f)) +} + +logit = function(p){ + log(p / (1 - p)) +} + +f <- seq(-4, 4, by = 0.01) +y_log <- logistic(f) + +pix <- seq(0, 1, by = 0.001) +y_logit <- logit(pix) + +df_1 <- data.frame(x = f, y = y_log) +df_2 <- data.frame(x = pix, y = y_logit) + +# PLOT ------------------------------------------------------------------------- + +p_1 <- ggplot(df_1, aes(x = x, y = y)) + + geom_line(size = 1.2) + + xlab(expression(f)) + + ylab(expression(pi)) + +p_1 <- p_1 + + annotate( + "text", + x = 2, + y = 0.3, + label = bquote(pi ~ "=" ~ (1 + exp(-f))^-1), + size = 7) + +p_1 <- p_1 + theme(text = element_text(size = 20)) + +ggsave("../figure/logistic.png", p_1, height = 4, width = 6) + +p_2 <- ggplot(df_2, aes(x = x, y = y)) + + geom_line(size = 1.2) + + xlab(expression(p)) + + ylab(expression(f^"*")) + + theme(text = element_text(size = 20)) + +ggsave("../figure/logistic_inverse.png", p_2, height = 6, width = 8) diff --git a/slides/advriskmin/rsrc/make_loss_bernoulli_plots.R b/slides/advriskmin/rsrc/make_loss_bernoulli_plots.R deleted file mode 100644 index 72959cdb..00000000 --- a/slides/advriskmin/rsrc/make_loss_bernoulli_plots.R +++ /dev/null @@ -1,53 +0,0 @@ -# ------------------------------------------------------------------------------ -# FIG: BERNOULLI LOSS -# ------------------------------------------------------------------------------ - -library(ggplot2) - -# DATA ------------------------------------------------------------------------- - -x_1 <- seq(-4L, 4L, by = 0.01) -y <- log(1L + exp(-x_1)) - -bernoulli = function(y, pix) { - -y * log(pix) - (1 - y) * log(1 - pix) -} - -x_2 <- seq(0L, 1L, by = 0.001) -df <- data.frame(x = x_2, y = 1L, pi = bernoulli(1L, x_2)) -df <- rbind(df, data.frame(x = x_2, y = 0L, pi = bernoulli(0L, x_2))) -df$y <- as.factor(df$y) - -# PLOTS ------------------------------------------------------------------------ - -p_1 <- ggplot2::ggplot(data.frame(x_1, y), aes(x = x_1, y = y)) + - geom_line(size = 1.2) + - xlab(expression(yf(x))) + - ylab(expression(L(y, f(x)))) - -p_1 <- p_1 + - ggplot2::annotate( - "text", - x = 2L, - y = 2L, - label = bquote(L(y, f(x)) ~ "=" ~ ln(1 + exp(-yf(x)))), - size = 7L) - -p_1 <- p_1 + theme_minimal() -p_1 <- p_1 + theme(text = element_text(size = 20L)) - -ggplot2::ggsave("../figure/plot_bernoulli_plusmin_encoding.png", p_1) - -p_2 <- ggplot2::ggplot(data = df, aes(x = x, y = pi, color = y)) + - geom_line(size = 1.2) + - xlab(expression(pi(x))) + - ylab(expression(L(y, pi(x)))) + - theme_minimal() + - theme(text = element_text(size = 20L)) + - scale_color_viridis_d(end = 0.9) - -ggplot2::ggsave( - "../figure/plot_bernoulli_prob.png", - p_2, - height = 4L, - width = 10L) diff --git a/slides/advriskmin/rsrc/make_loss_overview_classif_plot.R b/slides/advriskmin/rsrc/make_loss_overview_classif_plot.R deleted file mode 100644 index 32c2f950..00000000 --- a/slides/advriskmin/rsrc/make_loss_overview_classif_plot.R +++ /dev/null @@ -1,58 +0,0 @@ -# ------------------------------------------------------------------------------ -# FIG: LOSSES OVERVIEW (CLASSIF LOSSES) -# ------------------------------------------------------------------------------ - -library(ggplot2) - -# DATA ------------------------------------------------------------------------- - -x <- seq(-4L, 4L, length.out = 800L) - -hinge <- ifelse(x < 1L, 1L - x, 0L) -hinge_sq <- ifelse(x < 1L, (1L - x)^2, 0L) -sq_scores <- (1 - x)^2 -exp <- exp(-x) -zero_one <- as.numeric(x < 0L) - -df <- tidyr::gather( - data.frame(x, hinge, hinge_sq, sq_scores, exp, zero_one), - "loss", - "value", - -x) - -df$aux <- as.factor(ifelse(df$loss == "sq_scores", 1L, 0L)) - -# PLOTS ------------------------------------------------------------------------ - -p <- ggplot2::ggplot(df, aes(x = x, y = value, color = loss, linetype = aux)) + - ggplot2::geom_line(size = 1.1) + - ggplot2::scale_color_viridis_d( - end = 0.9, - name = "", - labels = c( - "Exponential", - "Hinge", - "Squared hinge", - "Squared (scores)", - "0-1")) + - ggplot2::guides(color = guide_legend(ncol = 2), linetype = FALSE) + - ggplot2::ylim(c(0L, 4L)) + - ggplot2::scale_x_continuous(breaks = seq(-4L, 4L)) + - ggplot2::xlab(expression(yf(x))) + - ggplot2::ylab(expression(L(y, f(x)))) + - ggplot2::theme_minimal() + - ggplot2::theme( - text = element_text(size = 20L), - legend.position = "bottom") - -ggplot2::ggsave( - "../figure/plot_loss_overview_classif.png", - p, - width = 6L, - height = 4L) - -ggplot2::ggsave( - "../figure/plot_loss_overview_classif_2.png", - p, - width = 5L, - height = 3.5L) diff --git a/slides/advriskmin/rsrc/overview_classif.R b/slides/advriskmin/rsrc/overview_classif.R new file mode 100644 index 00000000..cae85668 --- /dev/null +++ b/slides/advriskmin/rsrc/overview_classif.R @@ -0,0 +1,51 @@ +# ------------------------------------------------------------------------------ +# classification further losses + +# FIG: overview losses (hinge, squared scores, 0-1, squared hinge, exponential) +# ------------------------------------------------------------------------------ + +library(ggplot2) +library(tidyr) + +# DATA ------------------------------------------------------------------------- + +x <- seq(-4, 4, length.out = 800) + +hinge <- ifelse(x < 1, 1 - x, 0) +hinge_sq <- ifelse(x < 1, (1 - x)^2, 0) +sq_scores <- (1 - x)^2 +exp <- exp(-x) +zero_one <- as.numeric(x < 0) + +df <- gather( + data.frame(x, hinge, hinge_sq, sq_scores, exp, zero_one), + "loss", + "value", + -x) + +df$aux <- as.factor(ifelse(df$loss == "sq_scores", 1, 0)) + +# PLOTS ------------------------------------------------------------------------ + +p <- ggplot(df, aes(x = x, y = value, color = loss, linetype = aux)) + + geom_line(size = 1.1) + + scale_color_viridis_d( + end = 0.9, + name = "", + labels = c( + "Exponential", + "Hinge", + "Squared hinge", + "Squared (scores)", + "0-1")) + + guides(color = guide_legend(ncol = 2), linetype = FALSE) + + ylim(c(0, 4)) + + scale_x_continuous(breaks = seq(-4, 4)) + + xlab(expression(yf)) + + ylab(expression(L(y, f))) + + theme_minimal() + + theme( + text = element_text(size = 20), + legend.position = "bottom") + +ggsave("../figure/overview_classif.png", p, width = 6, height = 4) diff --git a/slides/advriskmin/rsrc/make_loss_squared_scores_plot.R b/slides/advriskmin/rsrc/squared_scores.R similarity index 52% rename from slides/advriskmin/rsrc/make_loss_squared_scores_plot.R rename to slides/advriskmin/rsrc/squared_scores.R index 778941a1..bbfac23e 100644 --- a/slides/advriskmin/rsrc/make_loss_squared_scores_plot.R +++ b/slides/advriskmin/rsrc/squared_scores.R @@ -1,27 +1,25 @@ -# ------------------------------------------------------------------------------ -# FIG: SQUARED LOSS ON SCORES -# ------------------------------------------------------------------------------ - -library(ggplot2) - -# DATA ------------------------------------------------------------------------- - -x <- seq(-4L, 4L, by = 0.01) -y <- (1 - x)^2 - -# PLOTS ------------------------------------------------------------------------ - -p <- ggplot2::ggplot(data.frame(x, y), aes(x = x, y = y)) + - geom_line(size = 1.2) + - scale_x_continuous(breaks = seq(-4L, 4L)) + - xlab(expression(yf(x))) + - ylab(expression(L(y, f(x)))) + - theme_minimal() + - theme(text = element_text(size = 30L)) - -ggplot2::ggsave( - "../figure/plot_loss_squared_scores.png", - p, - height = 4L, - width = 12L) - +# ------------------------------------------------------------------------------ +# classification further losses + +# FIG: squared loss on scores +# ------------------------------------------------------------------------------ + +library(ggplot2) + +# DATA ------------------------------------------------------------------------- + +x <- seq(-4, 4, by = 0.01) +y <- (1 - x)^2 + +# PLOTS ------------------------------------------------------------------------ + +p <- ggplot(data.frame(x, y), aes(x = x, y = y)) + + geom_line(size = 1.2) + + scale_x_continuous(breaks = seq(-4, 4)) + + xlab(expression(yf)) + + ylab(expression(L(y, f))) + + theme_minimal() + + theme(text = element_text(size = 30)) + +ggsave("../figure/squared_scores.png", p, height = 4, width = 12) + diff --git a/slides/advriskmin/rsrc/make_loss_zero_one_plot.R b/slides/advriskmin/rsrc/zero_one.R similarity index 55% rename from slides/advriskmin/rsrc/make_loss_zero_one_plot.R rename to slides/advriskmin/rsrc/zero_one.R index e58f6d8d..51bd647b 100644 --- a/slides/advriskmin/rsrc/make_loss_zero_one_plot.R +++ b/slides/advriskmin/rsrc/zero_one.R @@ -1,23 +1,25 @@ -# ------------------------------------------------------------------------------ -# FIG: 0-1 LOSS -# ------------------------------------------------------------------------------ - -library(ggplot2) - -# DATA ------------------------------------------------------------------------- - -x <- seq(-2L, 2L, by = 0.01) -y <- as.numeric(x < 0L) - -# PLOTS ------------------------------------------------------------------------ - -p <- ggplot2::ggplot(data.frame(x, y), aes(x = x, y = y)) + - geom_line(size = 1.2) + - xlab(expression(yf(x))) + - ylab(expression(L(y, f(x)))) - -p <- p + theme_minimal() -p <- p + theme(text = element_text(size = 20L)) - -ggplot2::ggsave("../figure/plot_loss_01.png", p, height = 4L, width = 10L) - +# ------------------------------------------------------------------------------ +# classification 01 + +# FIG: 0-1 Loss +# ------------------------------------------------------------------------------ + +library(ggplot2) + +# DATA ------------------------------------------------------------------------- + +x <- seq(-2, 2, by = 0.01) +y <- as.numeric(x < 0) + +# PLOTS ------------------------------------------------------------------------ + +p <- ggplot(data.frame(x, y), aes(x = x, y = y)) + + geom_line(size = 1.2) + + xlab(expression(yf)) + + ylab(expression(L(y, f))) + +p <- p + theme_minimal() +p <- p + theme(text = element_text(size = 20)) + +ggsave("../figure/zero_one.png", p, height = 4, width = 9) + diff --git a/slides/advriskmin/slides-advriskmin-classification-01.tex b/slides/advriskmin/slides-advriskmin-classification-01.tex index 717228eb..19e2b43f 100644 --- a/slides/advriskmin/slides-advriskmin-classification-01.tex +++ b/slides/advriskmin/slides-advriskmin-classification-01.tex @@ -20,7 +20,7 @@ }{% Lecture title 0-1-Loss }{% Relative path to title page image: Can be empty but must not start with slides/ - figure/plot_loss_01.png + figure/zero_one.png }{ \item Derive the risk minimizer of the 0-1-loss \item Derive the optimal constant model for the 0-1-loss @@ -29,17 +29,17 @@ \begin{vbframe}{0-1-Loss} \begin{itemize} - \item Let us first consider a discrete classifier $\hx: \Xspace \to \Yspace$. - \item The most natural choice for $\Lhxy$ is the 0-1-loss + \item Let us first consider a discrete classifier $h: \Xspace \to \Yspace$. + \item The most natural choice for $\Lhy$ is the 0-1-loss \vspace*{-0.2cm} $$ - \Lhxy = \mathds{1}_{\{y \ne \hx\}} = - \footnotesize \begin{cases} 1 \quad \text{ if } y \ne \hx \\ 0 \quad \text{ if } y = \hx \end{cases} + \Lhy = \mathds{1}_{\{y \ne h\}} = + \footnotesize \begin{cases} 1 \quad \text{ if } y \ne h \\ 0 \quad \text{ if } y = h \end{cases} $$ - \item For the binary case ($g = 2$) we can express the 0-1-loss for a scoring classifier $\fx$ based on the margin $\nu := y\fx$ + \item For the binary case ($g = 2$) we can express the 0-1-loss for a scoring classifier $f$ based on the margin $\nu := yf$ \vspace*{-0.2cm} $$ - \Lxy = \mathds{1}_{\{\nu < 0\}} = \mathds{1}_{\{y\fx < 0\}}. + \Lyf = \mathds{1}_{\{\nu < 0\}} = \mathds{1}_{\{yf < 0\}}. $$ % and for a probabilistic classifier $\Lxy = \mathds{1}_{\{\pix \ge 0.5 \}}$. \item Analytic properties: Not continuous, even for linear $f$ the optimization problem is NP-hard and close to intractable. @@ -47,7 +47,7 @@ \begin{center} % \includegraphics[width = 11cm ]{figure_man/0-1-loss.png} \\ -\includegraphics[width = 0.5\textwidth]{figure/plot_loss_01.png} +\includegraphics[width = 0.5\textwidth]{figure/zero_one.png} \end{center} \end{vbframe} @@ -61,7 +61,7 @@ \vspace*{-0.5cm} \begin{eqnarray*} - \riskf & = & \Exy\left[\Lxy\right] = \E_x \left[ \E_{y|x} [ L(y, \fx) ] \right] \\ + \riskf & = & \Exy\left[\Lxy\right] = \E_x \left[ \E_{y|x} [ \Lxy ] \right] \\ & = & \E_x \left[\sum_{k \in \Yspace} L(k, \fx) \P(y = k~|~ \xv)\right]\,, % & = & E_x \sum_{k \in \Yspace} L(k, \fx) \pikx, \end{eqnarray*} diff --git a/slides/advriskmin/slides-advriskmin-classification-bernoulli.tex b/slides/advriskmin/slides-advriskmin-classification-bernoulli.tex index c608d72a..4fa1aba3 100644 --- a/slides/advriskmin/slides-advriskmin-classification-bernoulli.tex +++ b/slides/advriskmin/slides-advriskmin-classification-bernoulli.tex @@ -23,7 +23,7 @@ }{% Lecture title Bernoulli Loss }{% Relative path to title page image: Can be empty but must not start with slides/ - figure/plot_bernoulli_prob.png + figure/bernoulli_prob.png }{ \item Know the Bernoulli loss and related losses (log-loss, logistic loss, Binomial loss) \item Derive the risk minimizer @@ -35,8 +35,8 @@ \vspace*{-0.5cm} \begin{eqnarray*} - L(y, \fx) &=& \log(1+\exp(-y \cdot \fx)) \quad \text{for } y \in \setmp\\ - L(y, \fx) &=& - y \cdot \fx + \log(1 + \exp(\fx)) \quad \text{for } y \in \setzo + \Lyf &=& \log(1+\exp(-y \cdot f)) \quad \text{for } y \in \setmp\\ + \Lyf &=& - y \cdot f + \log(1 + \exp(f)) \quad \text{for } y \in \setzo \end{eqnarray*} %Note that the expression $L(y, \fx) = \log(1 + \exp(-y \cdot \fx))$ for $y \in \setmp$ can be derived from the typical log-loss for $y \in \setzo$ %: @@ -60,7 +60,7 @@ \vspace{0.2cm} \begin{center} % \includegraphics[width = 9cm ]{figure_man/bernoulli.png} \\ -\includegraphics[width = 8cm ]{figure/plot_bernoulli_plusmin_encoding.png} +\includegraphics[width = 8cm]{figure/bernoulli_margin.png} \end{center} \end{vbframe} @@ -70,15 +70,18 @@ \begin{vbframe}{Bernoulli loss on probabilities} -If scores are transformed into probabilities by the logistic function $\pix = \left(1 + \exp(- \fx)\right)^{-1}$ (or equivalently if $f(x) = \log\left(\frac{\pix}{1 - \pix}\right)$ are the log-odds of $\pix$), we arrive at another equivalent formulation of the loss, where $y$ is again encoded as $\setzo$: +If scores are transformed into probabilities by the logistic function $\pi = \left(1 + \exp(-f)\right)^{-1}$ (or equivalently if $f = \log\left(\frac{\pi}{1 - \pi}\right)$ are the log-odds of $\pi$), we arrive at another equivalent formulation of the loss, where $y$ is again encoded as $\setzo$: $$ - L(y, \pix) = - y \log \left(\pix\right) - (1 - y) \log \left(1 - \pix\right). + L(y, \pi) = - y \log \left(\pi\right) - (1 - y) \log \left(1 - \pi\right). $$ \begin{center} % \includegraphics[width = 10cm ]{figure_man/bernoulli-loss.png} \\ -\includegraphics[width = 10cm ]{figure/plot_bernoulli_prob.png} +\begin{figure} + \subfloat{\includegraphics[width=0.5\textwidth]{figure/bernoulli_prob.png}} + \subfloat{\includegraphics[width=0.5\textwidth]{figure/logistic.png}}\\ +\end{figure} \end{center} \end{vbframe} @@ -134,36 +137,39 @@ \framebreak -The risk minimizer for the Bernoulli loss defined on $y \in \{-1, 1\}$ and scores $\fx$ is the point-wise log-odds: +The risk minimizer for the Bernoulli loss defined on $y \in \{-1, 1\}$ and scores $\fx$ is the point-wise log-odds, i.e. the logit function (inverse of logistic function) of $p(\xv) = \P(y~|~\xv = \xv)$: -\begin{eqnarray*} -\fxbayes &=& \log \biggl(\frac{\P(y~|~\xv = \xv)}{1-\P(y~|~\xv = \xv)}\biggr). -\end{eqnarray*} +\begin{minipage}{0.3\textwidth} + \centering + {$\fxbayes = \log (\frac{p(\xv)}{1-p(\xv)})$} +\end{minipage} +\hspace{-.03\textwidth} +\begin{minipage}{0.7\textwidth} + \centering + \includegraphics[width=0.7\textwidth]{figure/logistic_inverse.png} +\end{minipage} The function is undefined when $P(y~|~\xv = \xv) = 1$ or $P(y~|~\xv = \xv) = 0$, but predicts a smooth curve which grows when $P(y~|~\xv = \xv)$ increases and equals $0$ when $P(y~|~\xv = \xv) = 0.5$. -\lz +\framebreak \textbf{Proof: } As before we minimize - \begin{eqnarray*} \riskf &=& \E_x \left[L(1, \fx) \cdot \eta(\xv) + L(-1, \fx) \cdot (1 - \eta(\xv)) \right] \\ &=& \E_x \left[ \log(1 + \exp(- \fx)) \eta(\xv)+ \log(1 + \exp(\fx)) (1 - \eta(\xv)) \right] \end{eqnarray*} -\framebreak - For a fixed $\xv$ we compute the point-wise optimal value $c$ by setting the derivative to $0$: - \begin{footnotesize} \begin{eqnarray*} \frac{\partial }{\partial c} \log(1 + \exp(-c)) \eta(\xv)+ \log(1 + \exp(c)) (1 - \eta(\xv)) &=& 0 \\ - \frac{\exp(-c)}{1 + \exp(-c)} \eta(\xv) + \frac{\exp(c)}{1 + \exp(c)} (1 - \eta(\xv)) &=& 0 \\ - - \frac{\exp(-c)}{1 + \exp(-c)} \eta(\xv) + \frac{1}{1 + \exp(- c)} S(1 - \eta(\xv)) &=& 0\\ + % - \frac{\exp(-c)}{1 + \exp(-c)} \eta(\xv) + \frac{1}{1 + \exp(- c)} (1 - \eta(\xv)) &=& 0\\ % &=& - \frac{\exp(-c)}{1 + \exp(-c)} p + \frac{1}{1 + \exp(-c)} - \frac{1}{1 + \exp(-c)} p \\ + - \frac{\exp(-c) \eta(\xv) - 1 + \eta(\xv)}{1 + \exp(-c)} &=& 0 \\ - \eta(\xv) + \frac{1}{1 + \exp(-c)} &=& 0\\ - \eta(\xv) &=& \frac{1}{1 + \exp(-c)} \\ + % \eta(\xv) &=& \frac{1}{1 + \exp(-c)} \\ c &=& \log\left(\frac{\eta(\xv)}{1 - \eta(\xv)}\right) \end{eqnarray*} \end{footnotesize} @@ -205,10 +211,10 @@ % L(y, \fx) &=& - y \cdot \fx + \log(1 + \exp(\fx)) \quad \text{for } y \in \setzo %\end{eqnarray*} -\begin{eqnarray*} L(y, \fx) &=& \log(1+\exp(-y\fx)) \quad \text{for } y \in \setmp \\ -\ L(y, \fx) &=& - y \cdot \fx + \log(1 + \exp(\fx)) \quad \text{for } y \in \setzo \\ -L(y, \pix) &=& - y \log \left(\pix\right) - (1 - y) \log \left(1 - \pix\right) \quad \text{for } y \in \setzo \\ -L(y, \pix) &=& - \frac{1 + y}{2} \log\left(\pix\right) - \frac{1 - y}{2} \log\left(1 - \pix\right) \quad \text{for } y \in \setmp \end{eqnarray*} +\begin{eqnarray*} \Lyf &=& \log(1+\exp(-yf)) \quad \text{for } y \in \setmp \\ +\Lyf &=& - y \cdot f + \log(1 + \exp(f)) \quad \text{for } y \in \setzo \\ +\Lpiy &=& - y \log \left(\pi\right) - (1 - y) \log \left(1 - \pi\right) \quad \text{for } y \in \setzo \\ +\Lpiy &=& - \frac{1 + y}{2} \log\left(\pi\right) - \frac{1 - y}{2} \log\left(1 - \pi\right) \quad \text{for } y \in \setmp \end{eqnarray*} \lz diff --git a/slides/advriskmin/slides-advriskmin-classification-brier.tex b/slides/advriskmin/slides-advriskmin-classification-brier.tex index 0a5b54fe..e88556ec 100644 --- a/slides/advriskmin/slides-advriskmin-classification-brier.tex +++ b/slides/advriskmin/slides-advriskmin-classification-brier.tex @@ -22,12 +22,12 @@ }{% Lecture title Brier Score }{% Relative path to title page image: Can be empty but must not start with slides/ - figure/plot_brier.png + figure/brier.png }{ \item Know the Brier score \item Derive the risk minimizer \item Derive the optimal constant model - \item Understand the connection between Brier score and Gini splitting + % \item Understand the connection between Brier score and Gini splitting } % \begin{vbframe}{Classification Losses: (Naive) L2-Loss} @@ -71,17 +71,17 @@ \begin{vbframe}{Brier Score} -The binary Brier score is defined on probabilities $\pix \in [0, 1]$ and 0-1-encoded labels $y \in \{0, 1\}$ and measures their squared distance ($L2$ loss on probabilities). +The binary Brier score is defined on probabilities $\pi \in [0, 1]$ and 0-1-encoded labels $y \in \{0, 1\}$ and measures their squared distance ($L2$ loss on probabilities). \begin{eqnarray*} -L\left(y, \pix\right) &=& (\pix - y)^2 +\Lpiy &=& (\pi - y)^2 \end{eqnarray*} As the Brier score is a proper scoring rule, it can be used for calibration. Note that is is not convex on probabilities anymore. %\vspace{0.2cm} \begin{center} -\includegraphics[width = 0.8\textwidth]{figure/plot_brier.png} +\includegraphics[width = 0.55\textwidth]{figure/brier.png} \end{center} @@ -92,7 +92,7 @@ The risk minimizer for the (binary) Brier score is \begin{eqnarray*} -\pixbayes &=& \eta(\xv) = \P(y~|~\xv = \xv), +\pixbayes = \eta(\xv) = \P(y~|~\xv = \xv), \end{eqnarray*} which means that the Brier score will reach its minimum if the prediction equals the \enquote{true} probability of the outcome. @@ -114,8 +114,9 @@ \vspace*{-0.3cm} \begin{eqnarray*} - && \argmin_c L(1, c) \eta(\xv) + L(0, c) (1 - \eta(\xv)) \\ + && \argmin_c \quad L(1, c) \eta(\xv) + L(0, c) (1 - \eta(\xv)) \\ &=& \argmin_c \quad (c - 1)^2 \eta(\xv) + c^2 (1 - \eta(\xv))\\ + &=& \argmin_c \quad (c^2 -2c\eta(\xv) + \eta(\xv)^2)- \eta(\xv)^2 + \eta(\xv) \\ &=& \argmin_c \quad (c - \eta(\xv))^2. \end{eqnarray*} diff --git a/slides/advriskmin/slides-advriskmin-classification-deepdive.tex b/slides/advriskmin/slides-advriskmin-classification-deepdive.tex index ff13f89b..d569b6b7 100644 --- a/slides/advriskmin/slides-advriskmin-classification-deepdive.tex +++ b/slides/advriskmin/slides-advriskmin-classification-deepdive.tex @@ -22,7 +22,7 @@ }{% Lecture title Optimal constant model for the empirical log loss risk (Deep-Dive) }{% Relative path to title page image: Can be empty but must not start with slides/ - figure/plot_bernoulli_prob.png + figure/bernoulli_prob.png }{ \item Derive the optimal constant model for the binary empirical log loss risk \item Derive the optimal constant model for the empirical multiclass log loss risk diff --git a/slides/advriskmin/slides-advriskmin-classification-furtherlosses.tex b/slides/advriskmin/slides-advriskmin-classification-furtherlosses.tex index 138d1807..96ec64fa 100644 --- a/slides/advriskmin/slides-advriskmin-classification-furtherlosses.tex +++ b/slides/advriskmin/slides-advriskmin-classification-furtherlosses.tex @@ -23,7 +23,7 @@ }{% Lecture title Advanced Classification Losses }{% Relative path to title page image: Can be empty but must not start with slides/ - figure/plot_loss_overview_classif.png + figure/overview_classif.png }{ \item Know the (squared) hinge loss \item Know the $L2$ loss defined on scores @@ -38,7 +38,7 @@ properties ill-suited to direct optimization. \item The \textbf{hinge loss} is a continuous relaxation that acts as a convex upper bound on the 0-1-loss (for $y \in \setmp$): - $$\Lxy = \max \{ 0, 1 - y\fx \}.$$ + $$\Lyf = \max \{ 0, 1 - yf \}.$$ \item Note that the hinge loss only equals zero for a margin $\geq 1$, encouraging confident (correct) predictions. % \item A squared version exists for putting a sharper penalty on @@ -48,7 +48,7 @@ \end{itemize} \begin{center} -\includegraphics[width = 0.7\textwidth]{figure/plot_loss_hinge.png} +\includegraphics[width = 0.7\textwidth]{figure/hinge.png} \end{center} \end{vbframe} @@ -58,15 +58,15 @@ \begin{itemize} \item We can also specify a \textbf{squared} version for the hinge loss: - $$\Lxy = \max \{ 0, (1 - y\fx)\}^2.$$ - \item The $L2$ form punishes margins $y \fx \in (0, 1)$ less severely but puts + $$\Lyf = \max \{ 0, (1 - yf)\}^2.$$ + \item The $L2$ form punishes margins $yf \in (0, 1)$ less severely but puts a high penalty on more confidently wrong predictions. \item Therefore, it is smoother yet more outlier-sensitive than the non-squared hinge loss. \end{itemize} \begin{center} -\includegraphics[width = 0.7\textwidth]{figure/plot_loss_hinge_squared.png} +\includegraphics[width = 0.7\textwidth]{figure/hinge_squared.png} \end{center} \end{vbframe} @@ -81,15 +81,15 @@ \textbf{squared loss on classification scores} (again, $y \in \setmp$, using that $y^2 \equiv 1$): \begin{eqnarray*} - \Lxy = &(y - \fx)^2 = y^2 - 2y\fx + (\fx)^2 =\\ - = &1 - 2y\fx + (y\fx)^2 = (1 - y\fx)^2 + \Lyf = &(y - f)^2 = y^2 - 2yf + f^2 =\\ + = &1 - 2yf + (yf)^2 = (1 - yf)^2 \end{eqnarray*} - \item This loss behaves just like the squared hinge loss for $y \fx < 1$, but - is zero only for $y \fx = 1$ and actually increases again for larger margins (which is in general not desirable!) + \item This loss behaves just like the squared hinge loss for $yf < 1$, but + is zero only for $yf = 1$ and actually increases again for larger margins (which is in general not desirable!) \end{itemize} \begin{center} -\includegraphics[width = 0.7\textwidth]{figure/plot_loss_squared_scores.png} +\includegraphics[width = 0.7\textwidth]{figure/squared_scores.png} \end{center} \end{vbframe} @@ -101,7 +101,7 @@ Another possible choice for a (binary) loss function that is a smooth approximation to the 0-1-loss is the \textbf{exponential loss}: \begin{itemize} -\item $\Lxy = \exp(-y\fx)$, used in AdaBoost. +\item $\Lyf = \exp(-yf)$, used in AdaBoost. \item Convex, differentiable (thus easier to optimize than 0-1-loss). \item The loss increases exponentially for wrong predictions with high confidence; if the prediction is right with a small confidence only, there, loss is still positive. \item No closed-form analytic solution to (empirical) risk minimization. @@ -109,7 +109,7 @@ \begin{figure} -\includegraphics[width = 0.8\textwidth]{figure/plot_loss_exponential.png} +\includegraphics[width = 0.8\textwidth]{figure/exponential.png} \end{figure} \end{vbframe} diff --git a/slides/advriskmin/slides-advriskmin-logreg-deepdive.tex b/slides/advriskmin/slides-advriskmin-logreg-deepdive.tex index 9aaebaa6..a21f0180 100644 --- a/slides/advriskmin/slides-advriskmin-logreg-deepdive.tex +++ b/slides/advriskmin/slides-advriskmin-logreg-deepdive.tex @@ -22,7 +22,7 @@ }{% Lecture title Logistic regression (Deep-Dive) }{% Relative path to title page image: Can be empty but must not start with slides/ - figure/plot_bernoulli_prob.png + figure/bernoulli_prob.png }{ \item Derive the gradient of the logistic regression \item Derive the Hessian of the logistic regression diff --git a/slides/advriskmin/slides-advriskmin-losses-properties.tex b/slides/advriskmin/slides-advriskmin-losses-properties.tex index 82997e6e..31d45e62 100644 --- a/slides/advriskmin/slides-advriskmin-losses-properties.tex +++ b/slides/advriskmin/slides-advriskmin-losses-properties.tex @@ -64,7 +64,7 @@ \vfill \begin{minipage}[b]{1\textwidth} - \includegraphics[width=0.75\textwidth]{figure/plot_loss_overview_classif_2} + \includegraphics[width=0.65\textwidth]{figure/overview_classif.png} \tiny \centering %Margin-based losses \end{minipage}% @@ -208,7 +208,7 @@ \vfill \begin{minipage}[c]{0.4\textwidth} - \includegraphics[width=0.9\textwidth]{figure/plot_loss_overview_classif} + \includegraphics[width=0.9\textwidth]{figure/overview_classif.png} \end{minipage}% \begin{minipage}[c]{0.05\textwidth} \phantom{foo} @@ -350,7 +350,7 @@ \phantom{foo} \end{minipage}% \begin{minipage}{0.25\textwidth} - \includegraphics[width=\textwidth]{figure/plot_bernoulli} + \includegraphics[width=\textwidth]{figure/bernoulli.png} \end{minipage}% \begin{itemize}