Datasets¶
Apollon works on any table of flow features with a binary label. The package includes loaders for the three datasets of the Canadian Institute for Cybersecurity used in the paper. Datasets are not redistributed: download them from their official pages.
Name (--dataset) |
Dataset | Files to download | Label column |
|---|---|---|---|
cic-ids2017 |
CIC-IDS2017 | MachineLearningCSV.zip (8 CSV files) |
Label (BENIGN / attack name) |
cse-cic-ids2018 |
CSE-CIC-IDS2018 | Processed Traffic Data for ML Algorithms (10 CSV files, from the AWS bucket) |
Label (Benign / attack name) |
cic-ddos2019 |
CIC-DDoS2019 | CSV-01-12.zip and/or CSV-03-11.zip |
Label (BENIGN / attack name) |
Column names
The CIC files keep a leading space in many column names (" Label",
" Destination Port"). Apollon keeps the original names, so the functional-feature
list of the adversarial evaluation matches them.
Preprocessing¶
apollon prepare: from the raw CSV files of a dataset to a portable train/test split. Scalers are fitted on the training split only.apollon prepare (or apollon.data.prepare) runs the
pipeline of the paper:
- read and concatenate the CSV files (a directory expands to its
*.csvfiles) and shuffle them with a fixed seed; - drop identifier columns (flow id, addresses, ports and timestamps where the dataset has them), header lines repeated inside the files and constant features;
- replace infinite and missing values by 0 and map labels to 0 (benign) or 1 (any attack);
- split 70/30 into train and test, stratified by label;
- scale with
RobustScaler(with_centering=False)andNormalizer, both fitted on the training split only.
apollon prepare --dataset cse-cic-ids2018 --raw data/CSE-CIC-IDS2018 \
--out data/cic18.npz --sample 500000
The output is a single compressed .npz file with the train/test split, the feature
names and the dataset name, loaded with apollon.data.Dataset.load.
Memory
CSE-CIC-IDS2018 has about 16 million flows. Use --sample to keep a stratified
subset, or prepare it on a machine with at least 32 GB of RAM.
Your own data¶
Any pandas table works through the lower-level functions:
import pandas as pd
from apollon.data import DatasetSpec, clean, split_and_scale
spec = DatasetSpec(name="My network", label="label", benign="normal",
drop=("src_ip", "dst_ip", "timestamp"))
X, y = clean(pd.read_csv("flows.csv"), spec)
data = split_and_scale(X, y, seed=0)
data.save("data/my-network.npz") # usable by `apollon train`