Spaces:
Runtime error
Runtime error
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,15 +1,64 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# π‘οΈ Network Intrusion Detection System (NIDS)
|
| 2 |
+
|
| 3 |
+
Real-time network intrusion detection using ML & Deep Learning models trained on the NSL-KDD dataset.
|
| 4 |
+
|
| 5 |
+
## Models
|
| 6 |
+
- **XGBoost** (best) β Accuracy 76.18%, AUC-ROC 95.75%
|
| 7 |
+
- **Random Forest** β Accuracy 73.10%, AUC-ROC 95.34%
|
| 8 |
+
- **MLP** β Deep learning baseline
|
| 9 |
+
- **Autoencoder** β Unsupervised anomaly detection
|
| 10 |
+
- **LSTM** β Sequential feature modeling
|
| 11 |
+
- **Transformer** β FlowTransformer-style architecture
|
| 12 |
+
|
| 13 |
+
## Dataset
|
| 14 |
+
[NSL-KDD](https://huggingface.co/datasets/Mireu-Lab/NSL-KDD) β 185K records, 41 features, binary classification (normal/anomaly)
|
| 15 |
+
|
| 16 |
+
## Deployment
|
| 17 |
+
|
| 18 |
+
### REST API (FastAPI)
|
| 19 |
+
```bash
|
| 20 |
+
pip install fastapi uvicorn
|
| 21 |
+
uvicorn api:app --host 0.0.0.0 --port 8000
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
+
Endpoints:
|
| 25 |
+
- `GET /health` β Health check
|
| 26 |
+
- `GET /models` β List models
|
| 27 |
+
- `POST /predict` β Single flow detection
|
| 28 |
+
- `POST /predict/batch` β Batch detection
|
| 29 |
+
- `GET /stats` β Usage statistics
|
| 30 |
+
|
| 31 |
+
### Gradio UI
|
| 32 |
+
```bash
|
| 33 |
+
python app.py
|
| 34 |
+
```
|
| 35 |
+
|
| 36 |
+
## API Example
|
| 37 |
+
```bash
|
| 38 |
+
curl -X POST http://localhost:8000/predict \
|
| 39 |
+
-H "Content-Type: application/json" \
|
| 40 |
+
-d '{"features":[0,1,45,0,491,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,2,2,0,0,0,0,1,0,0,0,0.17], "model":"XGBoost"}'
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
## Results
|
| 44 |
+
| Model | Accuracy | Macro F1 | AUC-ROC | Type |
|
| 45 |
+
|-------|----------|----------|---------|------|
|
| 46 |
+
| XGBoost | 76.18% | 76.04% | 95.75% | Supervised |
|
| 47 |
+
| RandomForest | 73.10% | 73.05% | 95.34% | Supervised |
|
| 48 |
+
| MLP | 73.28% | 73.21% | 89.33% | Supervised |
|
| 49 |
+
| Autoencoder | 71.84% | 71.34% | 73.60% | Unsupervised |
|
| 50 |
+
|
| 51 |
+
## Project Structure
|
| 52 |
+
```
|
| 53 |
+
nids_project/
|
| 54 |
+
βββ api.py # FastAPI REST API
|
| 55 |
+
βββ app.py # Gradio web UI
|
| 56 |
+
βββ space_app.py # HF Spaces app
|
| 57 |
+
βββ data_loader.py # Dataset loading
|
| 58 |
+
βββ ml_models.py # ML implementations
|
| 59 |
+
βββ dl_models.py # DL implementations
|
| 60 |
+
βββ realtime.py # Real-time pipeline
|
| 61 |
+
βββ realtime_batch.py # Batch throughput benchmark
|
| 62 |
+
βββ Dockerfile # Container image
|
| 63 |
+
βββ requirements.txt # Dependencies
|
| 64 |
+
```
|