Balanced Datasets for IoT IDS

Alaa Alhowaide, Izzat Alsmadi, Jian Tang · DOI

TL;DR

This paper tackles the "imbalance problem" in IoT security datasets, where normal network traffic vastly outnumbers malicious attacks, leading to biased machine learning models. The authors propose two novel sampling algorithms to create smaller, representative, and perfectly balanced datasets, validated through statistical Z-tests and 3D Principal Component Analysis (PCA) visualizations.

What Problem Does This Paper Address?

The Internet of Things (IoT) is exploding, with projections suggesting 22 billion connected devices by 2025. This massive growth creates a target-rich environment for cyberattacks. To defend these networks, researchers build Intrusion Detection Systems (IDS) powered by Machine Learning (ML).

However, ML models are only as good as the data used to train them. Most existing cybersecurity datasets are "imbalanced"—they contain a mountain of normal traffic data and only a molehill of attack data. When an ML model is trained on such lopsided data, it often becomes "lazy," simply guessing "normal" for everything to achieve high accuracy while failing to catch actual threats. This paper addresses the lack of standardized, balanced datasets that researchers need to build reliable and efficient IDSs.

Methods

The authors propose a two-step algorithmic approach to data preparation:

  1. Algorithm 1 (Representative Sampling): This algorithm generates a smaller version of a large dataset. It uses random permutations to ensure variety and then checks if the distribution of labels in the sample matches the original. If they are similar, the sample is accepted.
  2. Algorithm 2 (Balanced Sampling): This builds on the first algorithm. It identifies the "MinLabel" (the least represented class, usually the attacks) and then uses Algorithm 1 to select an equal number of records from the dominant class (usually normal traffic). This results in a 50/50 split between normal and malicious traffic.

To prove these samples are actually "good," the authors used two validation techniques:

  • Z-tests: A statistical method to check if the means of the features in the sample are significantly different from the original.
  • 3D PCA Visualization: A geometric approach that squashes high-dimensional data into a 3D plot. If the "shape" of the sample's plot matches the original's plot, the sample is considered a high-quality representation.

Datasets

The study evaluates its algorithms against four prominent cybersecurity benchmarks:

  • NSL-KDD: A classic benchmark for general network intrusion detection.
  • UNSW-NB15: A more modern benchmark containing a mix of contemporary synthetic attack activities.
  • BotNetIoT-01: Specifically focused on IoT traffic, featuring Mirai and Gafgyt botnet attacks across nine different IoT devices.
  • BoTIoT: A recently published dataset containing a wide variety of new IoT-specific attacks.

Key Insights and Ideas

  • The "Shape" of Data Matters: The most striking insight is that while a statistical Z-test might suggest a sample is "different" from the original (due to the strictness of comparing every single feature mean), the PCA visualizations showed that the samples almost perfectly preserved the geometric structure and clusters of the original data.
  • Preserving Attack Diversity: Even when balancing the dataset (reducing the amount of normal traffic), Algorithm 2 successfully preserved the internal distribution of different types of attacks (e.g., DoS, Exploit, Fuzzers) relative to each other.
  • PCA as a Validation Tool: The authors suggest that PCA is a more accurate way to measure the "goodness" of a sample than traditional feature-by-feature statistical tests, as it captures the relationships between features rather than just their individual averages.

Key Results

  • Distribution Fidelity: For all four datasets, the 50% samples generated by Algorithm 1 were identical in label distribution to the original full datasets.
  • Successful Balancing: The authors successfully created balanced versions of massive datasets. For example, the BotNetIoT-01 dataset was reduced from over 7 million records to a balanced set of roughly 1.1 million, maintaining a 0.5 (50%) ratio for the normal class.
  • Visual Confirmation: In the 3D PCA plots (Table 14), the "Full," "50% sample," and "Balanced sample" for each dataset look nearly indistinguishable, proving that the sampling didn't lose the essential characteristics of the network traffic.

Limitations and Future Work

While the paper provides a robust framework for sampling, there are a few areas for further exploration:

  • ML Performance: The paper focuses on the quality of the samples but does not explicitly show how much the detection accuracy of specific ML models (like Random Forest or SVM) improves when trained on these balanced sets versus the imbalanced originals.
  • Feature Selection: The authors dropped some features (like num_outbound_cmds in NSL-KDD) because they had zero values. Future work could investigate if more complex feature engineering combined with this sampling would yield even better results.
  • Real-time Application: The current algorithms are designed for offline dataset preparation. Adapting these logic flows for real-time, "on-the-fly" balancing in a live IDS would be a significant next step.

Summary updated

Abstract

As the Internet of Things (IoT) continues to grow, cyberattacks are becoming increasingly common. The security of IoT networks relies heavily on intrusion detection systems (IDSs). The development of an IDS that is accurate and efficient is a challenging task. As a result, this challenge is made more challenging by the absence of balanced datasets for training and testing the proposed IDS. In this study, four commonly used datasets are visualized and analyzed visually. Moreover, it proposes a sampling algorithm that generates a sample that represents the original dataset. In addition, it proposes an algorithm to generate a balanced dataset. Researchers can use this paper as a starting point when investigating cybersecurity and machine learning. The proposed sampling algorithms showed reliability in generating well-representing and balanced samples from NSL-KDD, UNSW-NB15, BotNetIoT-01, and BoTIoT datasets.
BibTeX
@misc{alhowaide2022balanced,
  author = {Alaa Alhowaide and Izzat Alsmadi and Jian Tang},
  title = {{Balanced Datasets for IoT IDS}},
  year = {2022},
  eprint = {2301.04008},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2301.04008},
}
Figure