Built to order

Network Intrusion Detection using Machine Learning (NSL-KDD)

This project builds a machine-learning intrusion detector that examines a network connection's features — duration, protocol, service, byte counts, failed logins, traffic rates — and classifies it as normal traffic or one of four attack families (DoS, Probe, R2L, U2R) using the NSL-KDD benchmark of 125,973 labeled connections. It ships with a full training notebook, per-class evaluation, and an interactive demo where you can load classic attack scenarios (SYN flood, port sweep, password guessing) and watch the classifier's verdict with its reasoning. Suitable for B.E./B.Tech final-year

Network Intrusion Detection using Machine Learning (NSL-KDD) — project thumbnail preview
More project photos (2)

The problem

Firewalls block what they recognize; intrusion detection is about catching what they don't. Every TCP connection leaves a footprint — how long it lasted, which service it touched, how many bytes moved, how many logins failed — and attack families leave distinctive footprints: a SYN flood opens hundreds of half-connections, a port sweep touches many services from one host, password guessing fails logins repeatedly. This project turns those footprints into a classifier trained on NSL-KDD, the cleaned-up successor of the classic KDD Cup 99 benchmark: 125,973 training and 22,544 test connection records, each with 41 features and a label from five classes (Normal, DoS, Probe, R2L, U2R). A gradient-boosted tree ensemble learns the decision boundaries, and the project evaluates it both as a binary alarm (attack vs normal) and as a five-class diagnoser, with honest discussion of the dataset's age and limits.

How it works

  1. NSL-KDD connection records (125,973 train / 22,544 test, 41 features) are loaded; categorical features (protocol, service, flag) are encoded.
  2. Class imbalance is addressed (R2L and U2R are rare) with documented sampling/weighting choices.
  3. A gradient-boosted tree ensemble trains on the full feature vector with cross-validation for hyperparameter selection.
  4. The model is evaluated twice: binary (attack vs normal) for alarm quality, and five-class for diagnostic quality, with confusion matrices.
  5. Feature-importance analysis identifies which connection attributes the model actually relies on, documented for the report.
  6. In the demo, a scenario (or hand-edited features) is encoded identically to training data and classified live with probability bars and reasoning.

Tech stack:

  • Python 3, scikit-learn / XGBoost-style boosting
  • Pandas, NumPy (data handling)
  • Matplotlib (evaluation plots)
  • Jupyter Notebook (training & evaluation)
  • HTML5 + JavaScript (interactive demo)
  • NSL-KDD dataset (UNB / Tavallaee et al.)

Dataset & model details

  • Dataset: NSL-KDD — 125,973 training records (KDDTrain+) and 22,544 test records (KDDTest+), 41 features per connection, 5 classes: Normal, DoS, Probe, R2L, U2R; a cleaned, de-duplicated refinement of KDD Cup 99 by Tavallaee, Bagheri, Lu & Ghorbani (University of New Brunswick, 2009).
  • Task: Multiclass classification; input = 41-feature connection vector, output = probability distribution over the 5 classes (plus a binary attack-vs-normal view).
  • Model: Gradient-boosted decision-tree ensemble (depth-limited trees, log-loss objective), with one-hot encoded categoricals and class-weighted loss for the rare R2L/U2R classes.
  • Metrics: Binary accuracy ≥ 97% and five-class accuracy ≥ 80% (design targets for the built-to-order training run), per-class precision/recall/F1, confusion matrix, ROC-AUC for the binary view. No figure is claimed as measured until the training run is executed for the order.
Parameter Value
Input 41 connection features (mixed categorical + numeric)
Classes 5 (Normal, DoS, Probe, R2L, U2R)
Training records 125,973 (KDDTrain+)
Binary accuracy ≥ 97% (design target, not a measured claim)
Five-class accuracy ≥ 80% (design target, not a measured claim)
Training time Approximately 5–15 min on a laptop CPU (expected)
Inference Sub-millisecond per connection on CPU (expected)
Model file Approximately 5–15 MB (expected)
Demo Single-file web app, runs offline after download

Project features

  • [Five-class attack classifier] Gradient-boosted trees over the 41 NSL-KDD features, predicting Normal, DoS, Probe, R2L or U2R for each connection.
  • [Attack-scenario demo] One click loads a Neptune SYN flood, a portsweep probe, a guess-password R2L or a buffer-overflow U2R — then the classifier renders its verdict with per-class probabilities.
  • [Editable feature inspector] Tweak duration, byte counts, failed logins or traffic rates and watch the classification shift, which makes the model's logic tangible.
  • [Why-this-decision panel] The demo explains each verdict in terms of the features that drove it (e.g. "511 connections in 2 s with low same-service rate — SYN-flood signature").
  • [Full training notebook] Preprocessing, categorical encoding, class-imbalance handling, model training, binary and multiclass evaluation in one reproducible notebook.
  • [Per-class evaluation] Confusion matrix with precision/recall per attack family — including the known hard classes, R2L and U2R, which are rare in the data.
  • [Exported trained model] Saved model plus the feature-encoding pipeline, so the demo classifies without retraining.

What is included

  • Complete training & evaluation Jupyter notebook
  • Trained classifier with feature-encoding pipeline
  • Attack-scenario web demo wired to the trained model
  • Confusion matrices, per-class metrics, feature-importance plots
  • Project report PDF (background, IDS concepts, attack taxonomy, methodology, results, dataset limits)
  • PPT presentation for final review
  • Viva Q&A preparation document (DoS vs DDoS, R2L vs U2R, false positives, class imbalance)

Limitations & prerequisites

  • NSL-KDD is derived from 1999-era traffic — it teaches the methodology, not modern attack signatures; the report states this plainly.
  • R2L and U2R are rare in the data, so per-class recall there is weaker — shown honestly in the confusion matrix.
  • Accuracy targets are design targets for the training run, stated honestly — the report documents actual achieved figures after training.
  • The demo's in-browser classifier is a compact illustration on key features; the full 41-feature model ships separately.
  • A classifier is one layer of defense, not a complete IDS — no claim is made about stopping real attacks.

Frequently Asked Questions

Which dataset is used and why?

NSL-KDD — 125,973 training and 22,544 test labeled connections with 41 features each. It removed the duplicates and biases of the original KDD Cup 99, and remains the standard teaching benchmark for connection-level intrusion detection.

What are DoS, Probe, R2L and U2R?

DoS denies service (e.g. SYN floods); Probe is reconnaissance (e.g. port sweeps); R2L is remote-to-local (e.g. password guessing); U2R is user-to-root escalation (e.g. buffer overflows). The classifier learns each family's footprint.

Why is five-class harder than binary?

Telling "attack vs normal" is easy; naming the attack family is harder because R2L and U2R look almost like normal traffic and have few training examples — the report shows this in the per-class scores.

How does the demo explain its verdict?

Each scenario's key features are mapped to plain-language reasons — for example, hundreds of connections in two seconds with a tiny same-service rate is the classic Neptune SYN-flood signature.

Is NSL-KDD still relevant?

As a source of modern signatures, no; as a way to learn the full IDS pipeline — features, imbalance, false-positive trade-offs, per-class evaluation — it is still the standard classroom benchmark, and the report says exactly this.

Is this project suitable for a final-year project?

Yes — for AI & Machine Learning, Computer Science and IT programs. It covers a real security dataset, tree-ensemble modeling, honest multiclass evaluation and an interactive attack-scenario demo. Suitable for B.E./B.Tech final-year projects in AI & Machine Learning, Computer Science and IT.

Components & software requirements
  • Python 3, scikit-learn / XGBoost-style boosting
  • Pandas, NumPy (data handling)
  • Matplotlib (evaluation plots)
  • Jupyter Notebook (training & evaluation)
  • HTML5 + JavaScript (interactive demo)
  • NSL-KDD dataset (UNB / Tavallaee et al.)

Dataset & model details

  • Dataset: NSL-KDD — 125,973 training records (KDDTrain+) and 22,544 test records (KDDTest+), 41 features per connection, 5 classes: Normal, DoS, Probe, R2L, U2R; a cleaned, de-duplicated refinement of KDD Cup 99 by Tavallaee, Bagheri, Lu & Ghorbani (University of New Brunswick, 2009).
  • Task: Multiclass classification; input = 41-feature connection vector, output = probability distribution over the 5 classes (plus a binary attack-vs-normal view).
  • Model: Gradient-boosted decision-tree ensemble (depth-limited trees, log-loss objective), with one-hot encoded categoricals and class-weighted loss for the rare R2L/U2R classes.
  • Metrics: Binary accuracy ≥ 97% and five-class accuracy ≥ 80% (design targets for the built-to-order training run), per-class precision/recall/F1, confusion matrix, ROC-AUC for the binary view. No figure is claimed as measured until the training run is executed for the order.
Delivery information

Built-to-order project. Delivery timeline is shared after order confirmation based on current queue.

Support terms

Complete documentation, setup guide, and viva preparation included. Support for setup and explanation provided.

Download abstract (PDF)

Related guides

All guides
Blueprint-style technical illustration of multiple decision trees voting together into one final predictionStudents with basic Python and pandas skills who want a reliable first classifier for ML coursework and tabular data projects.

Random Forests Explained: Why Decision Trees Vote Better Together

Decision trees are readable but overfit; random forests fix this by training hundreds of varied trees on bootstrapped data with random feature subsets, then letting them vote. This guide explains Gini impurity, bagging, out-of-bag validation and the four hyperparameters that matter, with a complete scikit-learn workflow, honest feature-importance practices, and the mistakes students keep making.

Read guide
Illustration of object tracking showing video frames with bounding boxes and persistent ID labels following people and vehicles, comparing motion prediction and appearance matching.B.E./B.Tech Computer Science and Electronics students building video analytics projects — people counting, vehicle tracking, sports analysis — who have detection working and need

Object Tracking: DeepSORT and ByteTrack Explained

Detection finds objects per frame; tracking keeps their identities across frames. This guide explains tracking-by-detection, Kalman motion models, DeepSORT's appearance embeddings vs ByteTrack's low-confidence box recovery, tracking metrics (HOTA, IDF1, ID switches), and the tuning parameters that determine real-world quality.

Read guide
Illustration of image segmentation showing U-Net's U-shaped encoder-decoder with skip connections producing pixel masks, alongside Mask R-CNN detecting instances with masks.B.E./B.Tech Computer Science and AI/ML students moving from image classification or detection to pixel-level understanding — medical imaging, defect detection, autonomous driving

Image Segmentation: U-Net and Mask R-CNN

When projects need pixel-level answers, segmentation delivers. This guide explains semantic vs instance vs panoptic segmentation, U-Net's encoder-decoder with skip connections, Mask R-CNN's parallel mask head, Dice and IoU evaluation, paired augmentation, and how to choose the right architecture for your data and question.

Read guide
Get a quotation