I have a dataset of audio recording of variable length with large std which are heavily imbalanced in terms of total duration per class. So in stratified k-fold cross validation I would like to main the relative total duration statistics for each class but the common stratified sampling methods work using number of examples per class. So how can I achieve duration statistic preserving stratified sampling?
1 Answer
Easiest is to transform the dataset into a set of fixed-length samples - as then the number of instances will again be a good measure of the amount of data. This is often called analysis window in audio machine learning. This has other benefits as well, like making it possible to implement time-shift data augmentation (by letting the windows overlap) and merging predictions over multiple windows. As well as supporting the use of models which expect a fixed-size input.
The other alternative would be to write your own cross-validator splitter, using the logic that you want wrt duration.