Why the dataset decides what your IDS study can claim
An intrusion detection system (IDS) monitors network or host activity and flags behaviour that suggests an attack or policy violation. Machine learning approaches learn to separate malicious from benign activity from labelled examples, usually records of network flows or packets described by features such as duration, protocol, ports, byte and packet counts and TCP flags. Whatever model you build, it can only learn the patterns present in its training data, so the choice and preparation of the dataset shape every result.
This is also where many studies go wrong. Sommer and Paxson (2010) argued that machine learning is harder to apply to intrusion detection than to other domains, partly because realistic, well-labelled data are scarce and evaluation is difficult. A later review of security papers found pitfalls such as sampling bias, label errors, data snooping and lab-only evaluation to be common (Arp et al., 2022). A doctoral study that treats dataset selection as a design decision, rather than a download, avoids most of them.

Step 1: choose a dataset that matches your research question
Surveys of network intrusion datasets compare them on properties such as how the traffic was generated, whether it is labelled, which attacks it contains, its format (packets or flows), its age and how much metadata describes the setting (Ring et al., 2019). Start from your research question and threat model, then ask which dataset contains that kind of traffic and those attacks.
| Dataset | Origin | Labels | Points to check |
|---|---|---|---|
| KDD Cup 1999 (and the cleaned NSL-KDD) | Derived from the 1998 DARPA evaluation traffic | Normal plus four attack categories | Decades old, with many duplicate records in the original; use only for historical comparison |
| UNSW-NB15 | Generated in a cyber range at UNSW Canberra (2015) | Binary label and nine attack categories | Synthetic traffic mix; check how the official training and test splits were built |
| CIC-IDS2017 | Testbed with profiled benign users over five days (Sharafaldin et al., 2018) | Benign and several attack families | Strong class imbalance; attacks grouped by day; check for published corrections |
| UGR'16 | NetFlow from a Spanish internet service provider over several months | Background traffic with labelled attacks | Real background traffic but synthetic attacks; flow data only |
| Bot-IoT | IoT testbed with botnet scenarios (Koroniotis et al., 2019) | Attack categories and subcategories | Dominated by attack traffic, the reverse of real networks |
| ToN_IoT | IoT and industrial IoT testbed (Booij et al., 2022) | Normal and several attack types | Heterogeneous sources; feature sets differ from other datasets |
Two consequences follow. First, results on different datasets are rarely comparable, because feature sets and attack labels differ; Booij et al. (2022) argued for standardised features and attack types for exactly this reason. Second, attacks and benign behaviour change over time, so a model that performs well on an old dataset may fail on current traffic. Testing on at least two datasets, or on data collected later than the training data, makes your conclusions much stronger.
Step 2: decide on binary or multiclass labels
Some datasets label each record only as normal or attack; others name the attack category. Binary labels suit studies of detection, where the operational question is whether to raise an alert. Multiclass labels suit studies of attack identification or response, but rare classes will have few examples and may need to be merged or reported separately.
Check how labels were produced. Labels in testbed datasets come from the attack schedule, which can mislabel benign flows that occur during an attack window, and labels in real traffic often come from other detection tools, which carries their errors into your ground truth (Arp et al., 2022).
Step 3: split the data and judge how much you need
A common rule of thumb suggests 100,000 to 200,000 records for neural networks and recommended keeping 20% "for the actual classification". There is no fixed number. What matters is the number of examples in each class, especially the rarest attacks, and whether performance is still improving as you add data, which a learning curve shows. The 20% is the test set: data that the model never sees during training or tuning.
- Three partitions. Use a training set to fit the model, a validation set (or cross-validation within the training data) to tune it, and a test set touched only once, at the end.
- Split before any preprocessing. Fitting scalers, feature selection or resampling on the whole dataset leaks information from the test set into training (Kapoor & Narayanan, 2023).
- Remove duplicates across partitions. Identical records in training and test sets inflate accuracy.
- Respect time. Where records carry timestamps, train on earlier traffic and test on later traffic. Random splits let a model learn from the future and overstate how it would perform after deployment (Pendlebury et al., 2019; Arp et al., 2022).
Step 4: handle scaling and class imbalance correctly
The original section on "data scaling" actually described deleting rows and reducing over-represented attack classes, and claimed that this would cure overfitting. These are separate issues.
- Scaling means transforming feature values, for example standardising each feature to zero mean and unit variance, so that features with large ranges such as byte counts do not dominate distance-based models or slow neural network training. Fit the scaler on the training data only.
- Class imbalance means some classes vastly outnumber others. Undersampling the majority class, oversampling the minority class or weighting classes in the loss function can help the model learn rare attacks. Resample only the training data, never the test set.
- Overfitting means learning noise in the training data. It is addressed by regularisation, simpler models, more data and honest validation, not by deleting rows.
Imbalance also changes how results should be reported. When attacks are rare, accuracy can be high for a model that never detects them, and ROC curves can look reassuring. Precision-recall curves are more informative for imbalanced data (Saito & Rehmsmeier, 2015), and a false positive rate that sounds small can still flood analysts with alerts when benign traffic vastly outnumbers attacks, the base rate problem (Arp et al., 2022).
Step 5: choose a model, and a baseline, to suit the data
Deep neural networks are popular for intrusion detection, but they are not automatically the best choice. Most deep IDS classifiers are trained with supervised learning on labelled records. The input layer receives the features; hidden layers learn intermediate representations from them; and the output layer gives either two classes (normal or attack) or one class per attack type. Recurrent networks, which feed information forward across time steps, suit sequences of packets or flows; autoencoders trained only on benign traffic are used for anomaly detection.

Always include simpler baselines, such as logistic regression, random forests or gradient boosting on the same features and splits, so that any gain from a deep model is measured rather than assumed (Arp et al., 2022). Deep models usually need more labelled data and more tuning, and their advantage is clearest on raw or sequential inputs. The claim that real-time learning is not feasible is also outdated: incremental (online) learning methods update models as data arrive. The practical limit is that new data need trustworthy labels.
Worked example: preparing data for a flow-based IDS study (illustrative)
Illustrative case. A doctoral researcher asks whether a gradient-boosting model trained on flow features detects brute-force and denial-of-service attacks better than a deep network, and whether either holds up on traffic from a different network.
- Datasets. CIC-IDS2017 for development (Sharafaldin et al., 2018), UNSW-NB15 as a second dataset; KDD Cup 1999 is cited only for historical context.
- Labels. Binary labels for the main question, with a secondary multiclass analysis for the two attack families.
- Splits. Within CIC-IDS2017, earlier days for training and validation, a later day for testing; duplicates removed across partitions; scaler and resampling fitted on training data only (Kapoor & Narayanan, 2023).
- Cross-dataset test. Features mapped to a shared subset so the trained models can be tested on UNSW-NB15, with the mapping documented (Booij et al., 2022).
- Evaluation. Precision, recall and precision-recall curves per class, false positives per day of benign traffic, and results for a random forest baseline (Saito & Rehmsmeier, 2015; Arp et al., 2022).
- Reproducibility. Code, random seeds, dataset versions and preprocessing scripts archived (Sandve et al., 2013).
What to report in your methods chapter
| Element | What to state |
|---|---|
| Dataset | Name, version, source, year and how the traffic was generated |
| Labels | Binary or multiclass, how labels were produced and any relabelling or merging |
| Cleaning | Duplicates, missing values and records removed, with counts |
| Splits | Partition sizes, time or random basis, and how leakage was prevented |
| Preprocessing | Scaling, encoding, feature selection and resampling, fitted on training data only |
| Class balance | Class counts in every partition |
| Models | All models including baselines, with hyperparameters and tuning procedure |
| Metrics | Per-class precision and recall, precision-recall curves, false positive rates |
| Generalisation | Results on a second dataset or later traffic |
Common mistakes
- Using KDD Cup 1999 as the only dataset for claims about current networks.
- Fitting scalers, feature selection or resampling before splitting the data (Kapoor & Narayanan, 2023).
- Resampling the test set so that it no longer reflects real class proportions.
- Reporting accuracy alone on imbalanced data (Saito & Rehmsmeier, 2015).
- Testing on a random split of the same traffic and calling the result generalisation (Pendlebury et al., 2019).
- Comparing a deep model with no simpler baseline (Arp et al., 2022).
For more on evaluation, see why lab accuracy does not survive real networks, adversarial attacks on machine-learning IDS, flaws in cybersecurity PhD methodology and the annotated LSTM intrusion detection example.
Key takeaways
- Choose an IDS dataset by its traffic, attacks, labels and age, not by popularity (Ring et al., 2019).
- Split before any preprocessing and respect time order, or results will be inflated (Kapoor & Narayanan, 2023; Pendlebury et al., 2019).
- Scaling, class imbalance and overfitting are different problems with different remedies.
- Report per-class precision and recall and include simple baselines (Saito & Rehmsmeier, 2015; Arp et al., 2022).
- Test on a second dataset or later traffic before claiming that a model generalises (Booij et al., 2022; Sommer & Paxson, 2010).
