0
$\begingroup$

I want to perform k-fold cross-validation for the setting where I have a training dataset consisting of a sequential time series that is fully benign and a test dataset (also a sequential time series) which contains labeled anomalies.

I already took a look at this post, but as my data is sequential, the answer doesn't work out.

I am especially stuck with the factor that for K-fold cross-validation, you use (k-1)/k parts of your data for training and 1/k parts of your data for testing, however, we can not make that split now as we really want to train the classifier on the benign training data and validate on test data which contains anomalies, so we are not allowed to use data from the test data for training (which would make it an ordinary classification problem).

maybe usefull to point out, is that I want to use k-fold cross-validation specifically to determine the n_neighbors and decision threshold hyperparameters for LOF (LocalOutlierFactor)

$\endgroup$

1 Answer 1

1
$\begingroup$

I don't recommend k-fold for time series data, since you shouldn't be randomizing the inputs and the time series sequence must be preserved. However, you can do your own permutations of the training data (t1,t2,t3), (T2,t3,t4), (T2,t3,t4,t5), and still preserve your anomalies in the test data set.

These answers may also be helpful:

https://stats.stackexchange.com/questions/14099/using-k-fold-cross-validation-for-time-series-model-selection

$\endgroup$

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.