This repository contains the implementation for predicting the severity of network intrusions using the CICIDS2017 (Canadian Institute for Cybersecurity Intrusion Detection System) dataset. The project leverages machine learning and deep learning methodologies to classify network traffic flows and assess the severity of potential cyber-attacks, moving beyond standard binary or multi-class detection into risk-based severity scoring.
The CICIDS2017 dataset includes benign traffic and the most common up-to-date attacks. Network traffic was captured via PCAP and processed using CICFlowMeter to extract 80+ time-based statistical features (e.g., flow duration, packet length variance, inter-arrival times).
- Cleaning: Removal of
NaNandInfinityvalues standard in raw CICFlowMeter outputs. - Normalization: Application of
StandardScaler/MinMaxScalerfor gradient stability during deep learning optimization. - Feature Selection: Dimensionality reduction to eliminate zero-variance and highly correlated features, optimizing computational overhead.
├── data/ # Directory for CIC-2017 CSV files
├── notebooks/ # Exploratory Data Analysis (EDA) and prototyping
├── src/
│ ├── data_loader.py # Data parsing and preprocessing scripts
│ ├── model.py # Neural network architecture / ML models
│ ├── train.py # Training loop and gradient optimization logic
│ └── evaluate.py # Inference and metrics calculation
├── requirements.txt # Environment dependencies
└── README.md # Project documentation
It is recommended to run this project in an isolated virtual environment (e.g., using venv or conda on Linux).
# Clone the repository
git clone https://github.com/SaifoSaeed/CIC-2017-Severity-Prediction.git
cd CIC-2017-Severity-Prediction
# Create and activate virtual environment
python3 -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txtKey packages required (see requirements.txt for exact versions):
numpy,pandasfor low-level matrix manipulation and data processingscikit-learnfor preprocessing and baseline modelstorch(PyTorch) for deep neural network executionmatplotlib,seabornfor confusion matrix and metric visualization
1. Data Preparation:
Place the processed CIC-2017 CSV files into the data/ directory. Run the preprocessing script to clean the data and generate feature tensors:
python src/data_loader.py --input data/raw --output data/processed2. Model Training: Execute the training script. You can specify hyperparameters such as batch size, learning rate, and epochs.
python src/train.py --epochs 50 --batch_size 256 --lr 0.0013. Evaluation: Evaluate the trained weights against the test split to compute Precision, Recall, F1-Score, and Severity mapping:
python src/evaluate.py --model_path weights/best_model.pthThe model relies on mapping the multi-class attack labels (e.g., DDoS, PortScan, Bot, Web Attack) into distinct severity tiers (Low, Medium, High, Critical) based on network impact. The architecture leverages deep learning (via PyTorch) optimized for structured tabular data, implementing robust regularization to prevent overfitting on the majority classes (Benign traffic).
Contributions are welcome. Please submit a pull request detailing the bug fix, feature addition, or performance optimization.
This project is licensed under the MIT License - see the LICENSE file for details.