Alaudeen commited on
Commit
aff7fb9
Β·
verified Β·
1 Parent(s): 2d293be

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +64 -15
README.md CHANGED
@@ -1,15 +1,64 @@
1
- ---
2
- title: Nids Deployment
3
- emoji: 🐠
4
- colorFrom: indigo
5
- colorTo: red
6
- sdk: gradio
7
- sdk_version: 6.14.0
8
- python_version: '3.13'
9
- app_file: app.py
10
- pinned: false
11
- tags:
12
- - ml-intern
13
- ---
14
-
15
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ ```