A practical ML pipeline for multi-class network intrusion detection using the CSE-CIC-IDS2018 dataset, with:
- preprocessing,
- tabular model training (LightGBM, RandomForest),
- LSTM baseline training,
- ablation analysis for leakage/shortcut checks.
- Unified preprocessing for train/val/test
- Multi-model training and metrics export
- LSTM sequence baseline
- Ablation runner for suspicious feature analysis
- JSON/CSV reports for easy comparison
src/
config.py
preprocess.py
trainer_tabular.py
trainer_lstm.py
run_all.py
ablation_runner.py
rebuild_cleaned_files.py
data/
raw/ # original IDS CSV files
processed/ # cleaned_*.parquet, model artifacts
reports/ # metrics JSON/CSV outputs
python -m venv .venv
source .venv/bin/activatepip install -U pip
pip install pandas numpy scikit-learn lightgbm pyarrow joblib tensorflowIf TensorFlow GPU is not detected, training still works on CPU.
Place raw IDS CSV files in:
data/raw/
Ensure FILES in src/config.py matches your dataset file names.
python -m src.rebuild_cleaned_filespython -m src.trainer_tabularpython -m src.trainer_lstmpython -m src.run_allpython -m src.ablation_runnerGenerated artifacts are saved to:
data/processed/- trained model files (
*.pkl,*.keras) - encoders/scalers
- selected feature lists
- trained model files (
reports/tabular_results.jsonlstm_results.jsoncombined_results.jsonablation_results.jsonablation_results.csv
Current results can appear very high if split mode falls back to row_order.
For reliable generalization claims, prefer strict day-based hard splits (hard_split_runner.py) with all day files available.
- Implementation complete through ablation stage
- Leakage-aware diagnostics integrated
- Hard split evaluation recommended as next step for final reporting
If you use this repository in academic work, please cite:
- Sharafaldin et al., CSE-CIC-IDS2018
- LightGBM paper
- Random Forest paper
- LSTM original paper