A Streamlit-based Network Intrusion Detection System that uses Deep Learning and Machine Learning techniques to detect malicious network traffic.
The system supports real-time single input analysis, batch CSV analysis, data visualization, and on-the-fly classification training.
- Predicts whether a network connection is NORMAL or an ATTACK
- Uses a pre-trained Deep Learning model (Keras
.h5) - Probability-based decision with a configurable threshold
- Upload large CSV files for analysis
- View:
- Data preview
- Descriptive statistics
- Filtered subsets
- Interactive plots:
- Line charts
- Pie charts
- Train a Decision Tree Classifier
- Automatic:
- Encoding of categorical features
- Feature scaling
- Outputs:
- Accuracy score
- Classification report
- Confusion matrix
- Custom CSS
- Clean, dashboard-style interface
- Optimized for wide screens
- Frontend / UI: Streamlit
- Deep Learning: TensorFlow / Keras
- Machine Learning: Scikit-learn
- Data Handling: Pandas, NumPy
- Visualization: Matplotlib
- Model Artifacts: Pickle
├── app.py # Main Streamlit application ├── nids_model.h5 # Trained deep learning model ├── scaler.pkl # StandardScaler object ├── encoders.pkl # LabelEncoders for categorical features ├── features.pkl # Ordered feature list ├── requirements.txt # Python dependencies └── README.md # Project documentation
yaml
- Trained on the KDD Cup Network Intrusion Dataset
- Supports common network attributes such as:
- protocol_type
- service
- flag
- src_bytes
- dst_bytes
- connection counts
python -m venv venv source venv/bin/activate # Linux/Mac venv\Scripts\activate # Windows 3️⃣ Install Dependencies bash pip install -r requirements.txt 4️⃣ Update Model Paths Make sure paths to these files are correct in the code:
nids_model.h5
scaler.pkl
encoders.pkl
features.pkl
🧪 How Prediction Works User inputs or uploads network traffic data
Categorical features are encoded
Numeric features are scaled
Deep Learning model predicts attack probability
Output:
NORMAL ✅ or ATTACK 🚨
📈 Threshold Logic python threshold = 0.2 label = "ATTACK" if probability > threshold else "NORMAL" You can adjust the threshold based on security requirements.
🛠️ Future Improvements Support for real-time packet capture
Additional ML models (Random Forest, XGBoost)
Model performance comparison dashboard
Deployment on cloud platforms
👤 Author Avikal Bhatt GitHub: https://github.com/avikal286
LinkedIn: https://www.linkedin.com/in/avikal-bhatt-418902372
📜 License This project is for educational and research purposes.
⭐ If you find this project useful, consider giving it a star on GitHub!