An AI-driven threat detection system that analyzes network traffic and identifies potential anomalies using machine learning. The project uses an Isolation Forest model to distinguish between normal and abnormal traffic patterns.
This project demonstrates how machine learning can be applied to network security by generating synthetic traffic data, training an anomaly detection model, and evaluating suspicious activity within network patterns.
- Generates synthetic network traffic data for training and testing.
- Trains an Isolation Forest model for anomaly detection.
- Evaluates model performance using test data.
- Generates synthetic network packets and saves them as a
.pcapfile. - Serves as a foundation for more advanced threat detection systems.
ai_threat_detection.py: Main script that trains and tests the anomaly detection model using synthetic network traffic data.generate_synthetic_network_data.py: Generates synthetic network traffic data for training and testing.generate_synthetic_traffic.py: Generates synthetic network packets and saves them in.pcapformat.
- Python 3.x
- Required Python libraries:
numpypandasscikit-learnscapy
- Install the required dependencies using pip:
pip install numpy pandas scikit-learn scapyRun the following command to create the synthetic dataset:
python generate_synthetic_network_data.pyThis will generate a CSV file named synthetic_network_data.csv containing both normal and abnormal traffic data.
Train the Isolation Forest model and evaluate its performance:
python ai_threat_detection.py- The script will output training and testing results, along with a classification report.
- Create synthetic network packets and save them as a
.pcapfile:
python generate_synthetic_traffic.py- The generated
.pcapfile can be used for further analysis or for testing network monitoring tools.
- Generates synthetic normal and abnormal network traffic data.
- Splits the dataset into training and testing sets.
- Trains the Isolation Forest model on the training data.
- Evaluates the model on test data.
- Outputs performance metrics and classification results.
- Creates synthetic network traffic data with both normal and abnormal patterns.
- Saves the generated data as a CSV file.
- Generates synthetic network packets using random IP addresses and TCP ports.
- Saves the packets as a
.pcapfile for analysis.
-
To make the project more robust and production-ready, consider the following improvements:
-
Integrate real network traffic data for more realistic evaluation.
-
Compare multiple machine learning models.
-
Add feature engineering to improve detection quality.
-
Build a real-time monitoring pipeline for live traffic analysis.
-
Develop a GUI to visualize detection results.
Melisa Sever
- Project repository: AI-Driven Threat Detection System
- This project was originally started by Melisa Sever and later developed in collaboration with Saarthak Tripathi.