For example, if you want to tune hyperparameters of XGboost with 5-fold cross validation, you have to write as following:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">library</span>(xgboost)
<span class="kw">library</span>(Matrix)

<span class="kw">data</span>(agaricus.train, <span class="dt">package =</span> <span class="st">"xgboost"</span>)
dtrain &lt;-<span class="st"> </span><span class="kw"><a href="http://www.rdocumentation.org/packages/xgboost/top