Margin-reciprocal loss: enhancing robust network anomaly detection on imbalanced traffic data
Abstract
Accurate detection of network intrusions remains challenging under severe class imbalance, where rare attacks such as remote-to-local (R2L) and user-to-root (U2R) are poorly represented. Although many learning-based intrusion detection systems achieve high overall accuracy, conventional loss functions often bias training toward majority classes, leading to weak minority-class performance. This paper introduces a smooth margin-reciprocal loss (MRL), inspired by distance-weighted discrimination (DWD), which emphasizes samples with small or negative margins while rapidly attenuating penalties for well-classified instances. Unlike probability-based focal loss, MRL operates directly on the signed margin and enables stable optimization with first-order methods. Experiments conducted on the NSL-KDD benchmark using linear and shallow multilayer perceptron models show that MRL consistently improves macro-F1 and per-class precision–recall AUC compared with hinge, logistic, and focal losses, with notable gains on minority attack classes.
Keywords
Anomaly detection; Class imbalance; Intrusion detection systems; Margin-based learning; Margin-reciprocal loss; NSL-KDD
Full Text:
PDFDOI: http://doi.org/10.11591/ijeecs.v42.i2.pp498-508
Refbacks
- There are currently no refbacks.

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Indonesian Journal of Electrical Engineering and Computer Science (IJEECS)
p-ISSN: 2502-4752, e-ISSN: 2502-4760
This journal is published by the Institute of Advanced Engineering and Science (IAES).