Open Access iconOpen Access

ARTICLE

Cross-Dataset Transformer-IDS with Calibration and AUC Optimization (Evaluated on NSL-KDD, UNSW-NB15, CIC-IDS2017)

Chaonan Xin*, Keqing Xu

School of Engineering, Software College, Henan University of Animal Husbandry and Economy, Zhengzhou, 450000, China

* Corresponding Author: Chaonan Xin. Email: email

Journal of Cyber Security 2025, 7, 483-503. https://doi.org/10.32604/jcs.2025.071627

Abstract

Intrusion Detection Systems (IDS) have achieved high accuracy on benchmark datasets, yet models often fail to generalize across different network environments. In this paper, we propose Transformer-IDS, a transformer-based network intrusion detection model designed for cross-dataset generalization. The model incorporates a classification token, multi-head self-attention, and embedding layers to learn versatile features, and it introduces a calibration module and an AUC-oriented optimization objective to improve reliability and ranking performance. We evaluate Transformer-IDS on three prominent datasets (NSL-KDD, UNSW-NB15, CIC-IDS2017) in both within-dataset and cross-dataset scenarios. Results demonstrate that while conventional deep IDS models (e.g., CNN-LSTM hybrids) reach ~99% accuracy when training and testing on the same dataset, their performance drops sharply to near-chance in cross-dataset tests. In contrast, the proposed Transformer-IDS achieves substantially better cross-dataset detection, improving Area Under the ROC Curve (AUC) by over 10%–20% and F1-score by 10+ points vs. baseline models. Calibration of output probabilities further enhances trustworthiness, aligning predicted confidence with actual attack probabilities. These findings highlight that a transformer with calibration and AUC optimization can serve as a robust IDS for varied network contexts, reducing the generalization gap and providing more reliable intrusion alerts.

Keywords

Intrusion detection system; transformer; cross-dataset generalization; calibration; AUC optimization; NSL-KDD; UNSW-NB15; CIC-IDS2017; deep learning; transfer learning

Cite This Article

APA Style
Xin, C., Xu, K. (2025). Cross-Dataset Transformer-IDS with Calibration and AUC Optimization (Evaluated on NSL-KDD, UNSW-NB15, CIC-IDS2017). Journal of Cyber Security, 7(1), 483–503. https://doi.org/10.32604/jcs.2025.071627
Vancouver Style
Xin C, Xu K. Cross-Dataset Transformer-IDS with Calibration and AUC Optimization (Evaluated on NSL-KDD, UNSW-NB15, CIC-IDS2017). J Cyber Secur. 2025;7(1):483–503. https://doi.org/10.32604/jcs.2025.071627
IEEE Style
C. Xin and K. Xu, “Cross-Dataset Transformer-IDS with Calibration and AUC Optimization (Evaluated on NSL-KDD, UNSW-NB15, CIC-IDS2017),” J. Cyber Secur., vol. 7, no. 1, pp. 483–503, 2025. https://doi.org/10.32604/jcs.2025.071627



cc Copyright © 2025 The Author(s). Published by Tech Science Press.
This work is licensed under a Creative Commons Attribution 4.0 International License , which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.
  • 128

    View

  • 48

    Download

  • 0

    Like

Share Link