muddasser commited on
Commit
5b93b6c
Β·
verified Β·
1 Parent(s): 454c456

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +99 -12
README.md CHANGED
@@ -1,19 +1,106 @@
1
  ---
2
- title: Anomoly Detection
3
- emoji: πŸš€
4
- colorFrom: red
5
- colorTo: red
6
- sdk: docker
7
  app_port: 8501
8
- tags:
9
- - streamlit
10
  pinned: false
11
- short_description: Streamlit template space
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  ---
13
 
14
- # Welcome to Streamlit!
 
 
 
 
 
15
 
16
- Edit `/src/streamlit_app.py` to customize this app to your heart's desire. :heart:
 
17
 
18
- If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
19
- forums](https://discuss.streamlit.io).
 
1
  ---
2
+ title: NSL-KDD Anomaly Detection
3
+ emoji: 🧠
4
+ colorFrom: blue
5
+ colorTo: green
6
+ sdk: streamlit
7
  app_port: 8501
 
 
8
  pinned: false
9
+ tags:
10
+ - anomaly-detection
11
+ - streamlit
12
+ - machine-learning
13
+ - cybersecurity
14
+ ---
15
+
16
+ # 🧠 NSL-KDD Anomaly Detection using Isolation Forest, One-Class SVM, and Logistic Regression
17
+
18
+ This Streamlit web app performs **network intrusion / anomaly detection** using the **NSL-KDD** dataset β€” a popular benchmark for cybersecurity and anomaly detection research.
19
+ It compares three models:
20
+ - 🏝 **Isolation Forest** (unsupervised)
21
+ - πŸ”Ή **One-Class SVM** (unsupervised)
22
+ - βš™οΈ **Logistic Regression** (supervised baseline)
23
+
24
+ ---
25
+
26
+ ## 🌐 Live Demo
27
+ πŸ‘‰ Try it on **Hugging Face Spaces**:
28
+ *(Replace with your actual Space link after deployment)*
29
+
30
+ ---
31
+
32
+ ## 🧠 Overview
33
+
34
+ The **NSL-KDD dataset** is an improved version of the classic **KDD Cup ’99** dataset for intrusion detection.
35
+ It contains labeled examples of **normal** and **attack** network connections, described by 41 features such as protocol type, service, flag, duration, and bytes transmitted.
36
+
37
+ This project:
38
+ - Loads the NSL-KDD dataset (from local file or online source)
39
+ - Performs preprocessing and scaling
40
+ - Trains and compares:
41
+ - Isolation Forest
42
+ - One-Class SVM
43
+ - Logistic Regression
44
+ - Computes accuracy, precision, recall, F1-score, and confusion matrices
45
+ - Visualizes anomalies using Seaborn and Matplotlib
46
+
47
+ ---
48
+
49
+ ## βš™οΈ How It Works
50
+
51
+ 1. Load and clean NSL-KDD dataset
52
+ 2. Convert categorical variables (e.g., protocol, service, flag) to numeric form
53
+ 3. Scale the features using **StandardScaler**
54
+ 4. Train and evaluate the following models:
55
+ - **Isolation Forest** β†’ Detects outliers by random partitioning
56
+ - **One-Class SVM** β†’ Learns boundary around normal samples
57
+ - **Logistic Regression** β†’ Supervised baseline using true labels
58
+ 5. Display results and metrics interactively in Streamlit
59
+
60
+ ---
61
+
62
+ ## 🧾 Dataset: NSL-KDD
63
+
64
+ | Column Type | Description |
65
+ |--------------|-------------|
66
+ | Numerical | Continuous numeric features (e.g., duration, src_bytes, dst_bytes) |
67
+ | Categorical | protocol_type, service, flag |
68
+ | Target | normal / attack |
69
+
70
+ πŸ“‚ You can download it from:
71
+ https://www.unb.ca/cic/datasets/nsl.html
72
+ or use a preprocessed CSV copy.
73
+
74
+ ---
75
+
76
+ ## πŸ“Š Example Outputs
77
+
78
+ - Model Accuracy Comparison
79
+ - Confusion Matrices for each model
80
+ - Bar chart of precision, recall, and F1-score
81
+ - Sample prediction visualization
82
+
83
+ ---
84
+
85
+ ## 🧰 Technologies Used
86
+
87
+ - **Python 3.9+**
88
+ - **Streamlit** β€” web UI
89
+ - **Scikit-learn** β€” model training
90
+ - **Pandas / NumPy** β€” data handling
91
+ - **Matplotlib / Seaborn** β€” visualization
92
+
93
  ---
94
 
95
+ ## πŸ—οΈ Local Setup (Optional)
96
+
97
+ ```bash
98
+ # Clone the repository
99
+ git clone https://huggingface.co/spaces/your-username/nsl-kdd-anomaly-detection
100
+ cd nsl-kdd-anomaly-detection
101
 
102
+ # Install dependencies
103
+ pip install -r requirements.txt
104
 
105
+ # Run Streamlit app
106
+ streamlit run app.py