[Tex/LaTex] Making a space between table headings

tables

I want to replicate the table in this image but without the second column:

enter image description here

However the problem is that I'm unable to find out how to make a horizontal space between each two columns (N=2, N=3 … etc). Also I'm not able to find out how to make a vertical space between the first row and the second row (N=2 and Avg. Pos … etc) because the text is too close to the upperline.

Here is my version and code:

\begin{table}[h]
    \begin{tabular}{@{}lrrrrrr@{}}
        \toprule
        & \multicolumn{2}{c}{N = 2}                                     & \multicolumn{2}{c}{N = 3}                                     & \multicolumn{2}{c}{N = 4}                                      \\  \cline{2-3} \cline{4-5} \cline{6-7} 
        Network Name       & \multicolumn{1}{c}{Avg. Pos.} & \multicolumn{1}{c}{Avg. Neg.} & \multicolumn{1}{c}{Avg. Pos.} & \multicolumn{1}{c}{Avg. Neg.} & \multicolumn{1}{c}{Avg. Pos.} & \multicolumn{1}{c}{Avg. Neg.} \\ \midrule
        X            & 4895                          & 135639                        & 77                            & 109622                        & 5                             & 16360                         \\ 
        Y               & 5426                          & 183685                        & 196                           & 204801                        & 9                             & 39977                         \\ 
        Z & 8959                          & 80669                         & 38                            & 109362                        & 4                             & 43329                         \\ \bottomrule
    \end{tabular}
\end{table}

enter image description here

Best Answer

For first, use \cmidrule(lr){2-3}, note (lr). For details, consult the booktabs manual. For second, use some strut like

\newcommand*{\mystrut}{\rule{0pt}{2.5ex}}

Change 2.5ex as you want.

\documentclass{article}
\usepackage{booktabs}
\newcommand*{\mystrut}{\rule{0pt}{2.5ex}}
\begin{document}
  \begin{table}[h]
    \begin{tabular}{@{}lrrrrrr@{}}
        \toprule
        & \multicolumn{2}{c}{N = 2}                                     & \multicolumn{2}{c}{N = 3}                                     & \multicolumn{2}{c}{N = 4}                                      \\  \cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(lr){6-7}
     \mystrut   Network Name       & \multicolumn{1}{c}{Avg. Pos.} & \multicolumn{1}{c}{Avg. Neg.} & \multicolumn{1}{c}{Avg. Pos.} & \multicolumn{1}{c}{Avg. Neg.} & \multicolumn{1}{c}{Avg. Pos.} & \multicolumn{1}{c}{Avg. Neg.} \\ \midrule
        X            & 4895                          & 135639                        & 77                            & 109622                        & 5                             & 16360                         \\
        Y               & 5426                          & 183685                        & 196                           & 204801                        & 9                             & 39977                         \\
        Z & 8959                          & 80669                         & 38                            & 109362                        & 4                             & 43329                         \\ \bottomrule
    \end{tabular}
\end{table}
\end{document}

enter image description here