我正在完成我的论文。然而,论文中的最后一个障碍是算法环境中的整数 Z 符号。当我使用\mathbb{Z}
它时,它会返回错误:! LaTeX Error: \mathbb allowed only in math mode.
以下是算法示例:
\begin{algorithm}
\begin{algorithmic}[1]
\For{$b\gets 1, B$}
\State (a) Draw a bootstrap sample \mathbb{Z}$^*$ of size $N$ from the training data.
\State (b) Grow a random forest tree $T_b$ to the bootstrapped data, by recursively repeating the following steps for each terminal node of
the tree, until the minimum node size $n_{min}$ is reached.
\State\indent (I) \ $\>$ Select $m$ variables at random from the $p$ variables.
\State\indent (II) $\>$ Pick the best variable/split-point among the $m$.
\State\indent (III)$\>$ Split the node into two daughter nodes.
\EndFor
\State Output the ensemble of trees $\{ T_b\}_1^B$
\State Make prediction at new point $x$:
\State Let $\hat{C}_b(x)$ be the class prediction be the class prediction of the $b$th random forest tree. Then $\hat{C}_rf^B(x) = \text{ majority vote }\{ \hat{C}_b(x)_1^B\}$.
\end{algorithmic}
\caption{Random Forest for Classification (RFC) \protect\cite{friedman2001elements}}\label{alg:randomforest}
\end{algorithm}
答案1
因此,将其置于数学模式中:$\mathbb{Z}^*$
\documentclass{article}
\usepackage{algorithm,algpseudocode}
\usepackage{amsmath,amsfonts}
\begin{document}
\begin{algorithm}
\begin{algorithmic}[1]
\For{$b\gets 1, B$}
\State (a) Draw a bootstrap sample $\mathbb{Z}^*$ of size $N$ from the training data.
\State (b) Grow a random forest tree $T_b$ to the bootstrapped data, by recursively repeating the following steps for each terminal node of
the tree, until the minimum node size $n_{\mathrm{min}}$ is reached.
\State \indent \makebox[2em][l]{(I) } Select $m$ variables at random from the $p$ variables.
\State \indent \makebox[2em][l]{(II) } Pick the best variable/split-point among the $m$.
\State \indent \makebox[2em][l]{(III)} Split the node into two daughter nodes.
\EndFor
\State Output the ensemble of trees $\{T_b\}_1^B$
\State Make prediction at new point $x$:
\State Let $\hat{C}_b(x)$ be the class prediction be the class prediction of the $b$th random forest tree. Then $\hat{C}_r f^B(x) = \text{majority vote } \{ \hat{C}_b(x)_1^B \}$.
\end{algorithmic}
\caption{Random Forest for Classification (RFC)}
\end{algorithm}
\end{document}