ktestkp15 commited on
Commit
86830e3
·
verified ·
1 Parent(s): 50a7ad3

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -58,3 +58,11 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
61
+ MachineLearningCVE/Friday-WorkingHours-Afternoon-DDos.pcap_ISCX.csv filter=lfs diff=lfs merge=lfs -text
62
+ MachineLearningCVE/Friday-WorkingHours-Afternoon-PortScan.pcap_ISCX.csv filter=lfs diff=lfs merge=lfs -text
63
+ MachineLearningCVE/Friday-WorkingHours-Morning.pcap_ISCX.csv filter=lfs diff=lfs merge=lfs -text
64
+ MachineLearningCVE/Monday-WorkingHours.pcap_ISCX.csv filter=lfs diff=lfs merge=lfs -text
65
+ MachineLearningCVE/Thursday-WorkingHours-Afternoon-Infilteration.pcap_ISCX.csv filter=lfs diff=lfs merge=lfs -text
66
+ MachineLearningCVE/Thursday-WorkingHours-Morning-WebAttacks.pcap_ISCX.csv filter=lfs diff=lfs merge=lfs -text
67
+ MachineLearningCVE/Tuesday-WorkingHours.pcap_ISCX.csv filter=lfs diff=lfs merge=lfs -text
68
+ MachineLearningCVE/Wednesday-workingHours.pcap_ISCX.csv filter=lfs diff=lfs merge=lfs -text
MachineLearningCVE/Friday-WorkingHours-Afternoon-DDos.pcap_ISCX.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6ff1580f5f81c0ae28a26f7631721018577f5f7c5e0feac28b795fcfe7b411ee
3
+ size 77123859
MachineLearningCVE/Friday-WorkingHours-Afternoon-PortScan.pcap_ISCX.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ca1824c51bfbb7b3c72290a11be04366ba8815878c6a1cc5c44cb1cee269e99b
3
+ size 76906168
MachineLearningCVE/Friday-WorkingHours-Morning.pcap_ISCX.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:53a41c24d570ea83b7ac55b2e94df94e7a8216aeb80a2af0246b6bc8bb543000
3
+ size 58316725
MachineLearningCVE/Monday-WorkingHours.pcap_ISCX.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:852c4beb34eda186f32561fa79df7a0747e92e1a6535b01270820dd9ffe17f34
3
+ size 176927918
MachineLearningCVE/Thursday-WorkingHours-Afternoon-Infilteration.pcap_ISCX.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6bcda3857c2504676034e3ea57762d38393cc734cb377a726bd5cb153961b1b5
3
+ size 83102436
MachineLearningCVE/Thursday-WorkingHours-Morning-WebAttacks.pcap_ISCX.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d67066211fb1689c78406f1506f4c44704ecb92088353d5c96d96d6474eb819d
3
+ size 52023263
MachineLearningCVE/Tuesday-WorkingHours.pcap_ISCX.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:52b8692ae8c7d2ed04671fe2b98335693c0a92c7ab157d8c8b534d6523080851
3
+ size 135078995
MachineLearningCVE/Wednesday-workingHours.pcap_ISCX.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:893c27dc968bf7a8adef1689f90be55ca4a4dc3088fb63d6ff247ac56856df2a
3
+ size 225166395
README.md CHANGED
@@ -1,3 +1,136 @@
1
  ---
2
- license: apache-2.0
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ license: mit
3
+ task_categories:
4
+ - tabular-classification
5
+ tags:
6
+ - cybersecurity
7
+ - intrusion-detection
8
+ - network-security
9
+ - cic-ids2017
10
+ size_categories:
11
+ - 1M<n<10M
12
  ---
13
+
14
+ # NIT Cyber Analysis — Network Intrusion Detection using CIC-IDS2017
15
+
16
+ Research project on network intrusion detection using the CIC-IDS2017 dataset.
17
+ Covers data preprocessing, exploratory analysis, and deep learning classification across 15 traffic categories (14 attack types + benign).
18
+
19
+ ---
20
+
21
+ ## Dataset
22
+
23
+ CIC-IDS2017 — Canadian Institute for Cybersecurity
24
+
25
+ * 8 CSV files
26
+ * ~2.8 million network flow records
27
+ * 78 features + label
28
+
29
+ Dataset Download: https://www.unb.ca/cic/datasets/ids-2017.html
30
+
31
+ > CSV files are not tracked in this repository due to their large size.
32
+
33
+ ---
34
+
35
+ ## Project Structure
36
+
37
+ ```text
38
+ .
39
+ ├── notebooks
40
+ │ ├── 01_pre-processing.ipynb
41
+ │ ├── 02_EDA.ipynb
42
+ │ └── 03_modelling.ipynb
43
+ ├── requirements.txt
44
+ └── README.md
45
+ ```
46
+
47
+ | File | Description |
48
+ | ----------------------- | ----------------------------------------------- |
49
+ | 01_pre-processing.ipynb | Data cleaning and preprocessing pipeline |
50
+ | 02_EDA.ipynb | Exploratory Data Analysis |
51
+ | 03_modelling.ipynb | Encoding, scaling, SMOTE, and model preparation |
52
+ | requirements.txt | Project dependencies |
53
+
54
+ ---
55
+
56
+ ## Work Division
57
+
58
+ ### Undergraduate Contribution (This Repository)
59
+
60
+ * Loaded and merged all 8 CIC-IDS2017 CSV files into a single dataframe (~2.8M rows)
61
+ * Handled missing values, infinite values, and duplicate records
62
+ * Cleaned column names and label inconsistencies present in the raw dataset
63
+ * Performed exploratory data analysis including:
64
+
65
+ * Label distribution analysis
66
+ * Binary vs multi-class distribution
67
+ * Correlation heatmaps
68
+ * Outlier detection using boxplots
69
+ * Feature distribution analysis
70
+ * Prepared data for modelling through:
71
+
72
+ * Label Encoding
73
+ * Feature selection
74
+ * Stratified train-test split (80:20)
75
+ * StandardScaler normalization
76
+ * SMOTE class balancing
77
+
78
+ ### PhD Scholar Contribution
79
+
80
+ * Deep learning model architecture design
81
+ * Model training and experimentation
82
+ * Hyperparameter tuning
83
+ * Performance evaluation and benchmarking
84
+ * Result analysis
85
+
86
+ ---
87
+
88
+ ## Pipeline
89
+
90
+ ```text
91
+ Raw CSV Files
92
+ ↓
93
+ Merge
94
+ ↓
95
+ Clean
96
+ ↓
97
+ EDA
98
+ ↓
99
+ Encode
100
+ ↓
101
+ Split
102
+ ↓
103
+ Scale
104
+ ↓
105
+ SMOTE
106
+ ↓
107
+ Deep Learning Model
108
+ ```
109
+
110
+ ---
111
+
112
+ ## Setup
113
+
114
+ ```bash
115
+ pip install -r requirements.txt
116
+ jupyter notebook
117
+ ```
118
+
119
+ Run the notebooks in the following order:
120
+
121
+ ```text
122
+ notebooks/01_pre-processing.ipynb
123
+ ↓
124
+ notebooks/02_EDA.ipynb
125
+ ↓
126
+ notebooks/03_modelling.ipynb
127
+ ```
128
+
129
+ ---
130
+
131
+ ## Team
132
+
133
+ **NIT Research Collaboration**
134
+ B.Tech CSE Student + PhD Scholar
135
+
136
+ Dataset Credit: Canadian Institute for Cybersecurity (CIC), University of New Brunswick
notebooks/01_pre-processing.ipynb ADDED
@@ -0,0 +1,1406 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "id": "initial_id",
6
+ "metadata": {
7
+ "collapsed": true,
8
+ "ExecuteTime": {
9
+ "end_time": "2026-06-22T16:40:34.164570Z",
10
+ "start_time": "2026-06-22T16:40:33.675544Z"
11
+ }
12
+ },
13
+ "source": [
14
+ "import pandas as pd\n",
15
+ "import numpy as np"
16
+ ],
17
+ "outputs": [],
18
+ "execution_count": 1
19
+ },
20
+ {
21
+ "metadata": {
22
+ "ExecuteTime": {
23
+ "end_time": "2026-06-22T16:40:38.951020Z",
24
+ "start_time": "2026-06-22T16:40:34.174240Z"
25
+ }
26
+ },
27
+ "cell_type": "code",
28
+ "source": [
29
+ "data_1 = pd.read_csv('MachineLearningCVE/Monday-WorkingHours.pcap_ISCX.csv')\n",
30
+ "data_2 = pd.read_csv('MachineLearningCVE/Tuesday-WorkingHours.pcap_ISCX.csv')\n",
31
+ "data_3 = pd.read_csv('MachineLearningCVE/Wednesday-workingHours.pcap_ISCX.csv')\n",
32
+ "data_4 = pd.read_csv('MachineLearningCVE/Thursday-WorkingHours-Morning-WebAttacks.pcap_ISCX.csv')\n",
33
+ "data_5 = pd.read_csv('MachineLearningCVE/Thursday-WorkingHours-Afternoon-Infilteration.pcap_ISCX.csv')\n",
34
+ "data_6 = pd.read_csv('MachineLearningCVE/Friday-WorkingHours-Morning.pcap_ISCX.csv')\n",
35
+ "data_7 = pd.read_csv('MachineLearningCVE/Friday-WorkingHours-Afternoon-PortScan.pcap_ISCX.csv')\n",
36
+ "data_8 = pd.read_csv('MachineLearningCVE/Friday-WorkingHours-Afternoon-DDos.pcap_ISCX.csv')"
37
+ ],
38
+ "id": "2b0f14cbce7cfda9",
39
+ "outputs": [],
40
+ "execution_count": 2
41
+ },
42
+ {
43
+ "metadata": {
44
+ "ExecuteTime": {
45
+ "end_time": "2026-06-22T16:40:39.020261Z",
46
+ "start_time": "2026-06-22T16:40:38.976598Z"
47
+ }
48
+ },
49
+ "cell_type": "code",
50
+ "source": [
51
+ "data_list = [data_1, data_2, data_3, data_4, data_5, data_6, data_7, data_8]\n",
52
+ "for i, nums in enumerate(data_list):\n",
53
+ " print(\"Shape of File\", i+1, \":\", nums.shape)"
54
+ ],
55
+ "id": "f3aee561cf447257",
56
+ "outputs": [
57
+ {
58
+ "name": "stdout",
59
+ "output_type": "stream",
60
+ "text": [
61
+ "Shape of File 1 : (529918, 79)\n",
62
+ "Shape of File 2 : (445909, 79)\n",
63
+ "Shape of File 3 : (692703, 79)\n",
64
+ "Shape of File 4 : (170366, 79)\n",
65
+ "Shape of File 5 : (288602, 79)\n",
66
+ "Shape of File 6 : (191033, 79)\n",
67
+ "Shape of File 7 : (286467, 79)\n",
68
+ "Shape of File 8 : (225745, 79)\n"
69
+ ]
70
+ }
71
+ ],
72
+ "execution_count": 3
73
+ },
74
+ {
75
+ "metadata": {
76
+ "ExecuteTime": {
77
+ "end_time": "2026-06-22T16:40:39.470589Z",
78
+ "start_time": "2026-06-22T16:40:39.047671Z"
79
+ }
80
+ },
81
+ "cell_type": "code",
82
+ "source": [
83
+ "data = pd.concat(data_list, ignore_index=True)\n",
84
+ "print(data.shape)"
85
+ ],
86
+ "id": "d686cbfe1d5f54d8",
87
+ "outputs": [
88
+ {
89
+ "name": "stdout",
90
+ "output_type": "stream",
91
+ "text": [
92
+ "(2830743, 79)\n"
93
+ ]
94
+ }
95
+ ],
96
+ "execution_count": 4
97
+ },
98
+ {
99
+ "metadata": {
100
+ "ExecuteTime": {
101
+ "end_time": "2026-06-22T16:40:39.488182Z",
102
+ "start_time": "2026-06-22T16:40:39.471428Z"
103
+ }
104
+ },
105
+ "cell_type": "code",
106
+ "source": "data.head()",
107
+ "id": "61786487c7062017",
108
+ "outputs": [
109
+ {
110
+ "data": {
111
+ "text/plain": [
112
+ " Destination Port Flow Duration Total Fwd Packets \\\n",
113
+ "0 49188 4 2 \n",
114
+ "1 49188 1 2 \n",
115
+ "2 49188 1 2 \n",
116
+ "3 49188 1 2 \n",
117
+ "4 49486 3 2 \n",
118
+ "\n",
119
+ " Total Backward Packets Total Length of Fwd Packets \\\n",
120
+ "0 0 12 \n",
121
+ "1 0 12 \n",
122
+ "2 0 12 \n",
123
+ "3 0 12 \n",
124
+ "4 0 12 \n",
125
+ "\n",
126
+ " Total Length of Bwd Packets Fwd Packet Length Max \\\n",
127
+ "0 0 6 \n",
128
+ "1 0 6 \n",
129
+ "2 0 6 \n",
130
+ "3 0 6 \n",
131
+ "4 0 6 \n",
132
+ "\n",
133
+ " Fwd Packet Length Min Fwd Packet Length Mean Fwd Packet Length Std \\\n",
134
+ "0 6 6.0 0.0 \n",
135
+ "1 6 6.0 0.0 \n",
136
+ "2 6 6.0 0.0 \n",
137
+ "3 6 6.0 0.0 \n",
138
+ "4 6 6.0 0.0 \n",
139
+ "\n",
140
+ " ... min_seg_size_forward Active Mean Active Std Active Max \\\n",
141
+ "0 ... 20 0.0 0.0 0 \n",
142
+ "1 ... 20 0.0 0.0 0 \n",
143
+ "2 ... 20 0.0 0.0 0 \n",
144
+ "3 ... 20 0.0 0.0 0 \n",
145
+ "4 ... 20 0.0 0.0 0 \n",
146
+ "\n",
147
+ " Active Min Idle Mean Idle Std Idle Max Idle Min Label \n",
148
+ "0 0 0.0 0.0 0 0 BENIGN \n",
149
+ "1 0 0.0 0.0 0 0 BENIGN \n",
150
+ "2 0 0.0 0.0 0 0 BENIGN \n",
151
+ "3 0 0.0 0.0 0 0 BENIGN \n",
152
+ "4 0 0.0 0.0 0 0 BENIGN \n",
153
+ "\n",
154
+ "[5 rows x 79 columns]"
155
+ ],
156
+ "text/html": [
157
+ "<div>\n",
158
+ "<style scoped>\n",
159
+ " .dataframe tbody tr th:only-of-type {\n",
160
+ " vertical-align: middle;\n",
161
+ " }\n",
162
+ "\n",
163
+ " .dataframe tbody tr th {\n",
164
+ " vertical-align: top;\n",
165
+ " }\n",
166
+ "\n",
167
+ " .dataframe thead th {\n",
168
+ " text-align: right;\n",
169
+ " }\n",
170
+ "</style>\n",
171
+ "<table border=\"1\" class=\"dataframe\">\n",
172
+ " <thead>\n",
173
+ " <tr style=\"text-align: right;\">\n",
174
+ " <th></th>\n",
175
+ " <th>Destination Port</th>\n",
176
+ " <th>Flow Duration</th>\n",
177
+ " <th>Total Fwd Packets</th>\n",
178
+ " <th>Total Backward Packets</th>\n",
179
+ " <th>Total Length of Fwd Packets</th>\n",
180
+ " <th>Total Length of Bwd Packets</th>\n",
181
+ " <th>Fwd Packet Length Max</th>\n",
182
+ " <th>Fwd Packet Length Min</th>\n",
183
+ " <th>Fwd Packet Length Mean</th>\n",
184
+ " <th>Fwd Packet Length Std</th>\n",
185
+ " <th>...</th>\n",
186
+ " <th>min_seg_size_forward</th>\n",
187
+ " <th>Active Mean</th>\n",
188
+ " <th>Active Std</th>\n",
189
+ " <th>Active Max</th>\n",
190
+ " <th>Active Min</th>\n",
191
+ " <th>Idle Mean</th>\n",
192
+ " <th>Idle Std</th>\n",
193
+ " <th>Idle Max</th>\n",
194
+ " <th>Idle Min</th>\n",
195
+ " <th>Label</th>\n",
196
+ " </tr>\n",
197
+ " </thead>\n",
198
+ " <tbody>\n",
199
+ " <tr>\n",
200
+ " <th>0</th>\n",
201
+ " <td>49188</td>\n",
202
+ " <td>4</td>\n",
203
+ " <td>2</td>\n",
204
+ " <td>0</td>\n",
205
+ " <td>12</td>\n",
206
+ " <td>0</td>\n",
207
+ " <td>6</td>\n",
208
+ " <td>6</td>\n",
209
+ " <td>6.0</td>\n",
210
+ " <td>0.0</td>\n",
211
+ " <td>...</td>\n",
212
+ " <td>20</td>\n",
213
+ " <td>0.0</td>\n",
214
+ " <td>0.0</td>\n",
215
+ " <td>0</td>\n",
216
+ " <td>0</td>\n",
217
+ " <td>0.0</td>\n",
218
+ " <td>0.0</td>\n",
219
+ " <td>0</td>\n",
220
+ " <td>0</td>\n",
221
+ " <td>BENIGN</td>\n",
222
+ " </tr>\n",
223
+ " <tr>\n",
224
+ " <th>1</th>\n",
225
+ " <td>49188</td>\n",
226
+ " <td>1</td>\n",
227
+ " <td>2</td>\n",
228
+ " <td>0</td>\n",
229
+ " <td>12</td>\n",
230
+ " <td>0</td>\n",
231
+ " <td>6</td>\n",
232
+ " <td>6</td>\n",
233
+ " <td>6.0</td>\n",
234
+ " <td>0.0</td>\n",
235
+ " <td>...</td>\n",
236
+ " <td>20</td>\n",
237
+ " <td>0.0</td>\n",
238
+ " <td>0.0</td>\n",
239
+ " <td>0</td>\n",
240
+ " <td>0</td>\n",
241
+ " <td>0.0</td>\n",
242
+ " <td>0.0</td>\n",
243
+ " <td>0</td>\n",
244
+ " <td>0</td>\n",
245
+ " <td>BENIGN</td>\n",
246
+ " </tr>\n",
247
+ " <tr>\n",
248
+ " <th>2</th>\n",
249
+ " <td>49188</td>\n",
250
+ " <td>1</td>\n",
251
+ " <td>2</td>\n",
252
+ " <td>0</td>\n",
253
+ " <td>12</td>\n",
254
+ " <td>0</td>\n",
255
+ " <td>6</td>\n",
256
+ " <td>6</td>\n",
257
+ " <td>6.0</td>\n",
258
+ " <td>0.0</td>\n",
259
+ " <td>...</td>\n",
260
+ " <td>20</td>\n",
261
+ " <td>0.0</td>\n",
262
+ " <td>0.0</td>\n",
263
+ " <td>0</td>\n",
264
+ " <td>0</td>\n",
265
+ " <td>0.0</td>\n",
266
+ " <td>0.0</td>\n",
267
+ " <td>0</td>\n",
268
+ " <td>0</td>\n",
269
+ " <td>BENIGN</td>\n",
270
+ " </tr>\n",
271
+ " <tr>\n",
272
+ " <th>3</th>\n",
273
+ " <td>49188</td>\n",
274
+ " <td>1</td>\n",
275
+ " <td>2</td>\n",
276
+ " <td>0</td>\n",
277
+ " <td>12</td>\n",
278
+ " <td>0</td>\n",
279
+ " <td>6</td>\n",
280
+ " <td>6</td>\n",
281
+ " <td>6.0</td>\n",
282
+ " <td>0.0</td>\n",
283
+ " <td>...</td>\n",
284
+ " <td>20</td>\n",
285
+ " <td>0.0</td>\n",
286
+ " <td>0.0</td>\n",
287
+ " <td>0</td>\n",
288
+ " <td>0</td>\n",
289
+ " <td>0.0</td>\n",
290
+ " <td>0.0</td>\n",
291
+ " <td>0</td>\n",
292
+ " <td>0</td>\n",
293
+ " <td>BENIGN</td>\n",
294
+ " </tr>\n",
295
+ " <tr>\n",
296
+ " <th>4</th>\n",
297
+ " <td>49486</td>\n",
298
+ " <td>3</td>\n",
299
+ " <td>2</td>\n",
300
+ " <td>0</td>\n",
301
+ " <td>12</td>\n",
302
+ " <td>0</td>\n",
303
+ " <td>6</td>\n",
304
+ " <td>6</td>\n",
305
+ " <td>6.0</td>\n",
306
+ " <td>0.0</td>\n",
307
+ " <td>...</td>\n",
308
+ " <td>20</td>\n",
309
+ " <td>0.0</td>\n",
310
+ " <td>0.0</td>\n",
311
+ " <td>0</td>\n",
312
+ " <td>0</td>\n",
313
+ " <td>0.0</td>\n",
314
+ " <td>0.0</td>\n",
315
+ " <td>0</td>\n",
316
+ " <td>0</td>\n",
317
+ " <td>BENIGN</td>\n",
318
+ " </tr>\n",
319
+ " </tbody>\n",
320
+ "</table>\n",
321
+ "<p>5 rows × 79 columns</p>\n",
322
+ "</div>"
323
+ ]
324
+ },
325
+ "execution_count": 5,
326
+ "metadata": {},
327
+ "output_type": "execute_result"
328
+ }
329
+ ],
330
+ "execution_count": 5
331
+ },
332
+ {
333
+ "metadata": {
334
+ "ExecuteTime": {
335
+ "end_time": "2026-06-22T16:40:39.573979Z",
336
+ "start_time": "2026-06-22T16:40:39.510891Z"
337
+ }
338
+ },
339
+ "cell_type": "code",
340
+ "source": "data.tail()",
341
+ "id": "99a533b9a872e4e1",
342
+ "outputs": [
343
+ {
344
+ "data": {
345
+ "text/plain": [
346
+ " Destination Port Flow Duration Total Fwd Packets \\\n",
347
+ "2830738 61374 61 1 \n",
348
+ "2830739 61378 72 1 \n",
349
+ "2830740 61375 75 1 \n",
350
+ "2830741 61323 48 2 \n",
351
+ "2830742 61326 68 1 \n",
352
+ "\n",
353
+ " Total Backward Packets Total Length of Fwd Packets \\\n",
354
+ "2830738 1 6 \n",
355
+ "2830739 1 6 \n",
356
+ "2830740 1 6 \n",
357
+ "2830741 0 12 \n",
358
+ "2830742 1 6 \n",
359
+ "\n",
360
+ " Total Length of Bwd Packets Fwd Packet Length Max \\\n",
361
+ "2830738 6 6 \n",
362
+ "2830739 6 6 \n",
363
+ "2830740 6 6 \n",
364
+ "2830741 0 6 \n",
365
+ "2830742 6 6 \n",
366
+ "\n",
367
+ " Fwd Packet Length Min Fwd Packet Length Mean \\\n",
368
+ "2830738 6 6.0 \n",
369
+ "2830739 6 6.0 \n",
370
+ "2830740 6 6.0 \n",
371
+ "2830741 6 6.0 \n",
372
+ "2830742 6 6.0 \n",
373
+ "\n",
374
+ " Fwd Packet Length Std ... min_seg_size_forward Active Mean \\\n",
375
+ "2830738 0.0 ... 20 0.0 \n",
376
+ "2830739 0.0 ... 20 0.0 \n",
377
+ "2830740 0.0 ... 20 0.0 \n",
378
+ "2830741 0.0 ... 20 0.0 \n",
379
+ "2830742 0.0 ... 20 0.0 \n",
380
+ "\n",
381
+ " Active Std Active Max Active Min Idle Mean Idle Std \\\n",
382
+ "2830738 0.0 0 0 0.0 0.0 \n",
383
+ "2830739 0.0 0 0 0.0 0.0 \n",
384
+ "2830740 0.0 0 0 0.0 0.0 \n",
385
+ "2830741 0.0 0 0 0.0 0.0 \n",
386
+ "2830742 0.0 0 0 0.0 0.0 \n",
387
+ "\n",
388
+ " Idle Max Idle Min Label \n",
389
+ "2830738 0 0 BENIGN \n",
390
+ "2830739 0 0 BENIGN \n",
391
+ "2830740 0 0 BENIGN \n",
392
+ "2830741 0 0 BENIGN \n",
393
+ "2830742 0 0 BENIGN \n",
394
+ "\n",
395
+ "[5 rows x 79 columns]"
396
+ ],
397
+ "text/html": [
398
+ "<div>\n",
399
+ "<style scoped>\n",
400
+ " .dataframe tbody tr th:only-of-type {\n",
401
+ " vertical-align: middle;\n",
402
+ " }\n",
403
+ "\n",
404
+ " .dataframe tbody tr th {\n",
405
+ " vertical-align: top;\n",
406
+ " }\n",
407
+ "\n",
408
+ " .dataframe thead th {\n",
409
+ " text-align: right;\n",
410
+ " }\n",
411
+ "</style>\n",
412
+ "<table border=\"1\" class=\"dataframe\">\n",
413
+ " <thead>\n",
414
+ " <tr style=\"text-align: right;\">\n",
415
+ " <th></th>\n",
416
+ " <th>Destination Port</th>\n",
417
+ " <th>Flow Duration</th>\n",
418
+ " <th>Total Fwd Packets</th>\n",
419
+ " <th>Total Backward Packets</th>\n",
420
+ " <th>Total Length of Fwd Packets</th>\n",
421
+ " <th>Total Length of Bwd Packets</th>\n",
422
+ " <th>Fwd Packet Length Max</th>\n",
423
+ " <th>Fwd Packet Length Min</th>\n",
424
+ " <th>Fwd Packet Length Mean</th>\n",
425
+ " <th>Fwd Packet Length Std</th>\n",
426
+ " <th>...</th>\n",
427
+ " <th>min_seg_size_forward</th>\n",
428
+ " <th>Active Mean</th>\n",
429
+ " <th>Active Std</th>\n",
430
+ " <th>Active Max</th>\n",
431
+ " <th>Active Min</th>\n",
432
+ " <th>Idle Mean</th>\n",
433
+ " <th>Idle Std</th>\n",
434
+ " <th>Idle Max</th>\n",
435
+ " <th>Idle Min</th>\n",
436
+ " <th>Label</th>\n",
437
+ " </tr>\n",
438
+ " </thead>\n",
439
+ " <tbody>\n",
440
+ " <tr>\n",
441
+ " <th>2830738</th>\n",
442
+ " <td>61374</td>\n",
443
+ " <td>61</td>\n",
444
+ " <td>1</td>\n",
445
+ " <td>1</td>\n",
446
+ " <td>6</td>\n",
447
+ " <td>6</td>\n",
448
+ " <td>6</td>\n",
449
+ " <td>6</td>\n",
450
+ " <td>6.0</td>\n",
451
+ " <td>0.0</td>\n",
452
+ " <td>...</td>\n",
453
+ " <td>20</td>\n",
454
+ " <td>0.0</td>\n",
455
+ " <td>0.0</td>\n",
456
+ " <td>0</td>\n",
457
+ " <td>0</td>\n",
458
+ " <td>0.0</td>\n",
459
+ " <td>0.0</td>\n",
460
+ " <td>0</td>\n",
461
+ " <td>0</td>\n",
462
+ " <td>BENIGN</td>\n",
463
+ " </tr>\n",
464
+ " <tr>\n",
465
+ " <th>2830739</th>\n",
466
+ " <td>61378</td>\n",
467
+ " <td>72</td>\n",
468
+ " <td>1</td>\n",
469
+ " <td>1</td>\n",
470
+ " <td>6</td>\n",
471
+ " <td>6</td>\n",
472
+ " <td>6</td>\n",
473
+ " <td>6</td>\n",
474
+ " <td>6.0</td>\n",
475
+ " <td>0.0</td>\n",
476
+ " <td>...</td>\n",
477
+ " <td>20</td>\n",
478
+ " <td>0.0</td>\n",
479
+ " <td>0.0</td>\n",
480
+ " <td>0</td>\n",
481
+ " <td>0</td>\n",
482
+ " <td>0.0</td>\n",
483
+ " <td>0.0</td>\n",
484
+ " <td>0</td>\n",
485
+ " <td>0</td>\n",
486
+ " <td>BENIGN</td>\n",
487
+ " </tr>\n",
488
+ " <tr>\n",
489
+ " <th>2830740</th>\n",
490
+ " <td>61375</td>\n",
491
+ " <td>75</td>\n",
492
+ " <td>1</td>\n",
493
+ " <td>1</td>\n",
494
+ " <td>6</td>\n",
495
+ " <td>6</td>\n",
496
+ " <td>6</td>\n",
497
+ " <td>6</td>\n",
498
+ " <td>6.0</td>\n",
499
+ " <td>0.0</td>\n",
500
+ " <td>...</td>\n",
501
+ " <td>20</td>\n",
502
+ " <td>0.0</td>\n",
503
+ " <td>0.0</td>\n",
504
+ " <td>0</td>\n",
505
+ " <td>0</td>\n",
506
+ " <td>0.0</td>\n",
507
+ " <td>0.0</td>\n",
508
+ " <td>0</td>\n",
509
+ " <td>0</td>\n",
510
+ " <td>BENIGN</td>\n",
511
+ " </tr>\n",
512
+ " <tr>\n",
513
+ " <th>2830741</th>\n",
514
+ " <td>61323</td>\n",
515
+ " <td>48</td>\n",
516
+ " <td>2</td>\n",
517
+ " <td>0</td>\n",
518
+ " <td>12</td>\n",
519
+ " <td>0</td>\n",
520
+ " <td>6</td>\n",
521
+ " <td>6</td>\n",
522
+ " <td>6.0</td>\n",
523
+ " <td>0.0</td>\n",
524
+ " <td>...</td>\n",
525
+ " <td>20</td>\n",
526
+ " <td>0.0</td>\n",
527
+ " <td>0.0</td>\n",
528
+ " <td>0</td>\n",
529
+ " <td>0</td>\n",
530
+ " <td>0.0</td>\n",
531
+ " <td>0.0</td>\n",
532
+ " <td>0</td>\n",
533
+ " <td>0</td>\n",
534
+ " <td>BENIGN</td>\n",
535
+ " </tr>\n",
536
+ " <tr>\n",
537
+ " <th>2830742</th>\n",
538
+ " <td>61326</td>\n",
539
+ " <td>68</td>\n",
540
+ " <td>1</td>\n",
541
+ " <td>1</td>\n",
542
+ " <td>6</td>\n",
543
+ " <td>6</td>\n",
544
+ " <td>6</td>\n",
545
+ " <td>6</td>\n",
546
+ " <td>6.0</td>\n",
547
+ " <td>0.0</td>\n",
548
+ " <td>...</td>\n",
549
+ " <td>20</td>\n",
550
+ " <td>0.0</td>\n",
551
+ " <td>0.0</td>\n",
552
+ " <td>0</td>\n",
553
+ " <td>0</td>\n",
554
+ " <td>0.0</td>\n",
555
+ " <td>0.0</td>\n",
556
+ " <td>0</td>\n",
557
+ " <td>0</td>\n",
558
+ " <td>BENIGN</td>\n",
559
+ " </tr>\n",
560
+ " </tbody>\n",
561
+ "</table>\n",
562
+ "<p>5 rows × 79 columns</p>\n",
563
+ "</div>"
564
+ ]
565
+ },
566
+ "execution_count": 6,
567
+ "metadata": {},
568
+ "output_type": "execute_result"
569
+ }
570
+ ],
571
+ "execution_count": 6
572
+ },
573
+ {
574
+ "metadata": {
575
+ "ExecuteTime": {
576
+ "end_time": "2026-06-22T16:40:39.911875Z",
577
+ "start_time": "2026-06-22T16:40:39.898994Z"
578
+ }
579
+ },
580
+ "cell_type": "code",
581
+ "source": "data.info()",
582
+ "id": "30cfcaa709f658b8",
583
+ "outputs": [
584
+ {
585
+ "name": "stdout",
586
+ "output_type": "stream",
587
+ "text": [
588
+ "<class 'pandas.DataFrame'>\n",
589
+ "RangeIndex: 2830743 entries, 0 to 2830742\n",
590
+ "Data columns (total 79 columns):\n",
591
+ " # Column Dtype \n",
592
+ "--- ------ ----- \n",
593
+ " 0 Destination Port int64 \n",
594
+ " 1 Flow Duration int64 \n",
595
+ " 2 Total Fwd Packets int64 \n",
596
+ " 3 Total Backward Packets int64 \n",
597
+ " 4 Total Length of Fwd Packets int64 \n",
598
+ " 5 Total Length of Bwd Packets int64 \n",
599
+ " 6 Fwd Packet Length Max int64 \n",
600
+ " 7 Fwd Packet Length Min int64 \n",
601
+ " 8 Fwd Packet Length Mean float64\n",
602
+ " 9 Fwd Packet Length Std float64\n",
603
+ " 10 Bwd Packet Length Max int64 \n",
604
+ " 11 Bwd Packet Length Min int64 \n",
605
+ " 12 Bwd Packet Length Mean float64\n",
606
+ " 13 Bwd Packet Length Std float64\n",
607
+ " 14 Flow Bytes/s float64\n",
608
+ " 15 Flow Packets/s float64\n",
609
+ " 16 Flow IAT Mean float64\n",
610
+ " 17 Flow IAT Std float64\n",
611
+ " 18 Flow IAT Max int64 \n",
612
+ " 19 Flow IAT Min int64 \n",
613
+ " 20 Fwd IAT Total int64 \n",
614
+ " 21 Fwd IAT Mean float64\n",
615
+ " 22 Fwd IAT Std float64\n",
616
+ " 23 Fwd IAT Max int64 \n",
617
+ " 24 Fwd IAT Min int64 \n",
618
+ " 25 Bwd IAT Total int64 \n",
619
+ " 26 Bwd IAT Mean float64\n",
620
+ " 27 Bwd IAT Std float64\n",
621
+ " 28 Bwd IAT Max int64 \n",
622
+ " 29 Bwd IAT Min int64 \n",
623
+ " 30 Fwd PSH Flags int64 \n",
624
+ " 31 Bwd PSH Flags int64 \n",
625
+ " 32 Fwd URG Flags int64 \n",
626
+ " 33 Bwd URG Flags int64 \n",
627
+ " 34 Fwd Header Length int64 \n",
628
+ " 35 Bwd Header Length int64 \n",
629
+ " 36 Fwd Packets/s float64\n",
630
+ " 37 Bwd Packets/s float64\n",
631
+ " 38 Min Packet Length int64 \n",
632
+ " 39 Max Packet Length int64 \n",
633
+ " 40 Packet Length Mean float64\n",
634
+ " 41 Packet Length Std float64\n",
635
+ " 42 Packet Length Variance float64\n",
636
+ " 43 FIN Flag Count int64 \n",
637
+ " 44 SYN Flag Count int64 \n",
638
+ " 45 RST Flag Count int64 \n",
639
+ " 46 PSH Flag Count int64 \n",
640
+ " 47 ACK Flag Count int64 \n",
641
+ " 48 URG Flag Count int64 \n",
642
+ " 49 CWE Flag Count int64 \n",
643
+ " 50 ECE Flag Count int64 \n",
644
+ " 51 Down/Up Ratio int64 \n",
645
+ " 52 Average Packet Size float64\n",
646
+ " 53 Avg Fwd Segment Size float64\n",
647
+ " 54 Avg Bwd Segment Size float64\n",
648
+ " 55 Fwd Header Length.1 int64 \n",
649
+ " 56 Fwd Avg Bytes/Bulk int64 \n",
650
+ " 57 Fwd Avg Packets/Bulk int64 \n",
651
+ " 58 Fwd Avg Bulk Rate int64 \n",
652
+ " 59 Bwd Avg Bytes/Bulk int64 \n",
653
+ " 60 Bwd Avg Packets/Bulk int64 \n",
654
+ " 61 Bwd Avg Bulk Rate int64 \n",
655
+ " 62 Subflow Fwd Packets int64 \n",
656
+ " 63 Subflow Fwd Bytes int64 \n",
657
+ " 64 Subflow Bwd Packets int64 \n",
658
+ " 65 Subflow Bwd Bytes int64 \n",
659
+ " 66 Init_Win_bytes_forward int64 \n",
660
+ " 67 Init_Win_bytes_backward int64 \n",
661
+ " 68 act_data_pkt_fwd int64 \n",
662
+ " 69 min_seg_size_forward int64 \n",
663
+ " 70 Active Mean float64\n",
664
+ " 71 Active Std float64\n",
665
+ " 72 Active Max int64 \n",
666
+ " 73 Active Min int64 \n",
667
+ " 74 Idle Mean float64\n",
668
+ " 75 Idle Std float64\n",
669
+ " 76 Idle Max int64 \n",
670
+ " 77 Idle Min int64 \n",
671
+ " 78 Label str \n",
672
+ "dtypes: float64(24), int64(54), str(1)\n",
673
+ "memory usage: 1.7 GB\n"
674
+ ]
675
+ }
676
+ ],
677
+ "execution_count": 7
678
+ },
679
+ {
680
+ "metadata": {
681
+ "ExecuteTime": {
682
+ "end_time": "2026-06-22T16:40:42.108651Z",
683
+ "start_time": "2026-06-22T16:40:39.929882Z"
684
+ }
685
+ },
686
+ "cell_type": "code",
687
+ "source": "data.describe()",
688
+ "id": "fd59141b1e4719f7",
689
+ "outputs": [
690
+ {
691
+ "name": "stderr",
692
+ "output_type": "stream",
693
+ "text": [
694
+ "/Users/partha/PycharmProjects/Cyber-Sec/.venv/lib/python3.12/site-packages/pandas/core/nanops.py:1028: RuntimeWarning: invalid value encountered in subtract\n",
695
+ " sqr = _ensure_numeric((avg - values) ** 2)\n",
696
+ "/Users/partha/PycharmProjects/Cyber-Sec/.venv/lib/python3.12/site-packages/pandas/core/nanops.py:1028: RuntimeWarning: invalid value encountered in subtract\n",
697
+ " sqr = _ensure_numeric((avg - values) ** 2)\n"
698
+ ]
699
+ },
700
+ {
701
+ "data": {
702
+ "text/plain": [
703
+ " Destination Port Flow Duration Total Fwd Packets \\\n",
704
+ "count 2.830743e+06 2.830743e+06 2.830743e+06 \n",
705
+ "mean 8.071483e+03 1.478566e+07 9.361160e+00 \n",
706
+ "std 1.828363e+04 3.365374e+07 7.496728e+02 \n",
707
+ "min 0.000000e+00 -1.300000e+01 1.000000e+00 \n",
708
+ "25% 5.300000e+01 1.550000e+02 2.000000e+00 \n",
709
+ "50% 8.000000e+01 3.131600e+04 2.000000e+00 \n",
710
+ "75% 4.430000e+02 3.204828e+06 5.000000e+00 \n",
711
+ "max 6.553500e+04 1.200000e+08 2.197590e+05 \n",
712
+ "\n",
713
+ " Total Backward Packets Total Length of Fwd Packets \\\n",
714
+ "count 2.830743e+06 2.830743e+06 \n",
715
+ "mean 1.039377e+01 5.493024e+02 \n",
716
+ "std 9.973883e+02 9.993589e+03 \n",
717
+ "min 0.000000e+00 0.000000e+00 \n",
718
+ "25% 1.000000e+00 1.200000e+01 \n",
719
+ "50% 2.000000e+00 6.200000e+01 \n",
720
+ "75% 4.000000e+00 1.870000e+02 \n",
721
+ "max 2.919220e+05 1.290000e+07 \n",
722
+ "\n",
723
+ " Total Length of Bwd Packets Fwd Packet Length Max \\\n",
724
+ "count 2.830743e+06 2.830743e+06 \n",
725
+ "mean 1.616264e+04 2.075999e+02 \n",
726
+ "std 2.263088e+06 7.171848e+02 \n",
727
+ "min 0.000000e+00 0.000000e+00 \n",
728
+ "25% 0.000000e+00 6.000000e+00 \n",
729
+ "50% 1.230000e+02 3.700000e+01 \n",
730
+ "75% 4.820000e+02 8.100000e+01 \n",
731
+ "max 6.554530e+08 2.482000e+04 \n",
732
+ "\n",
733
+ " Fwd Packet Length Min Fwd Packet Length Mean \\\n",
734
+ "count 2.830743e+06 2.830743e+06 \n",
735
+ "mean 1.871366e+01 5.820194e+01 \n",
736
+ "std 6.033935e+01 1.860912e+02 \n",
737
+ "min 0.000000e+00 0.000000e+00 \n",
738
+ "25% 0.000000e+00 6.000000e+00 \n",
739
+ "50% 2.000000e+00 3.400000e+01 \n",
740
+ "75% 3.600000e+01 5.000000e+01 \n",
741
+ "max 2.325000e+03 5.940857e+03 \n",
742
+ "\n",
743
+ " Fwd Packet Length Std ... act_data_pkt_fwd min_seg_size_forward \\\n",
744
+ "count 2.830743e+06 ... 2.830743e+06 2.830743e+06 \n",
745
+ "mean 6.891013e+01 ... 5.418218e+00 -2.741688e+03 \n",
746
+ "std 2.811871e+02 ... 6.364257e+02 1.084989e+06 \n",
747
+ "min 0.000000e+00 ... 0.000000e+00 -5.368707e+08 \n",
748
+ "25% 0.000000e+00 ... 0.000000e+00 2.000000e+01 \n",
749
+ "50% 0.000000e+00 ... 1.000000e+00 2.400000e+01 \n",
750
+ "75% 2.616295e+01 ... 2.000000e+00 3.200000e+01 \n",
751
+ "max 7.125597e+03 ... 2.135570e+05 1.380000e+02 \n",
752
+ "\n",
753
+ " Active Mean Active Std Active Max Active Min Idle Mean \\\n",
754
+ "count 2.830743e+06 2.830743e+06 2.830743e+06 2.830743e+06 2.830743e+06 \n",
755
+ "mean 8.155132e+04 4.113412e+04 1.531825e+05 5.829582e+04 8.316037e+06 \n",
756
+ "std 6.485999e+05 3.933815e+05 1.025825e+06 5.770923e+05 2.363008e+07 \n",
757
+ "min 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 \n",
758
+ "25% 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 \n",
759
+ "50% 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 \n",
760
+ "75% 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 \n",
761
+ "max 1.100000e+08 7.420000e+07 1.100000e+08 1.100000e+08 1.200000e+08 \n",
762
+ "\n",
763
+ " Idle Std Idle Max Idle Min \n",
764
+ "count 2.830743e+06 2.830743e+06 2.830743e+06 \n",
765
+ "mean 5.038439e+05 8.695752e+06 7.920031e+06 \n",
766
+ "std 4.602984e+06 2.436689e+07 2.336342e+07 \n",
767
+ "min 0.000000e+00 0.000000e+00 0.000000e+00 \n",
768
+ "25% 0.000000e+00 0.000000e+00 0.000000e+00 \n",
769
+ "50% 0.000000e+00 0.000000e+00 0.000000e+00 \n",
770
+ "75% 0.000000e+00 0.000000e+00 0.000000e+00 \n",
771
+ "max 7.690000e+07 1.200000e+08 1.200000e+08 \n",
772
+ "\n",
773
+ "[8 rows x 78 columns]"
774
+ ],
775
+ "text/html": [
776
+ "<div>\n",
777
+ "<style scoped>\n",
778
+ " .dataframe tbody tr th:only-of-type {\n",
779
+ " vertical-align: middle;\n",
780
+ " }\n",
781
+ "\n",
782
+ " .dataframe tbody tr th {\n",
783
+ " vertical-align: top;\n",
784
+ " }\n",
785
+ "\n",
786
+ " .dataframe thead th {\n",
787
+ " text-align: right;\n",
788
+ " }\n",
789
+ "</style>\n",
790
+ "<table border=\"1\" class=\"dataframe\">\n",
791
+ " <thead>\n",
792
+ " <tr style=\"text-align: right;\">\n",
793
+ " <th></th>\n",
794
+ " <th>Destination Port</th>\n",
795
+ " <th>Flow Duration</th>\n",
796
+ " <th>Total Fwd Packets</th>\n",
797
+ " <th>Total Backward Packets</th>\n",
798
+ " <th>Total Length of Fwd Packets</th>\n",
799
+ " <th>Total Length of Bwd Packets</th>\n",
800
+ " <th>Fwd Packet Length Max</th>\n",
801
+ " <th>Fwd Packet Length Min</th>\n",
802
+ " <th>Fwd Packet Length Mean</th>\n",
803
+ " <th>Fwd Packet Length Std</th>\n",
804
+ " <th>...</th>\n",
805
+ " <th>act_data_pkt_fwd</th>\n",
806
+ " <th>min_seg_size_forward</th>\n",
807
+ " <th>Active Mean</th>\n",
808
+ " <th>Active Std</th>\n",
809
+ " <th>Active Max</th>\n",
810
+ " <th>Active Min</th>\n",
811
+ " <th>Idle Mean</th>\n",
812
+ " <th>Idle Std</th>\n",
813
+ " <th>Idle Max</th>\n",
814
+ " <th>Idle Min</th>\n",
815
+ " </tr>\n",
816
+ " </thead>\n",
817
+ " <tbody>\n",
818
+ " <tr>\n",
819
+ " <th>count</th>\n",
820
+ " <td>2.830743e+06</td>\n",
821
+ " <td>2.830743e+06</td>\n",
822
+ " <td>2.830743e+06</td>\n",
823
+ " <td>2.830743e+06</td>\n",
824
+ " <td>2.830743e+06</td>\n",
825
+ " <td>2.830743e+06</td>\n",
826
+ " <td>2.830743e+06</td>\n",
827
+ " <td>2.830743e+06</td>\n",
828
+ " <td>2.830743e+06</td>\n",
829
+ " <td>2.830743e+06</td>\n",
830
+ " <td>...</td>\n",
831
+ " <td>2.830743e+06</td>\n",
832
+ " <td>2.830743e+06</td>\n",
833
+ " <td>2.830743e+06</td>\n",
834
+ " <td>2.830743e+06</td>\n",
835
+ " <td>2.830743e+06</td>\n",
836
+ " <td>2.830743e+06</td>\n",
837
+ " <td>2.830743e+06</td>\n",
838
+ " <td>2.830743e+06</td>\n",
839
+ " <td>2.830743e+06</td>\n",
840
+ " <td>2.830743e+06</td>\n",
841
+ " </tr>\n",
842
+ " <tr>\n",
843
+ " <th>mean</th>\n",
844
+ " <td>8.071483e+03</td>\n",
845
+ " <td>1.478566e+07</td>\n",
846
+ " <td>9.361160e+00</td>\n",
847
+ " <td>1.039377e+01</td>\n",
848
+ " <td>5.493024e+02</td>\n",
849
+ " <td>1.616264e+04</td>\n",
850
+ " <td>2.075999e+02</td>\n",
851
+ " <td>1.871366e+01</td>\n",
852
+ " <td>5.820194e+01</td>\n",
853
+ " <td>6.891013e+01</td>\n",
854
+ " <td>...</td>\n",
855
+ " <td>5.418218e+00</td>\n",
856
+ " <td>-2.741688e+03</td>\n",
857
+ " <td>8.155132e+04</td>\n",
858
+ " <td>4.113412e+04</td>\n",
859
+ " <td>1.531825e+05</td>\n",
860
+ " <td>5.829582e+04</td>\n",
861
+ " <td>8.316037e+06</td>\n",
862
+ " <td>5.038439e+05</td>\n",
863
+ " <td>8.695752e+06</td>\n",
864
+ " <td>7.920031e+06</td>\n",
865
+ " </tr>\n",
866
+ " <tr>\n",
867
+ " <th>std</th>\n",
868
+ " <td>1.828363e+04</td>\n",
869
+ " <td>3.365374e+07</td>\n",
870
+ " <td>7.496728e+02</td>\n",
871
+ " <td>9.973883e+02</td>\n",
872
+ " <td>9.993589e+03</td>\n",
873
+ " <td>2.263088e+06</td>\n",
874
+ " <td>7.171848e+02</td>\n",
875
+ " <td>6.033935e+01</td>\n",
876
+ " <td>1.860912e+02</td>\n",
877
+ " <td>2.811871e+02</td>\n",
878
+ " <td>...</td>\n",
879
+ " <td>6.364257e+02</td>\n",
880
+ " <td>1.084989e+06</td>\n",
881
+ " <td>6.485999e+05</td>\n",
882
+ " <td>3.933815e+05</td>\n",
883
+ " <td>1.025825e+06</td>\n",
884
+ " <td>5.770923e+05</td>\n",
885
+ " <td>2.363008e+07</td>\n",
886
+ " <td>4.602984e+06</td>\n",
887
+ " <td>2.436689e+07</td>\n",
888
+ " <td>2.336342e+07</td>\n",
889
+ " </tr>\n",
890
+ " <tr>\n",
891
+ " <th>min</th>\n",
892
+ " <td>0.000000e+00</td>\n",
893
+ " <td>-1.300000e+01</td>\n",
894
+ " <td>1.000000e+00</td>\n",
895
+ " <td>0.000000e+00</td>\n",
896
+ " <td>0.000000e+00</td>\n",
897
+ " <td>0.000000e+00</td>\n",
898
+ " <td>0.000000e+00</td>\n",
899
+ " <td>0.000000e+00</td>\n",
900
+ " <td>0.000000e+00</td>\n",
901
+ " <td>0.000000e+00</td>\n",
902
+ " <td>...</td>\n",
903
+ " <td>0.000000e+00</td>\n",
904
+ " <td>-5.368707e+08</td>\n",
905
+ " <td>0.000000e+00</td>\n",
906
+ " <td>0.000000e+00</td>\n",
907
+ " <td>0.000000e+00</td>\n",
908
+ " <td>0.000000e+00</td>\n",
909
+ " <td>0.000000e+00</td>\n",
910
+ " <td>0.000000e+00</td>\n",
911
+ " <td>0.000000e+00</td>\n",
912
+ " <td>0.000000e+00</td>\n",
913
+ " </tr>\n",
914
+ " <tr>\n",
915
+ " <th>25%</th>\n",
916
+ " <td>5.300000e+01</td>\n",
917
+ " <td>1.550000e+02</td>\n",
918
+ " <td>2.000000e+00</td>\n",
919
+ " <td>1.000000e+00</td>\n",
920
+ " <td>1.200000e+01</td>\n",
921
+ " <td>0.000000e+00</td>\n",
922
+ " <td>6.000000e+00</td>\n",
923
+ " <td>0.000000e+00</td>\n",
924
+ " <td>6.000000e+00</td>\n",
925
+ " <td>0.000000e+00</td>\n",
926
+ " <td>...</td>\n",
927
+ " <td>0.000000e+00</td>\n",
928
+ " <td>2.000000e+01</td>\n",
929
+ " <td>0.000000e+00</td>\n",
930
+ " <td>0.000000e+00</td>\n",
931
+ " <td>0.000000e+00</td>\n",
932
+ " <td>0.000000e+00</td>\n",
933
+ " <td>0.000000e+00</td>\n",
934
+ " <td>0.000000e+00</td>\n",
935
+ " <td>0.000000e+00</td>\n",
936
+ " <td>0.000000e+00</td>\n",
937
+ " </tr>\n",
938
+ " <tr>\n",
939
+ " <th>50%</th>\n",
940
+ " <td>8.000000e+01</td>\n",
941
+ " <td>3.131600e+04</td>\n",
942
+ " <td>2.000000e+00</td>\n",
943
+ " <td>2.000000e+00</td>\n",
944
+ " <td>6.200000e+01</td>\n",
945
+ " <td>1.230000e+02</td>\n",
946
+ " <td>3.700000e+01</td>\n",
947
+ " <td>2.000000e+00</td>\n",
948
+ " <td>3.400000e+01</td>\n",
949
+ " <td>0.000000e+00</td>\n",
950
+ " <td>...</td>\n",
951
+ " <td>1.000000e+00</td>\n",
952
+ " <td>2.400000e+01</td>\n",
953
+ " <td>0.000000e+00</td>\n",
954
+ " <td>0.000000e+00</td>\n",
955
+ " <td>0.000000e+00</td>\n",
956
+ " <td>0.000000e+00</td>\n",
957
+ " <td>0.000000e+00</td>\n",
958
+ " <td>0.000000e+00</td>\n",
959
+ " <td>0.000000e+00</td>\n",
960
+ " <td>0.000000e+00</td>\n",
961
+ " </tr>\n",
962
+ " <tr>\n",
963
+ " <th>75%</th>\n",
964
+ " <td>4.430000e+02</td>\n",
965
+ " <td>3.204828e+06</td>\n",
966
+ " <td>5.000000e+00</td>\n",
967
+ " <td>4.000000e+00</td>\n",
968
+ " <td>1.870000e+02</td>\n",
969
+ " <td>4.820000e+02</td>\n",
970
+ " <td>8.100000e+01</td>\n",
971
+ " <td>3.600000e+01</td>\n",
972
+ " <td>5.000000e+01</td>\n",
973
+ " <td>2.616295e+01</td>\n",
974
+ " <td>...</td>\n",
975
+ " <td>2.000000e+00</td>\n",
976
+ " <td>3.200000e+01</td>\n",
977
+ " <td>0.000000e+00</td>\n",
978
+ " <td>0.000000e+00</td>\n",
979
+ " <td>0.000000e+00</td>\n",
980
+ " <td>0.000000e+00</td>\n",
981
+ " <td>0.000000e+00</td>\n",
982
+ " <td>0.000000e+00</td>\n",
983
+ " <td>0.000000e+00</td>\n",
984
+ " <td>0.000000e+00</td>\n",
985
+ " </tr>\n",
986
+ " <tr>\n",
987
+ " <th>max</th>\n",
988
+ " <td>6.553500e+04</td>\n",
989
+ " <td>1.200000e+08</td>\n",
990
+ " <td>2.197590e+05</td>\n",
991
+ " <td>2.919220e+05</td>\n",
992
+ " <td>1.290000e+07</td>\n",
993
+ " <td>6.554530e+08</td>\n",
994
+ " <td>2.482000e+04</td>\n",
995
+ " <td>2.325000e+03</td>\n",
996
+ " <td>5.940857e+03</td>\n",
997
+ " <td>7.125597e+03</td>\n",
998
+ " <td>...</td>\n",
999
+ " <td>2.135570e+05</td>\n",
1000
+ " <td>1.380000e+02</td>\n",
1001
+ " <td>1.100000e+08</td>\n",
1002
+ " <td>7.420000e+07</td>\n",
1003
+ " <td>1.100000e+08</td>\n",
1004
+ " <td>1.100000e+08</td>\n",
1005
+ " <td>1.200000e+08</td>\n",
1006
+ " <td>7.690000e+07</td>\n",
1007
+ " <td>1.200000e+08</td>\n",
1008
+ " <td>1.200000e+08</td>\n",
1009
+ " </tr>\n",
1010
+ " </tbody>\n",
1011
+ "</table>\n",
1012
+ "<p>8 rows × 78 columns</p>\n",
1013
+ "</div>"
1014
+ ]
1015
+ },
1016
+ "execution_count": 8,
1017
+ "metadata": {},
1018
+ "output_type": "execute_result"
1019
+ }
1020
+ ],
1021
+ "execution_count": 8
1022
+ },
1023
+ {
1024
+ "metadata": {
1025
+ "ExecuteTime": {
1026
+ "end_time": "2026-06-22T16:40:42.182449Z",
1027
+ "start_time": "2026-06-22T16:40:42.147460Z"
1028
+ }
1029
+ },
1030
+ "cell_type": "code",
1031
+ "source": "data.columns",
1032
+ "id": "715e095358502819",
1033
+ "outputs": [
1034
+ {
1035
+ "data": {
1036
+ "text/plain": [
1037
+ "Index([' Destination Port', ' Flow Duration', ' Total Fwd Packets',\n",
1038
+ " ' Total Backward Packets', 'Total Length of Fwd Packets',\n",
1039
+ " ' Total Length of Bwd Packets', ' Fwd Packet Length Max',\n",
1040
+ " ' Fwd Packet Length Min', ' Fwd Packet Length Mean',\n",
1041
+ " ' Fwd Packet Length Std', 'Bwd Packet Length Max',\n",
1042
+ " ' Bwd Packet Length Min', ' Bwd Packet Length Mean',\n",
1043
+ " ' Bwd Packet Length Std', 'Flow Bytes/s', ' Flow Packets/s',\n",
1044
+ " ' Flow IAT Mean', ' Flow IAT Std', ' Flow IAT Max', ' Flow IAT Min',\n",
1045
+ " 'Fwd IAT Total', ' Fwd IAT Mean', ' Fwd IAT Std', ' Fwd IAT Max',\n",
1046
+ " ' Fwd IAT Min', 'Bwd IAT Total', ' Bwd IAT Mean', ' Bwd IAT Std',\n",
1047
+ " ' Bwd IAT Max', ' Bwd IAT Min', 'Fwd PSH Flags', ' Bwd PSH Flags',\n",
1048
+ " ' Fwd URG Flags', ' Bwd URG Flags', ' Fwd Header Length',\n",
1049
+ " ' Bwd Header Length', 'Fwd Packets/s', ' Bwd Packets/s',\n",
1050
+ " ' Min Packet Length', ' Max Packet Length', ' Packet Length Mean',\n",
1051
+ " ' Packet Length Std', ' Packet Length Variance', 'FIN Flag Count',\n",
1052
+ " ' SYN Flag Count', ' RST Flag Count', ' PSH Flag Count',\n",
1053
+ " ' ACK Flag Count', ' URG Flag Count', ' CWE Flag Count',\n",
1054
+ " ' ECE Flag Count', ' Down/Up Ratio', ' Average Packet Size',\n",
1055
+ " ' Avg Fwd Segment Size', ' Avg Bwd Segment Size',\n",
1056
+ " ' Fwd Header Length.1', 'Fwd Avg Bytes/Bulk', ' Fwd Avg Packets/Bulk',\n",
1057
+ " ' Fwd Avg Bulk Rate', ' Bwd Avg Bytes/Bulk', ' Bwd Avg Packets/Bulk',\n",
1058
+ " 'Bwd Avg Bulk Rate', 'Subflow Fwd Packets', ' Subflow Fwd Bytes',\n",
1059
+ " ' Subflow Bwd Packets', ' Subflow Bwd Bytes', 'Init_Win_bytes_forward',\n",
1060
+ " ' Init_Win_bytes_backward', ' act_data_pkt_fwd',\n",
1061
+ " ' min_seg_size_forward', 'Active Mean', ' Active Std', ' Active Max',\n",
1062
+ " ' Active Min', 'Idle Mean', ' Idle Std', ' Idle Max', ' Idle Min',\n",
1063
+ " ' Label'],\n",
1064
+ " dtype='str')"
1065
+ ]
1066
+ },
1067
+ "execution_count": 9,
1068
+ "metadata": {},
1069
+ "output_type": "execute_result"
1070
+ }
1071
+ ],
1072
+ "execution_count": 9
1073
+ },
1074
+ {
1075
+ "metadata": {
1076
+ "ExecuteTime": {
1077
+ "end_time": "2026-06-22T16:40:42.275200Z",
1078
+ "start_time": "2026-06-22T16:40:42.250573Z"
1079
+ }
1080
+ },
1081
+ "cell_type": "code",
1082
+ "source": [
1083
+ "# many spaces problem are there in this dataset columns so we have to fix this\n",
1084
+ "data.columns = data.columns.str.strip()\n",
1085
+ "print(data.columns.to_list())"
1086
+ ],
1087
+ "id": "f1d6db43ea05007e",
1088
+ "outputs": [
1089
+ {
1090
+ "name": "stdout",
1091
+ "output_type": "stream",
1092
+ "text": [
1093
+ "['Destination Port', 'Flow Duration', 'Total Fwd Packets', 'Total Backward Packets', 'Total Length of Fwd Packets', 'Total Length of Bwd Packets', 'Fwd Packet Length Max', 'Fwd Packet Length Min', 'Fwd Packet Length Mean', 'Fwd Packet Length Std', 'Bwd Packet Length Max', 'Bwd Packet Length Min', 'Bwd Packet Length Mean', 'Bwd Packet Length Std', 'Flow Bytes/s', 'Flow Packets/s', 'Flow IAT Mean', 'Flow IAT Std', 'Flow IAT Max', 'Flow IAT Min', 'Fwd IAT Total', 'Fwd IAT Mean', 'Fwd IAT Std', 'Fwd IAT Max', 'Fwd IAT Min', 'Bwd IAT Total', 'Bwd IAT Mean', 'Bwd IAT Std', 'Bwd IAT Max', 'Bwd IAT Min', 'Fwd PSH Flags', 'Bwd PSH Flags', 'Fwd URG Flags', 'Bwd URG Flags', 'Fwd Header Length', 'Bwd Header Length', 'Fwd Packets/s', 'Bwd Packets/s', 'Min Packet Length', 'Max Packet Length', 'Packet Length Mean', 'Packet Length Std', 'Packet Length Variance', 'FIN Flag Count', 'SYN Flag Count', 'RST Flag Count', 'PSH Flag Count', 'ACK Flag Count', 'URG Flag Count', 'CWE Flag Count', 'ECE Flag Count', 'Down/Up Ratio', 'Average Packet Size', 'Avg Fwd Segment Size', 'Avg Bwd Segment Size', 'Fwd Header Length.1', 'Fwd Avg Bytes/Bulk', 'Fwd Avg Packets/Bulk', 'Fwd Avg Bulk Rate', 'Bwd Avg Bytes/Bulk', 'Bwd Avg Packets/Bulk', 'Bwd Avg Bulk Rate', 'Subflow Fwd Packets', 'Subflow Fwd Bytes', 'Subflow Bwd Packets', 'Subflow Bwd Bytes', 'Init_Win_bytes_forward', 'Init_Win_bytes_backward', 'act_data_pkt_fwd', 'min_seg_size_forward', 'Active Mean', 'Active Std', 'Active Max', 'Active Min', 'Idle Mean', 'Idle Std', 'Idle Max', 'Idle Min', 'Label']\n"
1094
+ ]
1095
+ }
1096
+ ],
1097
+ "execution_count": 10
1098
+ },
1099
+ {
1100
+ "metadata": {
1101
+ "ExecuteTime": {
1102
+ "end_time": "2026-06-22T16:40:42.445766Z",
1103
+ "start_time": "2026-06-22T16:40:42.340260Z"
1104
+ }
1105
+ },
1106
+ "cell_type": "code",
1107
+ "source": "print(data.isnull().sum())",
1108
+ "id": "446851169cd77bf9",
1109
+ "outputs": [
1110
+ {
1111
+ "name": "stdout",
1112
+ "output_type": "stream",
1113
+ "text": [
1114
+ "Destination Port 0\n",
1115
+ "Flow Duration 0\n",
1116
+ "Total Fwd Packets 0\n",
1117
+ "Total Backward Packets 0\n",
1118
+ "Total Length of Fwd Packets 0\n",
1119
+ " ..\n",
1120
+ "Idle Mean 0\n",
1121
+ "Idle Std 0\n",
1122
+ "Idle Max 0\n",
1123
+ "Idle Min 0\n",
1124
+ "Label 0\n",
1125
+ "Length: 79, dtype: int64\n"
1126
+ ]
1127
+ }
1128
+ ],
1129
+ "execution_count": 11
1130
+ },
1131
+ {
1132
+ "metadata": {
1133
+ "ExecuteTime": {
1134
+ "end_time": "2026-06-22T16:40:42.582964Z",
1135
+ "start_time": "2026-06-22T16:40:42.483002Z"
1136
+ }
1137
+ },
1138
+ "cell_type": "code",
1139
+ "source": "print(data.isnull().sum().sum())",
1140
+ "id": "caa8c41a7857d783",
1141
+ "outputs": [
1142
+ {
1143
+ "name": "stdout",
1144
+ "output_type": "stream",
1145
+ "text": [
1146
+ "1358\n"
1147
+ ]
1148
+ }
1149
+ ],
1150
+ "execution_count": 12
1151
+ },
1152
+ {
1153
+ "metadata": {
1154
+ "ExecuteTime": {
1155
+ "end_time": "2026-06-22T16:40:42.683403Z",
1156
+ "start_time": "2026-06-22T16:40:42.584620Z"
1157
+ }
1158
+ },
1159
+ "cell_type": "code",
1160
+ "source": [
1161
+ "missing = data.isnull().sum()\n",
1162
+ "print(missing[missing>0])"
1163
+ ],
1164
+ "id": "ce2bff78b4cd3932",
1165
+ "outputs": [
1166
+ {
1167
+ "name": "stdout",
1168
+ "output_type": "stream",
1169
+ "text": [
1170
+ "Flow Bytes/s 1358\n",
1171
+ "dtype: int64\n"
1172
+ ]
1173
+ }
1174
+ ],
1175
+ "execution_count": 13
1176
+ },
1177
+ {
1178
+ "metadata": {
1179
+ "ExecuteTime": {
1180
+ "end_time": "2026-06-22T16:40:43.380791Z",
1181
+ "start_time": "2026-06-22T16:40:42.684060Z"
1182
+ }
1183
+ },
1184
+ "cell_type": "code",
1185
+ "source": [
1186
+ "# we can drop those rows because if we fill by any mean or median then maybe fake behavior\n",
1187
+ "data = data.dropna()\n",
1188
+ "print(data.shape)\n",
1189
+ "print(data.isnull().sum().sum())"
1190
+ ],
1191
+ "id": "633b915c3ab452e8",
1192
+ "outputs": [
1193
+ {
1194
+ "name": "stdout",
1195
+ "output_type": "stream",
1196
+ "text": [
1197
+ "(2829385, 79)\n",
1198
+ "0\n"
1199
+ ]
1200
+ }
1201
+ ],
1202
+ "execution_count": 14
1203
+ },
1204
+ {
1205
+ "metadata": {
1206
+ "ExecuteTime": {
1207
+ "end_time": "2026-06-22T16:40:43.482924Z",
1208
+ "start_time": "2026-06-22T16:40:43.413062Z"
1209
+ }
1210
+ },
1211
+ "cell_type": "code",
1212
+ "source": [
1213
+ "# check if there is any infinite values, if there is any it may break the model --> gradient explosion, so we will replace those with NaN and then drop those\n",
1214
+ "print(np.isinf(data.select_dtypes(include=np.number)).sum().sum()) #find inf values"
1215
+ ],
1216
+ "id": "c57c6fbc52f9bd9c",
1217
+ "outputs": [
1218
+ {
1219
+ "name": "stdout",
1220
+ "output_type": "stream",
1221
+ "text": [
1222
+ "3018\n"
1223
+ ]
1224
+ }
1225
+ ],
1226
+ "execution_count": 15
1227
+ },
1228
+ {
1229
+ "metadata": {
1230
+ "ExecuteTime": {
1231
+ "end_time": "2026-06-22T16:40:44.671005Z",
1232
+ "start_time": "2026-06-22T16:40:43.483679Z"
1233
+ }
1234
+ },
1235
+ "cell_type": "code",
1236
+ "source": [
1237
+ "#replace it with NaN\n",
1238
+ "data.replace([np.inf, -np.inf], np.nan, inplace=True)\n",
1239
+ "data = data.dropna()\n",
1240
+ "print(data.shape)"
1241
+ ],
1242
+ "id": "87242e8ce315d6b2",
1243
+ "outputs": [
1244
+ {
1245
+ "name": "stdout",
1246
+ "output_type": "stream",
1247
+ "text": [
1248
+ "(2827876, 79)\n"
1249
+ ]
1250
+ }
1251
+ ],
1252
+ "execution_count": 16
1253
+ },
1254
+ {
1255
+ "metadata": {},
1256
+ "cell_type": "markdown",
1257
+ "source": "## Removing Duplicates",
1258
+ "id": "bcb28d65b041c579"
1259
+ },
1260
+ {
1261
+ "metadata": {
1262
+ "ExecuteTime": {
1263
+ "end_time": "2026-06-22T16:40:48.104273Z",
1264
+ "start_time": "2026-06-22T16:40:44.689890Z"
1265
+ }
1266
+ },
1267
+ "cell_type": "code",
1268
+ "source": "print(\"Duplicate Rows : \", data.duplicated().sum())",
1269
+ "id": "ad2951643a2a3412",
1270
+ "outputs": [
1271
+ {
1272
+ "name": "stdout",
1273
+ "output_type": "stream",
1274
+ "text": [
1275
+ "Duplicate Rows : 307078\n"
1276
+ ]
1277
+ }
1278
+ ],
1279
+ "execution_count": 17
1280
+ },
1281
+ {
1282
+ "metadata": {
1283
+ "ExecuteTime": {
1284
+ "end_time": "2026-06-22T16:40:51.760762Z",
1285
+ "start_time": "2026-06-22T16:40:48.121471Z"
1286
+ }
1287
+ },
1288
+ "cell_type": "code",
1289
+ "source": [
1290
+ "data = data.drop_duplicates()\n",
1291
+ "print(\"Shape of data after removing duplicates \" ,data.shape)"
1292
+ ],
1293
+ "id": "717284c3f7bd8dca",
1294
+ "outputs": [
1295
+ {
1296
+ "name": "stdout",
1297
+ "output_type": "stream",
1298
+ "text": [
1299
+ "Shape of data after removing duplicates (2520798, 79)\n"
1300
+ ]
1301
+ }
1302
+ ],
1303
+ "execution_count": 18
1304
+ },
1305
+ {
1306
+ "metadata": {
1307
+ "ExecuteTime": {
1308
+ "end_time": "2026-06-22T16:42:43.945659Z",
1309
+ "start_time": "2026-06-22T16:42:43.932390Z"
1310
+ }
1311
+ },
1312
+ "cell_type": "code",
1313
+ "source": [
1314
+ "## fix shape inside label also\n",
1315
+ "print(data.columns.tolist())"
1316
+ ],
1317
+ "id": "48b559d7ab6e82f1",
1318
+ "outputs": [
1319
+ {
1320
+ "name": "stdout",
1321
+ "output_type": "stream",
1322
+ "text": [
1323
+ "['Destination Port', 'Flow Duration', 'Total Fwd Packets', 'Total Backward Packets', 'Total Length of Fwd Packets', 'Total Length of Bwd Packets', 'Fwd Packet Length Max', 'Fwd Packet Length Min', 'Fwd Packet Length Mean', 'Fwd Packet Length Std', 'Bwd Packet Length Max', 'Bwd Packet Length Min', 'Bwd Packet Length Mean', 'Bwd Packet Length Std', 'Flow Bytes/s', 'Flow Packets/s', 'Flow IAT Mean', 'Flow IAT Std', 'Flow IAT Max', 'Flow IAT Min', 'Fwd IAT Total', 'Fwd IAT Mean', 'Fwd IAT Std', 'Fwd IAT Max', 'Fwd IAT Min', 'Bwd IAT Total', 'Bwd IAT Mean', 'Bwd IAT Std', 'Bwd IAT Max', 'Bwd IAT Min', 'Fwd PSH Flags', 'Bwd PSH Flags', 'Fwd URG Flags', 'Bwd URG Flags', 'Fwd Header Length', 'Bwd Header Length', 'Fwd Packets/s', 'Bwd Packets/s', 'Min Packet Length', 'Max Packet Length', 'Packet Length Mean', 'Packet Length Std', 'Packet Length Variance', 'FIN Flag Count', 'SYN Flag Count', 'RST Flag Count', 'PSH Flag Count', 'ACK Flag Count', 'URG Flag Count', 'CWE Flag Count', 'ECE Flag Count', 'Down/Up Ratio', 'Average Packet Size', 'Avg Fwd Segment Size', 'Avg Bwd Segment Size', 'Fwd Header Length.1', 'Fwd Avg Bytes/Bulk', 'Fwd Avg Packets/Bulk', 'Fwd Avg Bulk Rate', 'Bwd Avg Bytes/Bulk', 'Bwd Avg Packets/Bulk', 'Bwd Avg Bulk Rate', 'Subflow Fwd Packets', 'Subflow Fwd Bytes', 'Subflow Bwd Packets', 'Subflow Bwd Bytes', 'Init_Win_bytes_forward', 'Init_Win_bytes_backward', 'act_data_pkt_fwd', 'min_seg_size_forward', 'Active Mean', 'Active Std', 'Active Max', 'Active Min', 'Idle Mean', 'Idle Std', 'Idle Max', 'Idle Min', 'Label']\n"
1324
+ ]
1325
+ }
1326
+ ],
1327
+ "execution_count": 21
1328
+ },
1329
+ {
1330
+ "metadata": {
1331
+ "ExecuteTime": {
1332
+ "end_time": "2026-06-22T16:46:16.232663Z",
1333
+ "start_time": "2026-06-22T16:46:15.985514Z"
1334
+ }
1335
+ },
1336
+ "cell_type": "code",
1337
+ "source": [
1338
+ "data['Label'] = data['Label'].str.strip()\n",
1339
+ "print(data['Label'].value_counts())\n",
1340
+ "print(\"Total Unique Labels : \", data['Label'].nunique())"
1341
+ ],
1342
+ "id": "42396f003eb93812",
1343
+ "outputs": [
1344
+ {
1345
+ "name": "stdout",
1346
+ "output_type": "stream",
1347
+ "text": [
1348
+ "Label\n",
1349
+ "BENIGN 2095057\n",
1350
+ "DoS Hulk 172846\n",
1351
+ "DDoS 128014\n",
1352
+ "PortScan 90694\n",
1353
+ "DoS GoldenEye 10286\n",
1354
+ "FTP-Patator 5931\n",
1355
+ "DoS slowloris 5385\n",
1356
+ "DoS Slowhttptest 5228\n",
1357
+ "SSH-Patator 3219\n",
1358
+ "Bot 1948\n",
1359
+ "Web Attack � Brute Force 1470\n",
1360
+ "Web Attack � XSS 652\n",
1361
+ "Infiltration 36\n",
1362
+ "Web Attack � Sql Injection 21\n",
1363
+ "Heartbleed 11\n",
1364
+ "Name: count, dtype: int64\n",
1365
+ "Total Unique Labels : 15\n"
1366
+ ]
1367
+ }
1368
+ ],
1369
+ "execution_count": 23
1370
+ },
1371
+ {
1372
+ "metadata": {
1373
+ "ExecuteTime": {
1374
+ "end_time": "2026-06-22T16:48:47.812315Z",
1375
+ "start_time": "2026-06-22T16:48:25.894520Z"
1376
+ }
1377
+ },
1378
+ "cell_type": "code",
1379
+ "source": "data.to_csv('Cleaned_data.csv', index=False)",
1380
+ "id": "a17f60210b3d5077",
1381
+ "outputs": [],
1382
+ "execution_count": 24
1383
+ }
1384
+ ],
1385
+ "metadata": {
1386
+ "kernelspec": {
1387
+ "display_name": "Python 3",
1388
+ "language": "python",
1389
+ "name": "python3"
1390
+ },
1391
+ "language_info": {
1392
+ "codemirror_mode": {
1393
+ "name": "ipython",
1394
+ "version": 2
1395
+ },
1396
+ "file_extension": ".py",
1397
+ "mimetype": "text/x-python",
1398
+ "name": "python",
1399
+ "nbconvert_exporter": "python",
1400
+ "pygments_lexer": "ipython2",
1401
+ "version": "2.7.6"
1402
+ }
1403
+ },
1404
+ "nbformat": 4,
1405
+ "nbformat_minor": 5
1406
+ }
notebooks/02_EDA.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
notebooks/03_modelling.ipynb ADDED
@@ -0,0 +1,355 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "id": "initial_id",
6
+ "metadata": {
7
+ "collapsed": true,
8
+ "ExecuteTime": {
9
+ "end_time": "2026-06-30T14:55:38.259769Z",
10
+ "start_time": "2026-06-30T14:55:37.724976Z"
11
+ }
12
+ },
13
+ "source": [
14
+ "import pandas as pd\n",
15
+ "import numpy as np\n",
16
+ "import matplotlib.pyplot as plt\n",
17
+ "import seaborn as sns"
18
+ ],
19
+ "outputs": [],
20
+ "execution_count": 1
21
+ },
22
+ {
23
+ "metadata": {
24
+ "ExecuteTime": {
25
+ "end_time": "2026-06-30T14:57:07.241706Z",
26
+ "start_time": "2026-06-30T14:57:02.508449Z"
27
+ }
28
+ },
29
+ "cell_type": "code",
30
+ "source": "data = pd.read_csv('../Cleaned_data.csv')",
31
+ "id": "a3d6404b70c8c5a1",
32
+ "outputs": [],
33
+ "execution_count": 7
34
+ },
35
+ {
36
+ "metadata": {
37
+ "ExecuteTime": {
38
+ "end_time": "2026-06-30T14:57:07.621114Z",
39
+ "start_time": "2026-06-30T14:57:07.601409Z"
40
+ }
41
+ },
42
+ "cell_type": "code",
43
+ "source": "print('Data Shape::',data.shape )",
44
+ "id": "fd40b42eaa1ccce1",
45
+ "outputs": [
46
+ {
47
+ "name": "stdout",
48
+ "output_type": "stream",
49
+ "text": [
50
+ "Data Shape:: (2520798, 79)\n"
51
+ ]
52
+ }
53
+ ],
54
+ "execution_count": 8
55
+ },
56
+ {
57
+ "metadata": {
58
+ "ExecuteTime": {
59
+ "end_time": "2026-06-30T14:57:16.859802Z",
60
+ "start_time": "2026-06-30T14:57:16.794596Z"
61
+ }
62
+ },
63
+ "cell_type": "code",
64
+ "source": [
65
+ "## we have to encode those categories like BENING to 0 and others to 1...2...etc\n",
66
+ "print('Labels :',data['Label'].unique())"
67
+ ],
68
+ "id": "4c2b7cb5ac89a68d",
69
+ "outputs": [
70
+ {
71
+ "name": "stdout",
72
+ "output_type": "stream",
73
+ "text": [
74
+ "Labels : <StringArray>\n",
75
+ "[ 'BENIGN', 'FTP-Patator',\n",
76
+ " 'SSH-Patator', 'DoS slowloris',\n",
77
+ " 'DoS Slowhttptest', 'DoS Hulk',\n",
78
+ " 'DoS GoldenEye', 'Heartbleed',\n",
79
+ " 'Web Attack � Brute Force', 'Web Attack � XSS',\n",
80
+ " 'Web Attack � Sql Injection', 'Infiltration',\n",
81
+ " 'Bot', 'PortScan',\n",
82
+ " 'DDoS']\n",
83
+ "Length: 15, dtype: str\n"
84
+ ]
85
+ }
86
+ ],
87
+ "execution_count": 9
88
+ },
89
+ {
90
+ "metadata": {
91
+ "ExecuteTime": {
92
+ "end_time": "2026-06-30T14:57:20.699603Z",
93
+ "start_time": "2026-06-30T14:57:20.375465Z"
94
+ }
95
+ },
96
+ "cell_type": "code",
97
+ "source": [
98
+ "from sklearn.preprocessing import LabelEncoder,StandardScaler\n",
99
+ "le = LabelEncoder()\n",
100
+ "data['New_Label']=le.fit_transform(data['Label'])\n",
101
+ "print(le.classes_)"
102
+ ],
103
+ "id": "b1c0c404b464024a",
104
+ "outputs": [
105
+ {
106
+ "name": "stdout",
107
+ "output_type": "stream",
108
+ "text": [
109
+ "['BENIGN' 'Bot' 'DDoS' 'DoS GoldenEye' 'DoS Hulk' 'DoS Slowhttptest'\n",
110
+ " 'DoS slowloris' 'FTP-Patator' 'Heartbleed' 'Infiltration' 'PortScan'\n",
111
+ " 'SSH-Patator' 'Web Attack � Brute Force' 'Web Attack � Sql Injection'\n",
112
+ " 'Web Attack � XSS']\n"
113
+ ]
114
+ }
115
+ ],
116
+ "execution_count": 10
117
+ },
118
+ {
119
+ "metadata": {
120
+ "ExecuteTime": {
121
+ "end_time": "2026-06-30T14:57:22.949246Z",
122
+ "start_time": "2026-06-30T14:57:22.922049Z"
123
+ }
124
+ },
125
+ "cell_type": "code",
126
+ "source": [
127
+ "print(f\"Total columns: {len(data.columns)}\")\n",
128
+ "print(data.columns.tolist())"
129
+ ],
130
+ "id": "4f9c54f4f889e992",
131
+ "outputs": [
132
+ {
133
+ "name": "stdout",
134
+ "output_type": "stream",
135
+ "text": [
136
+ "Total columns: 80\n",
137
+ "['Destination Port', 'Flow Duration', 'Total Fwd Packets', 'Total Backward Packets', 'Total Length of Fwd Packets', 'Total Length of Bwd Packets', 'Fwd Packet Length Max', 'Fwd Packet Length Min', 'Fwd Packet Length Mean', 'Fwd Packet Length Std', 'Bwd Packet Length Max', 'Bwd Packet Length Min', 'Bwd Packet Length Mean', 'Bwd Packet Length Std', 'Flow Bytes/s', 'Flow Packets/s', 'Flow IAT Mean', 'Flow IAT Std', 'Flow IAT Max', 'Flow IAT Min', 'Fwd IAT Total', 'Fwd IAT Mean', 'Fwd IAT Std', 'Fwd IAT Max', 'Fwd IAT Min', 'Bwd IAT Total', 'Bwd IAT Mean', 'Bwd IAT Std', 'Bwd IAT Max', 'Bwd IAT Min', 'Fwd PSH Flags', 'Bwd PSH Flags', 'Fwd URG Flags', 'Bwd URG Flags', 'Fwd Header Length', 'Bwd Header Length', 'Fwd Packets/s', 'Bwd Packets/s', 'Min Packet Length', 'Max Packet Length', 'Packet Length Mean', 'Packet Length Std', 'Packet Length Variance', 'FIN Flag Count', 'SYN Flag Count', 'RST Flag Count', 'PSH Flag Count', 'ACK Flag Count', 'URG Flag Count', 'CWE Flag Count', 'ECE Flag Count', 'Down/Up Ratio', 'Average Packet Size', 'Avg Fwd Segment Size', 'Avg Bwd Segment Size', 'Fwd Header Length.1', 'Fwd Avg Bytes/Bulk', 'Fwd Avg Packets/Bulk', 'Fwd Avg Bulk Rate', 'Bwd Avg Bytes/Bulk', 'Bwd Avg Packets/Bulk', 'Bwd Avg Bulk Rate', 'Subflow Fwd Packets', 'Subflow Fwd Bytes', 'Subflow Bwd Packets', 'Subflow Bwd Bytes', 'Init_Win_bytes_forward', 'Init_Win_bytes_backward', 'act_data_pkt_fwd', 'min_seg_size_forward', 'Active Mean', 'Active Std', 'Active Max', 'Active Min', 'Idle Mean', 'Idle Std', 'Idle Max', 'Idle Min', 'Label', 'New_Label']\n"
138
+ ]
139
+ }
140
+ ],
141
+ "execution_count": 11
142
+ },
143
+ {
144
+ "metadata": {
145
+ "ExecuteTime": {
146
+ "end_time": "2026-06-30T14:57:25.425183Z",
147
+ "start_time": "2026-06-30T14:57:25.394293Z"
148
+ }
149
+ },
150
+ "cell_type": "code",
151
+ "source": [
152
+ "data_to_dl = data.drop(columns=['Label'])\n",
153
+ "print('Remaining columns:',len(data_to_dl.columns))"
154
+ ],
155
+ "id": "f748fed425b4474d",
156
+ "outputs": [
157
+ {
158
+ "name": "stdout",
159
+ "output_type": "stream",
160
+ "text": [
161
+ "Remaining columns: 79\n"
162
+ ]
163
+ }
164
+ ],
165
+ "execution_count": 12
166
+ },
167
+ {
168
+ "metadata": {
169
+ "ExecuteTime": {
170
+ "end_time": "2026-06-30T14:57:28.166228Z",
171
+ "start_time": "2026-06-30T14:57:28.149963Z"
172
+ }
173
+ },
174
+ "cell_type": "code",
175
+ "source": [
176
+ "X = data_to_dl.drop(columns=['New_Label'])\n",
177
+ "Y = data_to_dl['New_Label']\n",
178
+ "\n",
179
+ "print(f\"Features shape (X): {X.shape}\")\n",
180
+ "print(f\"Target shape (Y): {Y.shape}\")"
181
+ ],
182
+ "id": "26c68ae50c492420",
183
+ "outputs": [
184
+ {
185
+ "name": "stdout",
186
+ "output_type": "stream",
187
+ "text": [
188
+ "Features shape (X): (2520798, 78)\n",
189
+ "Target shape (Y): (2520798,)\n"
190
+ ]
191
+ }
192
+ ],
193
+ "execution_count": 13
194
+ },
195
+ {
196
+ "metadata": {
197
+ "ExecuteTime": {
198
+ "end_time": "2026-06-30T14:59:57.553115Z",
199
+ "start_time": "2026-06-30T14:59:52.475959Z"
200
+ }
201
+ },
202
+ "cell_type": "code",
203
+ "source": [
204
+ "## HERE WE HAVE TO APPLY S.M.O.T.E but only to TRAIN SPLIT\n",
205
+ "\n",
206
+ "from sklearn.model_selection import train_test_split\n",
207
+ "X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size = 0.2, random_state = 42)\n",
208
+ "\n",
209
+ "print(f'X_train shape: {X_train.shape}')\n",
210
+ "print(f'X_test shape: {X_test.shape}')\n",
211
+ "print(f'Y_train distribution: {Y_train.value_counts()}')"
212
+ ],
213
+ "id": "757fac208c382bb0",
214
+ "outputs": [
215
+ {
216
+ "name": "stdout",
217
+ "output_type": "stream",
218
+ "text": [
219
+ "X_train shape: (2016638, 78)\n",
220
+ "X_test shape: (504160, 78)\n",
221
+ "Y_train distribution: New_Label\n",
222
+ "0 1675805\n",
223
+ "4 138511\n",
224
+ "2 102513\n",
225
+ "10 72507\n",
226
+ "3 8207\n",
227
+ "7 4709\n",
228
+ "6 4334\n",
229
+ "5 4176\n",
230
+ "11 2553\n",
231
+ "1 1560\n",
232
+ "12 1175\n",
233
+ "14 536\n",
234
+ "9 27\n",
235
+ "13 16\n",
236
+ "8 9\n",
237
+ "Name: count, dtype: int64\n"
238
+ ]
239
+ }
240
+ ],
241
+ "execution_count": 14
242
+ },
243
+ {
244
+ "metadata": {
245
+ "ExecuteTime": {
246
+ "end_time": "2026-06-30T15:01:52.339866Z",
247
+ "start_time": "2026-06-30T15:01:51.036901Z"
248
+ }
249
+ },
250
+ "cell_type": "code",
251
+ "source": [
252
+ "#Now we have to encode using StandardScaler\n",
253
+ "from sklearn.preprocessing import StandardScaler\n",
254
+ "scaler = StandardScaler()\n",
255
+ "X_train_scaled = scaler.fit_transform(X_train)\n",
256
+ "X_test_scaled = scaler.transform(X_test)\n",
257
+ "print(f'X_train scaled shape: {X_train_scaled.shape}')\n",
258
+ "print(f\"Mean of first feature (should be ~0): {X_train_scaled[:, 0].mean():.4f}\")\n",
259
+ "print(f\"Std of first feature (should be ~1): {X_train_scaled[:, 0].std():.4f}\")"
260
+ ],
261
+ "id": "2d6b079049a36bfa",
262
+ "outputs": [
263
+ {
264
+ "name": "stdout",
265
+ "output_type": "stream",
266
+ "text": [
267
+ "X_train scaled shape: (2016638, 78)\n",
268
+ "Mean of first feature (should be ~0): -0.0000\n",
269
+ "Std of first feature (should be ~1): 1.0000\n"
270
+ ]
271
+ }
272
+ ],
273
+ "execution_count": 15
274
+ },
275
+ {
276
+ "metadata": {
277
+ "ExecuteTime": {
278
+ "end_time": "2026-06-30T15:15:02.117853Z",
279
+ "start_time": "2026-06-30T15:12:53.513901Z"
280
+ }
281
+ },
282
+ "cell_type": "code",
283
+ "source": [
284
+ "# SMOTE --> Synthetic Minority Oversampling Technique\n",
285
+ "from imblearn.over_sampling import SMOTE\n",
286
+ "smote = SMOTE(random_state=42)\n",
287
+ "X_train_smote, Y_train_smote = smote.fit_resample(X_train_scaled, Y_train)\n",
288
+ "print(f'BEFORE SMOTE SHAPE: {X_train_scaled.shape}')\n",
289
+ "print(f'AFTER SMOTE SHAPE: {X_train_smote.shape}')\n",
290
+ "print(f\"\\nClass distribution after SMOTE:\")\n",
291
+ "print(pd.Series(Y_train_smote).value_counts())"
292
+ ],
293
+ "id": "d951396573721ff",
294
+ "outputs": [
295
+ {
296
+ "name": "stdout",
297
+ "output_type": "stream",
298
+ "text": [
299
+ "BEFORE SMOTE SHAPE: (2016638, 78)\n",
300
+ "AFTER SMOTE SHAPE: (25137075, 78)\n",
301
+ "\n",
302
+ "Class distribution after SMOTE:\n",
303
+ "New_Label\n",
304
+ "0 1675805\n",
305
+ "2 1675805\n",
306
+ "4 1675805\n",
307
+ "10 1675805\n",
308
+ "14 1675805\n",
309
+ "5 1675805\n",
310
+ "7 1675805\n",
311
+ "12 1675805\n",
312
+ "3 1675805\n",
313
+ "1 1675805\n",
314
+ "11 1675805\n",
315
+ "6 1675805\n",
316
+ "13 1675805\n",
317
+ "8 1675805\n",
318
+ "9 1675805\n",
319
+ "Name: count, dtype: int64\n"
320
+ ]
321
+ }
322
+ ],
323
+ "execution_count": 18
324
+ },
325
+ {
326
+ "metadata": {},
327
+ "cell_type": "code",
328
+ "outputs": [],
329
+ "execution_count": null,
330
+ "source": "",
331
+ "id": "38c105a1f64a18ae"
332
+ }
333
+ ],
334
+ "metadata": {
335
+ "kernelspec": {
336
+ "display_name": "Python 3",
337
+ "language": "python",
338
+ "name": "python3"
339
+ },
340
+ "language_info": {
341
+ "codemirror_mode": {
342
+ "name": "ipython",
343
+ "version": 2
344
+ },
345
+ "file_extension": ".py",
346
+ "mimetype": "text/x-python",
347
+ "name": "python",
348
+ "nbconvert_exporter": "python",
349
+ "pygments_lexer": "ipython2",
350
+ "version": "2.7.6"
351
+ }
352
+ },
353
+ "nbformat": 4,
354
+ "nbformat_minor": 5
355
+ }
requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ numpy
2
+ pandas
3
+ matplotlib
4
+ seaborn
5
+ scikit-learn
6
+ imbalanced-learn
7
+ jupyter
8
+ scipy