0

I have the following figure for algorithm pseudocode.

\usepackage{graphicx}
\usepackage{psfrag}
\usepackage{amssymb}

\newcommand{\argmin}{\mathop{\mathrm{argmin}}}
\newcommand{\infl}{\eta}
\newcommand{\Ind}{\mathrm{I}}

\date{June 2021}

\begin{document}

\begin{figure}[bth]
  \begin{center}
    \begin{center}
      \fbox{\parbox{11.4cm}{
          \begin{itemize} 
          \item[] \textbf{Input:}  Data set ${\bf D}= \{ ({\bf x}_1,y_1), ({\bf x}_2,y_), \ldots,
            ({\bf x}_m,y_m) \};$
          \item[] \hspace {1cm} Base learning algorithm $ E $ ;
          \item[] \hspace {1cm} Number of learning rounds $T$;
          \item[]  \textbf{Process:}
            \begin{enumerate}
            \item $D_1(x) = 1/m$  \textit{   \# initialize the weight distribution}
            \item \textbf{\textit{for}} $t = 1, \ldots ,T;$ 
            \item $ h_t = E(D,D_t); $ \textit{\# train a classifier $h_t$ from $D$ under distribution $D_t$}
            \item $\epsilon_t = P_{{\bf x}\sim D_t} h_t{\bf (x)} \neq f({\bf (x)});$ \textit{evaluate the error of $h_t$}
            \item \textbf{\textit{if}} $\epsilon_t > 0.5 $  \textbf{\textit{then break}}
            \item $\alpha_t = \frac{1}{2} \ln\left ( \frac{1 - \epsilon_t}{\epsilon_t} \right ); $ \textit{\# determine the weight of $h_t$}
            \item $D_{t+1}{\bf (x)} = \frac{D_t {\bf (x)}}{Z_t}  \text{ x } \begin{cases}
 & \text{ exp } (-\alpha_t)= \text{ if } h_t{\bf (x)} = f{\bf (x)}\\ 
 &  \text{ exp } (\alpha_t) =  \text{ if } h_t{\bf (x)} \neq f{\bf (x)}
\end{cases} $  \\

\hspace {1.2cm} $ = \frac{D_t{\bf (x)} \text {exp}(-\alpha_tf{\bf (x)}h_t{\bf (x)})}{Z_t}$  \\
\textit{\# update the distribution, where $Z_t$ is a normalization factor which  enables $D_{t+1}$ to be a distribution.}
       \item \textbf{\textit{end}}            
            \end{enumerate}
            
          \item[]{\bf Output:}
          $
H{\bf (x)} = sign\left ( \sum_{t=1}^{T} \alpha_th_t{\bf (x)} \right ) $
          \end{itemize}
          }}
    \end{center}
  \end{center} 
  \caption[]{The AdaBoost algorithm. \label{fig:ABALG}}
\end{figure} 

\end{document}

Output: enter image description here

Now I want to put this into one slide I'm preparing: \begin{frame}{AdaBoost Algorithm} %code above \end{frame}

Slide: enter image description here

I nee a way to rescale this so that the last two lines will appear (I can ignore figure title).

1
  • 1
    You could collapse the first three lines in one after the first step...
    – Rmano
    Jun 8, 2021 at 18:53

1 Answer 1

2

Using \scalebox for scale of 80%

\documentclass[11pt]{beamer}
\usetheme{Warsaw}
\usepackage{psfrag}
\usepackage{amssymb}

\newcommand{\argmin}{\mathop{\mathrm{argmin}}}
\newcommand{\infl}{\eta}
\newcommand{\Ind}{\mathrm{I}}
\date{June 2021}
\begin{document}

\begin{frame}
\frametitle{AdaBoost algorithm}
\begin{figure}
\scalebox{0.8}{%
\fbox{\parbox{11.4cm}{%
\begin{itemize} 
          \item[] \textbf{Input:}  Data set ${\bf D}= \{ ({\bf x}_1,y_1), ({\bf x}_2,y_), \ldots,
            ({\bf x}_m,y_m) \};$
          \item[] \hspace {1cm} Base learning algorithm $ E $ ;
          \item[] \hspace {1cm} Number of learning rounds $T$;
          \item[]  \textbf{Process:}
            \begin{enumerate}
            \item $D_1(x) = 1/m$  \textit{   \# initialize the weight distribution}
            \item \textbf{\textit{for}} $t = 1, \ldots ,T;$ 
            \item $ h_t = E(D,D_t); $ \textit{\# train a classifier $h_t$ from $D$ under distribution $D_t$}
            \item $\epsilon_t = P_{{\bf x}\sim D_t} h_t{\bf (x)} \neq f({\bf (x)});$ \textit{evaluate the error of $h_t$}
            \item \textbf{\textit{if}} $\epsilon_t > 0.5 $  \textbf{\textit{then break}}
            \item $\alpha_t = \frac{1}{2} \ln\left ( \frac{1 - \epsilon_t}{\epsilon_t} \right ); $ \textit{\# determine the weight of $h_t$}
            \item $D_{t+1}{\bf (x)} = \frac{D_t {\bf (x)}}{Z_t}  \text{ x } \begin{cases}
 & \text{ exp } (-\alpha_t)= \text{ if } h_t{\bf (x)} = f{\bf (x)}\\ 
 &  \text{ exp } (\alpha_t) =  \text{ if } h_t{\bf (x)} \neq f{\bf (x)}
\end{cases} $  \\

\hspace {1.2cm} $ = \frac{D_t{\bf (x)} \text {exp}(-\alpha_tf{\bf (x)}h_t{\bf (x)})}{Z_t}$  \\
\textit{\# update the distribution, where $Z_t$ is a normalization factor which  enables $D_{t+1}$ to be a distribution.}
       \item \textbf{\textit{end}}            
            \end{enumerate}
            
          \item[]{\bf Output:}
          $
H{\bf (x)} = sign\left ( \sum_{t=1}^{T} \alpha_th_t{\bf (x)} \right ) $
          \end{itemize}
          }}}
  \caption[]{The AdaBoost algorithm. \label{fig:ABALG}}
\end{figure} 
\end{frame}
\end{document}

result with scalebox

1
  • Ah, yesss! Thank you.
    – arilwan
    Jun 8, 2021 at 22:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .