R caret / Confusion matrix
<p>I'd like to display the confusion matrix after a train() of the caret library, but I have some doubts. The "train()" should be on a train set ?(I'm not sure because of the "control" parameter). The "predict()" on the test set ? It seems weird to predict on the whole data set...</p>

<pre><code># df_corpus = Document Term Matrix + 1 column of Cos.code(class which are 203.2.2, 204.3.2 ...)
dataset &lt;- df_corpus
control &lt;- trainControl(method = "repeatedcv", number = 10, repeats = 3)
seed &lt;- 7

metric &lt;- "Accuracy"
preProcess=c("center", "scale")

# Linear Discriminant Analysis
set.seed(seed)
fit.lda &lt;- train(Cos.code~., data=dataset, method="lda", metric=metric,preProc=c("center", "scale"), trControl=control)
ldaClasses &lt;- predict(fit.lda)
cm &lt;- confusionMatrix(data = ldaClasses, dataset$Cos.code)
F1_score(cm$table, "lda")
</code></pre>

<p>Thank you for your help</p>