r/BirdNET_Analyzer • u/birdy_nick • Apr 26 '25
Custom classifier overfitting - advice please!
I've been using the birdnet_analyzer.train function to train on a binary classification task (target vs other). In the 'other' category are a diverse range of sounds, some just random segments from audio I know does not contain the target, to species with similar spectral features. The 'other' class outweighs the target by a LOT (~8000 vs 400), because I was getting loads of false positives, so I kept adding more examples to the 'other' class. However, it seems to have made it worse, and the model has collapsed completely (all predictions are now >0.9 for the target, even in completely unrelated audio). So it's back to the drawing board.
The parameters I've played with are:
- bandpass
- upsampling mode (currently 'SMOTE', but no better with 'repeat')
- I'm using the 'mixup' augmentation
- I tried focal loss with default parameters, but that seems to have made it worse.
The AUPRC and AUROC both reach very near 1.0, and testing on unseen audio proves that the model is useless (1.0 or near it for every 3-sec segment I use it on).
Any advice at all? Should I be using specific test data rather than allowing birdnet to split it (0.2 test ratio is the default).
Thanks in advance!
View all comments
Show parent comment
1
u/birdy_nick Apr 27 '25
Thanks for this reply. I'm not entirely sure I understand where you're coming from though, so just want to clarify a couple of things:
- by non-other, you mean just boost the number of examples of the target vocalisation? I am making an effort to include fairly poor examples as well as strong (high SNR) examples, but I can add more to this class.
- If the model was learning that 'everything else is other', wouldn't that mean that on new, unseen audio data, it would just never find the target, even if it was present? i.e. it would have very high false negative rate? This is not the case with this model. The model has very high recall, but terrible precision, with a big false positive rate.
- My understanding of how the .train function works is that it extracts the embeddings from the input files, but freezes the classification layer, replacing it with the classes you give it (in this case, just 'target' and 'other'). So, I'm not sure what you mean by starting from the base model. This is just a binary task, so I'm just trying to find a single species, labeling every other sound as 'other'. There is an option to append these new classes to the main model, I think, but I don't want/need that. The base model actually already 'knows' my target species, but it is useless at predicting it, I suspect due to very little training data for the species. My 'other' class consists of things like rain, frogs, other birds with similar spectral properties to the target, other ambient noise etc.
- I set it to train over 100 epochs, but it's been early stopping around 25 due to metrics reaching their asymptote (e.g. AUROC=~0.999987 or something silly).
That catastrophic forgetting is very interesting! Plus, what a name...
Apologies if I'm misunderstanding some of your response, I appreciate the help!
*update - I did find that the false positive rate decreased a bit (based on testing on unseen data) when I diversified the 'other' class a bit more, but only very slightly, it's still very overfitted, and at this rate I'll need many tens of thousands of 'other' clips just to get an ok model, which doesn't seem right...