A machine learningβbased network intrusion detection system (IDS) designed to classify and predict malicious activities from network traffic. This project integrates data preprocessing, model training, prediction, and deployment into a single pipeline, with a web interface for real-time detection.
- Data ingestion & validation: Handles raw network data, validates schema, and prepares features.
- Machine learning models: Trains and evaluates multiple ML algorithms (Logistic Regression, Random Forest, XGBoost, etc.) with hyperparameter tuning.
- Prediction pipeline: Generates predictions for new/unseen network traffic.
- Database integration: Uses MongoDB for storing datasets and logs.
- Web app: Flask-based interface (
app.py) for uploading data and viewing predictions. - Docker support: Containerized for easy deployment.
Network-Security/
β
βββ Network_Data/ # Raw dataset files
βββ valid_data/ # Cleaned & validated data
βββ prediction_output/ # Model prediction results
βββ final_model/ # Trained model artifacts
βββ data_schema/ # Schema definitions for validation
βββ networksecurity/ # Core package (data handling, training, utils)
βββ templates/ # HTML templates for Flask web app
β
βββ app.py # Flask app for web interface
βββ main.py # Training & pipeline execution
βββ push_data.py # Script to push data to MongoDB
βββ test_mongodb.py # MongoDB connectivity test
βββ requirements.txt # Python dependencies
βββ setup.py # Package setup
βββ Dockerfile # For containerization
βββ README.md # Project documentation
git clone https://github.com/gator-ryan/Network-Security.git
cd Network-Securitypython -m venv venv
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windowspip install -r requirements.txt- Ensure you have a MongoDB instance running (local or cloud e.g. Atlas).
- Update the MongoDB connection URI in your configuration files.
- Test connection:
python test_mongodb.pypython app.pyVisit: http://127.0.0.1:5000/
To build and run the Docker container:
docker build -t network-security .
docker run -p 5000:5000 network-security- The system can be trained on public intrusion detection datasets such as NSL-KDD, CICIDS 2017, or custom network traffic logs.
- Place datasets in
Network_Data/and define schema indata_schema/.
- Upload a CSV file containing network features via the web interface.
- The system preprocesses the file, validates schema, and applies the trained ML model.
- Results (benign/malicious classification) are displayed in the browser and saved to
prediction_output/.
- Unit and integration tests should be expanded.
- Run basic connectivity tests:
pytest- Add more ML/DL models (CNN, LSTM for sequence data).
- Improve visualization of predictions and attack statistics.
- Integrate real-time packet capture.
- Expand test coverage.
- Deploy to cloud (AWS/GCP/Azure).
Contributions are welcome! Please fork this repo and submit a pull request with improvements.
This project is licensed under the MIT License β see the LICENSE file for details.
Narayan Singh Bhadauriya π§ [email protected] π https://github.com/gator-ryan/ LinkedIn: www.linkedin.com/in/nsbhadauriya/