1

For example, I want to know what is the best k neighbours for my KNN model. It is recommended to have a separate dataset for finding the k with which your model gives the best performance, and then confirm it with test set.

Why would I need to use validation set if I can use for this purpose test set? Can't we just train n models with different k parameter and see which one performed the best using test set to chose the best k?

asked 10 hours ago
4
  • 2
    You shouldn’t use the test set to pick hyperparameters (like k) because the test set is meant to simulate unseen data for final evaluation. If you pick k based on test performance, you’re indirectly training on the test set, which biases your evaluation. Commented 10 hours ago
  • 1
    So this involves that I should treat the test dataset as a dataset that will come after the model is trained and validated? Commented 9 hours ago
  • 2
    Exactly! Think of the test set as new, unseen data that only comes into play after you’ve trained your model and chosen all hyperparameters (like k in KNN) using the training and validation sets. You never look at the test set while tuning your model, because it’s meant to give a realistic estimate of how your model will perform in the real world. Commented 9 hours ago
  • This is not a programming question! why are you even asking this in a programming site? Commented 2 hours ago

1 Answer 1

0

You shouldn't use the test set since its no longer unseen anymore, it is supposed to only be used once at the end to see the true test of how well it generalizes.

Instead validation sets are used to tune k, which will help the model improve, however afterwards you only use the test set once at the end. Hope this helped!

answered 1 hour ago
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.