Skip to content
mdashfaqqPublic

About

Adaptive Confidence-Weighted Multi-Stage Hybrid Intrusion Detection Framework for UAV CAN Networks.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

ACMH-IDS: Adaptive Calibrated Multi-Head Intrusion Detection System

License: MIT Python 3.10+

ACMH-IDS is a hybrid intrusion detection system for CAN bus networks in UAVs and autonomous vehicles. It fuses three complementary anomaly detectors — Isolation Forest, Autoencoder, and LSTM — through a learned stacking fusion engine with MCC-optimal decision thresholding to achieve strong balanced accuracy across both attack and normal traffic.


Research Motivation

Controller Area Network (CAN) buses in UAVs lack encryption or authentication, making them vulnerable to injection, masquerade, and flood attacks. Existing detectors either suffer from high false-positive rates (statistical models) or poor specificity when the class distribution is skewed (deep learning models). ACMH-IDS addresses this by combining packet-level detectors (IF, AE) with a sequence-level temporal detector (LSTM) and selecting the fusion threshold to maximise MCC rather than F1, yielding a much more balanced and practically useful system.


Architecture

CAN Bus Traffic
      │
      ├──► Isolation Forest (packet-level, unsupervised)
      │         │ p_IF
      ├──► Autoencoder (packet-level, reconstruction)
      │         │ p_AE
      └──► LSTM (sequence-level, temporal)
                │ p_LSTM
                ▼
         Fusion Engine (XGBoost stacking / weighted / logistic)
                │
         MCC-Optimal Threshold
                │
         Binary Prediction: Normal (0) / Attack (1)

Each sub-model outputs a calibrated probability. The fusion engine learns to weight these contributions and the decision threshold is selected on the validation set by maximising MCC.


Repository Structure

ACMH-IDS/
│
├── dataset/                    # Feature engineering & data loading
│   ├── preprocessing.py        # Leak-free pipeline, align_2d, create_sequences
│   └── dataset_generator.py    # Synthetic CAN dataset generation
│
├── models/                     # Model implementations
│   ├── isolation_forest.py
│   ├── autoencoder.py
│   ├── lstm.py
│   └── fusion_engine.py
│
├── evaluation/                 # Evaluation utilities
│   ├── calibration.py          # Platt, Beta, Isotonic, Temperature scaling
│   ├── metrics.py
│   ├── benchmark.py
│   ├── error_analysis.py
│   ├── explainability.py
│   ├── plots.py
│   ├── scientific_validation.py
│   └── generate_report.py      # Reproduces paper table comparisons
│
├── training/                   # Training & evaluation scripts
│   ├── train.py                # Full training pipeline with calibration search
│   ├── cross_validation.py     # Time-series 5-fold cross-validation
│   ├── ablation_study.py       # 7-configuration ablation study
│   └── fusion_optimization.py  # Fusion audit, threshold sweep, comparison
│
├── utils/
│   └── run_all.py              # Full end-to-end pipeline runner
│
├── saved_models/               # Pretrained model weights
├── reports/                    # Generated CSV/Markdown reports
│
├── docs/
│   ├── architecture.md         # Detailed architecture description
│   └── verification/           # Alignment and calibration audit artefacts
│
├── configs/                    # Reserved for future YAML configuration files
├── tests/                      # Reserved for unit tests
├── paper/                      # Reserved for manuscript source files
│
├── config.py                   # Global hyperparameters and paths
├── requirements.txt
├── environment.yml
├── README.md
├── CHANGELOG.md
├── LICENSE
└── CITATION.cff

Installation

Option A — pip

git clone https://github.com/your-username/acmh-ids.git
cd acmh-ids
python -m venv venv
# Windows:  venv\Scripts\activate
# Linux/Mac: source venv/bin/activate
pip install -r requirements.txt

Option B — Conda

conda env create -f environment.yml
conda activate acmh-ids

Dataset Preparation

The repository includes a pre-processed synthetic UAV CAN bus dataset at dataset/uav_can_dataset.csv.

To generate a fresh dataset:

python dataset/dataset_generator.py

The generator produces a balanced CAN bus trace with configurable attack ratio and sampling rate (see config.py).


Training

python training/train.py

This will:

  1. Load and pre-process the dataset (leak-free split → MinMax scaling → SMOTE).
  2. Train Isolation Forest, Autoencoder, and LSTM base models.
  3. Search over calibration methods (isotonic, platt, beta, temperature) and fusion strategies (weighted, logistic, xgboost, lightgbm) on the validation set.
  4. Save the optimal configuration to saved_models/.

Important: Calibration uses packet-level labels for IF/AE and sequence-level labels for LSTM. This is enforced by align_2d() in dataset/preprocessing.py. See docs/verification/alignment_report.csv and CHANGELOG.md for details.


Cross-Validation

python training/cross_validation.py

Runs time-series 5-fold cross-validation to produce statistically robust performance estimates. Results saved to reports/cross_validation.csv.


Ablation Study

python training/ablation_study.py

Evaluates all seven model configurations:

Configuration Description
IF Only Isolation Forest alone
AE Only Autoencoder alone
LSTM Only LSTM alone
IF + AE Average of IF and AE
IF + LSTM Average of IF and LSTM
AE + LSTM Average of AE and LSTM
Full ACMH-IDS Learned XGBoost stacking fusion

Results saved to reports/phase3_ablation_study.csv.


Fusion Optimization

python training/fusion_optimization.py

Performs:

  • XGBoost feature importance audit (which sub-model matters most).
  • Full threshold sweep (0.05–0.95) selecting the MCC-optimal threshold.
  • Fair comparison of all four fusion strategies under identical conditions.
  • Quality gates that reject fusion configurations with collapsed probabilities.

Key outputs in reports/:

File Description
fusion_comparison.csv All strategies ranked by MCC
fusion_quality_report.md Quality gate results
fusion_probability_statistics.csv Per-class probability distributions
fusion_feature_importance.csv XGBoost gain/weight/cover importance
fusion_threshold_analysis.csv Full threshold sweep table

Experimental Results

The metrics below correspond to the final optimised ACMH-IDS configuration: XGBoost stacking fusion with an MCC-optimal decision threshold of 0.794, selected on the validation set.

Performance Summary

Metric Value
MCC 0.645
Balanced Accuracy 93.02%
F1-Score 93.09%
Precision 99.84%
Recall 87.20%
Specificity 98.83%
ROC-AUC 0.938
PR-AUC 0.993

Fusion Strategy Comparison

All fusion strategies were evaluated under identical conditions using the same MCC-optimal threshold search.

Fusion Strategy MCC Balanced Accuracy F1
ACMH-IDS (XGBoost) 0.645 93.02% 93.09%
LightGBM 0.642 92.96% 93.00%
Reduced ACMH (XGBoost) 0.644 92.90% 93.08%
Weighted Fusion 0.629 90.88% 93.38%
Logistic Regression 0.594 87.69% 93.29%
AE + LSTM (avg) 0.629 91.35% 93.16%

Full per-metric breakdown is available in reports/fusion_comparison.csv.

Ablation Study

Ablation results confirm that the LSTM contributes the most to detection recall, while the Autoencoder contributes the most to specificity. The full hybrid achieves the best MCC by balancing both.

Configuration MCC Balanced Acc F1-Score
IF Only 0.094 51.62% 8.29%
AE Only 0.682 76.60% 69.17%
LSTM Only 0.288 60.38% 94.02%
IF + AE 0.671 75.91% 67.98%
IF + LSTM 0.574 84.38% 93.84%
AE + LSTM 0.608 88.54% 93.51%
Full ACMH-IDS 0.645 93.02% 93.09%

The complete ablation analysis including all confusion matrices and probability statistics is available in reports/phase3_ablation_study.csv.

All reported metrics are reproducible by executing the provided training, cross-validation, ablation, and fusion optimization scripts. Detailed CSV reports and quality analyses are available in the reports/ directory.


Evaluation

python evaluation/benchmark.py

Reports inference latency and throughput.

python evaluation/error_analysis.py

Generates a breakdown of false positive and false negative patterns.


Reproducing the Paper

To reproduce all results from a fresh clone:

python training/train.py
python training/cross_validation.py
python training/ablation_study.py
python training/fusion_optimization.py
python evaluation/benchmark.py
python evaluation/error_analysis.py
python evaluation/generate_report.py

Or run the entire pipeline in one command:

python utils/run_all.py

All generated reports will appear in reports/.


Citation

If you use ACMH-IDS in your research, please cite:

@software{acmh_ids_2025,
  title  = {{ACMH-IDS}: Adaptive Calibrated Multi-Head Intrusion Detection System},
  year   = {2025},
  url    = {https://github.com/your-username/acmh-ids},
  license = {MIT}
}

Or use GitHub's Cite this repository button (powered by CITATION.cff).


License

This project is licensed under the MIT License.

About

Adaptive Confidence-Weighted Multi-Stage Hybrid Intrusion Detection Framework for UAV CAN Networks.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages