ML-based system that detects and classifies cyberattacks in IoT network traffic using Random Forest and MLP Neural Network.
IoT devices generate massive network traffic and are frequent targets of cyberattacks. This system analyzes network traffic data and classifies it into 8 categories — Normal traffic and 7 attack types — helping identify threats in real time.
- Python, scikit-learn, pandas, numpy
- matplotlib, seaborn (visualization)
- Tkinter (desktop GUI)
| Model | Description |
|---|---|
| Random Forest | Ensemble of 10 decision trees, handles non-linear patterns |
| MLP Neural Network | Multi-layer perceptron, deep learning approach for complex pattern recognition |
- Data Upload — Load CSV dataset via file dialog
- Preprocessing — Label encoding for categorical features, imputation for missing values, StandardScaler normalization
- Feature Selection — PCA reducing to 10 principal components
- Training — 80/20 train-test split, both models trained independently
- Evaluation — Accuracy, Precision, Recall, F1 score + Confusion Matrix heatmap
- Prediction — Upload new test CSV, get attack/normal classification output
| Model | Accuracy | Precision | Recall | F1 Score |
|---|---|---|---|---|
| Random Forest | 99.48% | 99.48% | 99.48% | 99.48% |
| MLP Neural Network | 99.45% | 99.45% | 99.45% | 99.45% |
Results obtained on UNSW-NB15 dataset with 357,952 samples. Run the application to reproduce.
Normal, anomalous(DoSattack), anomalous(dataProbing), anomalous(malitiousControl), anomalous(malitiousOperation), anomalous(scan), anomalous(spying), anomalous(wrongSetUp)
- Python 3.8+
- Install dependencies:
pip install -r requirements.txtpython IOTCyberAttackDetection.py- Click 1. Upload IoT Dataset → select your
.csvfile - Click 2. Preprocess Dataset → cleans and scales the data
- Click 3. Feature Selection (PCA) → applies PCA
- Click 4a/4b Run Models → trains model and shows results
- Click 5. Predict from Test Data → upload test CSV to classify new traffic
This project uses IoT network traffic data. Dataset not included in repo due to size.
- Recommended: UNSW-NB15 Dataset
- Or: CIC-IoT Dataset
- Convert to web app (FastAPI + React) for browser-based access
- Add real-time network traffic monitoring
- Integrate SHAP for model explainability
- Expand to more attack categories