This project evaluates an Intrusion Detection System (IDS) pipeline using a baseline Random Forest and six metaheuristic variants. The optimizers perform joint feature selection alongside hyperparameter tuning (n_estimators, max_depth, min_samples_split) on the CICIDS2017 network traffic dataset.
- Baseline Random Forest (all features)
- Genetic Algorithm (GA) + Random Forest
- Particle Swarm Optimization (PSO) + Random Forest
- Grey Wolf Optimizer (GWO) + Random Forest
- Adaptive GWO + Random Forest
- GA-PSO Hybrid + Random Forest
- NSGA-III + Random Forest
- Highest Accuracy & Balanced Recall: NSGA-III + RF provides the strongest multi-objective balance, yielding high attack recall with a compact feature set, making it highly viable for general SOC deployment.
- Strict False Positive Minimization: Baseline Random Forest consistently suppresses the highest number of false alarms, functioning best in environments aiming to avoid alert fatigue.
- Fastest Computational Runtime: PSO + RF offers the lowest latency for both training and inference.
The project uses standard CICIDS2017 CSV files located under:
data/MachineLearningCVE/
Manual Dataset Acquisition: If the dataset was not bundled with your local copy of the repository due to file-size constraints:
- Download the
MachineLearningCVE.zipfile from the official Canadian Institute for Cybersecurity (UNB) website or from the Kaggle CICIDS2017 mirror. - Extract the archive and place all raw CSV files directly into the
data/MachineLearningCVE/directory.
Pipeline Execution:
- The workflow concatenates the full cleaned data first, standardizing column headers.
- It randomly samples 15% from the full concatenated dataset (reproducible via a fixed
random_state=42). - It extracts a robust stratified train/test split.
- Compiled split files are saved to
data/combined_ml_15pct/for persistence across optimization runs.
Eval.ipynb: Main experiment notebook containing the full execution pipeline and visualizations.requirements.txt: Python package dependencies.preprocessing/clean.py: Data loading, standardization, and stratified splitting logic.core/baseline.py: Baseline model training and performance evaluation.core/fitness.py: Optimization objective function and final model evaluation metrics.optimizers/ga.py: Genetic Algorithm (GA).optimizers/pso.py: Particle Swarm Optimization (PSO).optimizers/gwo.py: Grey Wolf Optimizer (GWO).optimizers/adaptive_gwo.py: Dynamic parameter Adaptive GWO.optimizers/gapso.py: Hybridized GA and PSO strategy.optimizers/nsga3.py: Non-dominated Sorting Genetic Algorithm III (NSGA-III).
- Create and activate a virtual environment (recommended):
python -m venv .venv
.\.venv\Scripts\Activate.ps1- Install dependencies:
pip install -r requirements.txtOption A: Notebook (Recommended)
- Open
Eval.ipynb. - Run the cells from top to bottom. The notebook will automatically build/load the sampled split files under
data/combined_ml_15pct/. - Review the metrics table, feature allocations, and visualizations.
Estimated Runtime: Executing the full notebook from scratch runs six distinct metaheuristic optimizers sequentially. For reference, this end-to-end evaluation takes approximately 1 to 1.5 hours to fully complete on a standard Intel Core i7 processor.
Provided Evaluation Outputs:
- Classification metrics (Accuracy, Precision, Recall, F1)
- Operations errors (False Positives and False Negatives counts)
- Latency (Training and Testing time comparisons)
- Feature-selection overlap and dimensional importance.
- Normalized optimizer convergence trajectory graphing.
- Optimization settings (agents/iterations) are highly configurable in
Eval.ipynb. Higher iterations improve convergence tracking but noticeably increase compute overhead. - Keep
random_statefixed where possible to strictly mirror the paper's reported outputs. - Run all algorithm comparisons sequentially on the exact same dataset split to prevent sample-variance skew.
If you see an error ending in: Error: Target column 'label' not found. or ValueError: not enough values to unpack, your dataset files are likely Git LFS pointer files instead of the real CSV data.
Fix: Run the following inside your terminal to pull the raw binary sets:
git lfs pull origin mainAIM Coursework Project University of Nottingham Malaysia
- Rajul Kabir
- Imitaz Naufal
- Babacar Sene