1
$\begingroup$

I have:
training dataset of size 150k.
validation dataset of size 19k.

At each epoch I randomly sample without replacement 10k datapoints for training because I get Out of Mem Errors.

I need to downsample my validation set too. Which of the following methods seem most appropriate:

  • Randomly sampling validation set which is x% of 10k and use the same set across every epoch.
  • Randomly sampling validation set which is x% of 10k at every epoch.
$\endgroup$
2
  • $\begingroup$ Do you really need to sample your validation set of 19k samples? Why so? Do you get OOM errors here, too? $\endgroup$
    – desertnaut
    Commented Nov 11, 2020 at 1:24
  • $\begingroup$ It takes significant amount of time (2x the training time) per epoch if I use 19k samples. $\endgroup$
    – Heisenbug
    Commented Nov 11, 2020 at 1:32

2 Answers 2

1
$\begingroup$

Two main things here:

  • How you should sample

Having a validation set of 19K samples is quite large. It's not bad, but it also means that unless you're dealing with a very complex problem, a reasonable sample out of the 19K should preserve the overall distribution of the 19K.

The way I would handle it is as follows. If you sample 10% of your training set, you should sample 10% of your validation set. That way, the proportions remain the same. You could split both datasets into 10 "groups" and iterate through each "train/validation" pair. With this amount of data, I don't expect huge issues when it comes to how representative your sets would be.

  • Out-of-memory errors

If you need to sample 10K items out of 150K to avoid out-of-memory errors, it might mean that you'd need to lazy load your data as you train, so that sampling isn't necessary anymore. If you don't run out of memory, but it just takes too long to run the validation, I'd indeed sample a small batch. Your validation set estimates the unknown distribution of your problem; whether you have 1K, 2K, or 19K items in that sample, it's still an estimate.

$\endgroup$
0
$\begingroup$

Actually you should never use any sampling techniques on your testing/evaluation data because this could lead to wrong classification results. If your dataset is imbalanced you could perform upsampling or downsampling techniques (like SMOTE) on your training data only. If you want to benchmark your multi-class classification you need to rely on e.g. the confusion matrix, recall, precision and F1 measure. Please keep in mind that the accuracy measure cannot be interpreted if you have too imbalanced data.

$\endgroup$
3
  • $\begingroup$ If you get out of memory errors you could use batch learning... this is usually done if you train on a huge dataset $\endgroup$ Commented Nov 11, 2020 at 11:31
  • 1
    $\begingroup$ You didn't say how your original sample was sampled in the first place. If it was simple random sampling, you can certainly take another random sample in the same ratio of training to test. But, based on your question, that would be the final sample. You didn't describe any goal in doing multi sampling. $\endgroup$ Commented Apr 24, 2022 at 19:34
  • $\begingroup$ Just to echo what @RalphWinters has said. The starting point is you have some data, which you then split into either two or three sets. If you have been given predefined training and test sets, it's best to find out why that is important. $\endgroup$
    – fswings
    Commented Sep 3, 2023 at 22:56

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.