Training, validation and test set. How to use the test set in R with LDA()

277 Views Asked by At

I am new in machine learning and have some problems with the final step of my exercise. I have a training, validation and test set. The test set is the set I have to use at the final step, but I am not entirely sure how. First I shall tell what I have been doing.

I am busy with some exercises about fitting different models using lda() and knn(). Eventually from all the models I choose the one which performed the best. It looks like this:

lda.fit = lda(Y~Var1+Var2+Var3+Var4, data=training)

pred = predict(lda.fit, newdata=validation)

Now the part where I am stuck: Pick the best performing model on the validation set, describe it and give the performance of the model on the test set.

So, the model above is my best performing model. I know I have to use the test set to avoid overfitting, but I am not entirely sure where I have to put the test data. Is it like this?

lda.fit2 = lda(Y~Var1+Var2+Var3+Var4, data=validation)

pred = predict(lda.fit2, newdata=test)

This is what I thought the solution is. Is there someone who can give me an confirmation or correct me?