我想将枚举环境中的文本环绕在表格周围,这是我的实际情况(抱歉包含了太多代码,但我想准确说明枚举环境中的行数):
\subsection{Given the following data set where “Target 2” represent the class attribute,
compute the naive Bayesian classification for the instance $<L,white>$ and $<XS,?>$.}
\begin{table}[h!t]
\centering
\begin{tabular}{ccc}
\toprule
Size & Color & Target2 \\
\midrule
XS & green & Yes \\
L & green & Yes \\
XS & white & No \\
M & black & No \\
XL & green & Yes \\
XS & white & Yes \\
L & black & No \\
M & green & Yes \\
\bottomrule
\end{tabular}
\end{table}
\begin{enumerate}
\item In this case the experience $E$ is made up of $e_{1} = L$ and $e_{2} = white$,
which in Naive Bayes are to be considered as independent, therefore we have:
\begin{align*}
P(yes|E) &= P(L|yes)\cdot P(white|yes) \cdot P(yes) \\
&= \sfrac{1}{5}\times \sfrac{1}{5} \times \sfrac{5}{8} \\
&= 0.025
\end{align*}
\begin{align*}
P(no|E) &= P(L|no) \cdot P(white|no) \cdot P(no) \\
&= \sfrac{1}{3} \times \sfrac{1}{3} times \sfrac{3}{8} \\
&= 0.041
\end{align*}
Then we normalize:
\begin{align*}
P(yes) &= \frac{0.025}{0.066}
\simeq 0.38
\end{align*}
\begin{align*}
P(no) &= \frac{0.041}{0.066}
\simeq 0.62
\end{align*}
As $P(no) > P(yes)$, we label $<L,white>$ as ``no''.
\item Now we have to classify a sample with a missing value. During the testing phase
we simply omit the attribute\footnote{Classification Other Methods, slide 24}:
\begin{align*}
P(yes|XS) &= P(XS|yes) \cdot P(yes) = \sfrac{2}{5} \times \sfrac{5}{8}
= 0.25
\end{align*}
\begin{align*}
P(no|XS) &= P(XS|no) \cdot P(no)
= \sfrac{1}{3} \times \sfrac{3}{8}
= 0.125
\end{align*}
Let us normalize
\begin{align*}
P(yes) &= \sfrac{0.25}{0.375} \simeq 0.7 \\
P(no) &= \sfrac{0.125}{0.375} \simeq 0.3
\end{align*}
Bottom line this sample is classified as ``yes''.
\end{enumerate}
我尝试使用wrapfig
和floatftl
包,但没有成功,在这两种情况下,表格都被移到了列表的末尾。我考虑过使用两种minipage
环境,但我希望文本能够真正环绕表格。
答案1
发布问题有助于完全的我猜,包括加载你需要的所有包
\usepackage{booktabs,xfrac,amsmath}
在这种情况下。我还修复了一些字体问题(针对多字母标识符和尖括号)
在 LaTeX 列表中更改边距有点棘手,但我认为这是你想要的布局
\documentclass{article}
\usepackage{booktabs,xfrac,amsmath}
\begin{document}
\subsection{Given the following data set where “Target 2” represent the class attribute,
compute the naive Bayesian classification for the instance $\langle L,white\rangle$ and $\langle \mathit{XS},?\rangle$.}
\savebox0{%
\begin{tabular}{ccc}
\toprule
Size & Color & Target2 \\
\midrule
XS & green & Yes \\
L & green & Yes \\
XS & white & No \\
M & black & No \\
XL & green & Yes \\
XS & white & Yes \\
L & black & No \\
M & green & Yes \\
\bottomrule
\end{tabular}}
\begin{enumerate}
\makeatletter
\dimen@\wd0
\advance\dimen@2em
\advance\rightmargin-\dimen@
\advance\linewidth-\dimen@
\parshape \@ne \@totalleftmargin \linewidth
\hbox to \textwidth{\hfill\vtop to \z@{\vskip1em \box\z@\vss}}
\item
In this case the experience $E$ is made up of $e_{1} = L$ and $e_{2} = \mathit{white}$,
which in Naive Bayes are to be considered as independent, therefore we have:
\begin{align*}
P(\mathit{yes}|E) &= P(L|\mathit{yes})\cdot P(\mathit{white}|\mathit{yes}) \cdot P(\mathit{yes}) \\
&= \sfrac{1}{5}\times \sfrac{1}{5} \times \sfrac{5}{8} \\
&= 0.025
\end{align*}
\begin{align*}
P(\mathit{no}|E) &= P(L|\mathit{no}) \cdot P(\mathit{white}|\mathit{no}) \cdot P(\mathit{no}) \\
&= \sfrac{1}{3} \times \sfrac{1}{3} \times \sfrac{3}{8} \\
&= 0.041
\end{align*}
\advance\rightmargin\dimen@
\advance\linewidth\dimen@
\parshape \@ne \@totalleftmargin \linewidth
Then we normalize:
\begin{align*}
P(\mathit{yes}) &= \frac{0.025}{0.066}
\simeq 0.38
\end{align*}
\begin{align*}
P(\mathit{no}) &= \frac{0.041}{0.066}
\simeq 0.62
\end{align*}
As $P(\mathit{no}) > P(\mathit{yes})$, we label $\langle L,\mathit{white}\rangle$ as ``no''.
\item Now we have to classify a sample with a missing value. During the testing phase
we simply omit the attribute\footnote{Classification Other Methods, slide 24}:
\begin{align*}
P(\mathit{yes}|\mathit{XS}) &= P(\mathit{XS}|\mathit{yes}) \cdot P(\mathit{yes}) \\
&= \sfrac{2}{5} \times \sfrac{5}{8}\\
&= 0.25
\end{align*}
\begin{align*}
P(\mathit{no}|\mathit{XS}) &= P(\mathit{XS}|\mathit{no}) \cdot P(\mathit{no})\\
&= \sfrac{1}{3} \times \sfrac{3}{8}\\
&= 0.125
\end{align*}
Let us normalize
\begin{align*}
P(\mathit{yes}) &= \sfrac{0.25}{0.375} \simeq 0.7 \\
P(\mathit{no}) &= \sfrac{0.125}{0.375} \simeq 0.3
\end{align*}
Bottom line this sample is classified as ``yes''.
\end{enumerate}
\end{document}