[Tex/LaTex] Problem with table caption

tables

I want to create a table using TeXworks. I could do it using tabular environment, but when I put caption above the table I get an error. The code is as follows. Can anyone please help me solve this problem?

 \begin{center}

    \begin{tabular}{l l l l l l}
        {\caption{Table 1: The coeffcient of determination ($R^2$) for validation set (dataset C) obtained by applying different preprocessing techniques.}}

        {\label{Table 1}}
        \hline

 Trans & Dry & Moisture-1 & Moisture-2 & Moisture-3 & Moisture-4\\

        \hline

Raw & 0.79 & -184.32 & -100.21 &    -53.74 & -13.02\\

MSC & 0.76 & -5.82 & -4.58 & -3.02 & -1.88\\

SNV & 0.75 & -423.19 & -188.19 & -69.23 & -7.95\\

FD & 0.71 & -6.12 & -4.13 & -3.26 & -2.19\\

        \hline

    \end{tabular}
\end(center)

Best Answer

It is good, that the code in the question does not contain vertical lines. That makes the table more professional looking.

I do not want to comment on the remaining issues, you might want to get a good LaTeX book. The table can be set as follows:

\documentclass{article}
\usepackage{booktabs}% nicer horizontal lines
\usepackage{caption}% fix vertical spacing of table captions
\usepackage{siunitx}% align numbers at the decimal point

\begin{document}
\begin{table}
  \centering
  \caption{The coeffcient of determination ($R^2$) for
    validation set (dataset~C) obtained by applying different preprocessing
    techniques.}
  \label{Table 1}
  \begin{tabular}{
    l
    S[table-format=1.2]
    S[table-format=-3.2]
    S[table-format=-3.2]
    S[table-format=-2.2]
    S[table-format=-2.2]
  }
    \toprule
    Trans & {Dry}
    & {Moisture-1} & {Moisture-2} & {Moisture-3} & {Moisture-4}\\
    \midrule
    Raw & 0.79 & -184.32 & -100.21 &    -53.74 & -13.02\\
    MSC & 0.76 & -5.82 & -4.58 & -3.02 & -1.88\\
    SNV & 0.75 & -423.19 & -188.19 & -69.23 & -7.95\\
    FD & 0.71 & -6.12 & -4.13 & -3.26 & -2.19\\
    \bottomrule
  \end{tabular}
\end{table}
\end{document}

Result

Related Question