Upload folder using huggingface_hub
Browse files- README.md +215 -0
- adaboost.pkl +3 -0
- decision_tree.pkl +3 -0
- extra_trees_classifier.pkl +3 -0
- gaussian_naive_bayes.pkl +3 -0
- gradient_boosting_classifier.pkl +3 -0
- label_encoder.pkl +3 -0
- logistic_regression.pkl +3 -0
- mlp_classifier.pkl +3 -0
- random_forest.pkl +3 -0
- scaler.pkl +3 -0
- sgd_classifier.pkl +3 -0
- xgboost.pkl +3 -0
README.md
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Malicious URL Detection Models
|
| 2 |
+
|
| 3 |
+
This directory contains trained machine learning models for detecting malicious URLs. The models are trained to classify URLs into four categories:
|
| 4 |
+
- **benign**
|
| 5 |
+
- **defacement**
|
| 6 |
+
- **malware**
|
| 7 |
+
- **phishing**
|
| 8 |
+
|
| 9 |
+
## Model Performance Summary
|
| 10 |
+
|
| 11 |
+
The following table summarizes the accuracy of each model on the test dataset:
|
| 12 |
+
|
| 13 |
+
| Model | Accuracy |
|
| 14 |
+
|-------|----------|
|
| 15 |
+
| **Extra Trees Classifier** | **97%** |
|
| 16 |
+
| **Random Forest** | **97%** |
|
| 17 |
+
| **Decision Tree** | **96%** |
|
| 18 |
+
| **MLP Classifier** | **96%** |
|
| 19 |
+
| **XGBoost** | **96%** |
|
| 20 |
+
| **Gradient Boosting Classifier** | **94%** |
|
| 21 |
+
| **Logistic Regression** | **87%** |
|
| 22 |
+
| **SGD Classifier** | **87%** |
|
| 23 |
+
| **Adaboost** | **85%** |
|
| 24 |
+
| **Gaussian Naive Bayes** | **80%** |
|
| 25 |
+
|
| 26 |
+
## Detailed Performance Reports
|
| 27 |
+
|
| 28 |
+
### Adaboost
|
| 29 |
+
- **Accuracy:** 0.85
|
| 30 |
+
- **Report:**
|
| 31 |
+
```
|
| 32 |
+
precision recall f1-score support
|
| 33 |
+
|
| 34 |
+
benign 0.90 0.97 0.93 85778
|
| 35 |
+
defacement 0.82 0.76 0.79 19104
|
| 36 |
+
malware 0.55 0.74 0.63 6521
|
| 37 |
+
phishing 0.68 0.42 0.52 18836
|
| 38 |
+
|
| 39 |
+
accuracy 0.85 130239
|
| 40 |
+
macro avg 0.74 0.72 0.72 130239
|
| 41 |
+
weighted avg 0.84 0.85 0.84 130239
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
+
### Decision Tree
|
| 45 |
+
- **Accuracy:** 0.96
|
| 46 |
+
- **Report:**
|
| 47 |
+
```
|
| 48 |
+
precision recall f1-score support
|
| 49 |
+
|
| 50 |
+
benign 0.97 0.98 0.98 85778
|
| 51 |
+
defacement 0.98 0.99 0.98 19104
|
| 52 |
+
malware 0.95 0.94 0.95 6521
|
| 53 |
+
phishing 0.87 0.85 0.86 18836
|
| 54 |
+
|
| 55 |
+
accuracy 0.96 130239
|
| 56 |
+
macro avg 0.95 0.94 0.94 130239
|
| 57 |
+
weighted avg 0.96 0.96 0.96 130239
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
### Extra Trees Classifier
|
| 61 |
+
- **Accuracy:** 0.97
|
| 62 |
+
- **Report:**
|
| 63 |
+
```
|
| 64 |
+
precision recall f1-score support
|
| 65 |
+
|
| 66 |
+
benign 0.97 0.98 0.98 85778
|
| 67 |
+
defacement 0.98 0.99 0.99 19104
|
| 68 |
+
malware 0.98 0.94 0.96 6521
|
| 69 |
+
phishing 0.91 0.86 0.88 18836
|
| 70 |
+
|
| 71 |
+
accuracy 0.97 130239
|
| 72 |
+
macro avg 0.96 0.95 0.95 130239
|
| 73 |
+
weighted avg 0.97 0.97 0.97 130239
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
### Gaussian Naive Bayes
|
| 77 |
+
- **Accuracy:** 0.80
|
| 78 |
+
- **Report:**
|
| 79 |
+
```
|
| 80 |
+
precision recall f1-score support
|
| 81 |
+
|
| 82 |
+
benign 0.86 0.90 0.88 85778
|
| 83 |
+
defacement 0.67 0.99 0.80 19104
|
| 84 |
+
malware 0.63 0.69 0.66 6521
|
| 85 |
+
phishing 0.68 0.19 0.29 18836
|
| 86 |
+
|
| 87 |
+
accuracy 0.80 130239
|
| 88 |
+
macro avg 0.71 0.69 0.66 130239
|
| 89 |
+
weighted avg 0.80 0.80 0.77 130239
|
| 90 |
+
```
|
| 91 |
+
|
| 92 |
+
### Gradient Boosting Classifier
|
| 93 |
+
- **Accuracy:** 0.94
|
| 94 |
+
- **Report:**
|
| 95 |
+
```
|
| 96 |
+
precision recall f1-score support
|
| 97 |
+
|
| 98 |
+
benign 0.96 0.99 0.97 85778
|
| 99 |
+
defacement 0.92 0.97 0.94 19104
|
| 100 |
+
malware 0.94 0.80 0.87 6521
|
| 101 |
+
phishing 0.89 0.78 0.83 18836
|
| 102 |
+
|
| 103 |
+
accuracy 0.94 130239
|
| 104 |
+
macro avg 0.93 0.88 0.90 130239
|
| 105 |
+
weighted avg 0.94 0.94 0.94 130239
|
| 106 |
+
```
|
| 107 |
+
|
| 108 |
+
### Logistic Regression
|
| 109 |
+
- **Accuracy:** 0.87
|
| 110 |
+
- **Report:**
|
| 111 |
+
```
|
| 112 |
+
precision recall f1-score support
|
| 113 |
+
|
| 114 |
+
benign 0.89 0.97 0.93 85778
|
| 115 |
+
defacement 0.85 0.95 0.90 19104
|
| 116 |
+
malware 0.81 0.69 0.74 6521
|
| 117 |
+
phishing 0.77 0.42 0.55 18836
|
| 118 |
+
|
| 119 |
+
accuracy 0.87 130239
|
| 120 |
+
macro avg 0.83 0.76 0.78 130239
|
| 121 |
+
weighted avg 0.87 0.87 0.86 130239
|
| 122 |
+
```
|
| 123 |
+
|
| 124 |
+
### MLP Classifier
|
| 125 |
+
- **Accuracy:** 0.96
|
| 126 |
+
- **Report:**
|
| 127 |
+
```
|
| 128 |
+
precision recall f1-score support
|
| 129 |
+
|
| 130 |
+
benign 0.97 0.98 0.98 85778
|
| 131 |
+
defacement 0.97 0.97 0.97 19104
|
| 132 |
+
malware 0.95 0.90 0.92 6521
|
| 133 |
+
phishing 0.88 0.83 0.86 18836
|
| 134 |
+
|
| 135 |
+
accuracy 0.96 130239
|
| 136 |
+
macro avg 0.94 0.92 0.93 130239
|
| 137 |
+
weighted avg 0.96 0.96 0.96 130239
|
| 138 |
+
```
|
| 139 |
+
|
| 140 |
+
### Random Forest
|
| 141 |
+
- **Accuracy:** 0.97
|
| 142 |
+
- **Report:**
|
| 143 |
+
```
|
| 144 |
+
precision recall f1-score support
|
| 145 |
+
|
| 146 |
+
benign 0.98 0.98 0.98 85778
|
| 147 |
+
defacement 0.98 0.99 0.99 19104
|
| 148 |
+
malware 0.98 0.94 0.96 6521
|
| 149 |
+
phishing 0.91 0.87 0.89 18836
|
| 150 |
+
|
| 151 |
+
accuracy 0.97 130239
|
| 152 |
+
macro avg 0.96 0.95 0.95 130239
|
| 153 |
+
weighted avg 0.97 0.97 0.97 130239
|
| 154 |
+
```
|
| 155 |
+
|
| 156 |
+
### SGD Classifier
|
| 157 |
+
- **Accuracy:** 0.87
|
| 158 |
+
- **Report:**
|
| 159 |
+
```
|
| 160 |
+
precision recall f1-score support
|
| 161 |
+
|
| 162 |
+
benign 0.89 0.96 0.93 85778
|
| 163 |
+
defacement 0.83 0.95 0.89 19104
|
| 164 |
+
malware 0.79 0.71 0.75 6521
|
| 165 |
+
phishing 0.74 0.40 0.52 18836
|
| 166 |
+
|
| 167 |
+
accuracy 0.87 130239
|
| 168 |
+
macro avg 0.81 0.76 0.77 130239
|
| 169 |
+
weighted avg 0.86 0.87 0.85 130239
|
| 170 |
+
```
|
| 171 |
+
|
| 172 |
+
### XGBoost
|
| 173 |
+
- **Accuracy:** 0.96
|
| 174 |
+
- **Report:**
|
| 175 |
+
```
|
| 176 |
+
precision recall f1-score support
|
| 177 |
+
|
| 178 |
+
benign 0.97 0.99 0.98 85778
|
| 179 |
+
defacement 0.97 0.99 0.98 19104
|
| 180 |
+
malware 0.98 0.92 0.95 6521
|
| 181 |
+
phishing 0.91 0.84 0.88 18836
|
| 182 |
+
|
| 183 |
+
accuracy 0.96 130239
|
| 184 |
+
macro avg 0.96 0.93 0.95 130239
|
| 185 |
+
weighted avg 0.96 0.96 0.96 130239
|
| 186 |
+
```
|
| 187 |
+
|
| 188 |
+
## Usage
|
| 189 |
+
|
| 190 |
+
To load a model in Python, you can use `joblib` or `pickle`.
|
| 191 |
+
|
| 192 |
+
### Using joblib
|
| 193 |
+
|
| 194 |
+
```python
|
| 195 |
+
import joblib
|
| 196 |
+
|
| 197 |
+
# Load the model
|
| 198 |
+
model = joblib.load('models/random_forest.pkl')
|
| 199 |
+
|
| 200 |
+
# Make predictions
|
| 201 |
+
prediction = model.predict(X_test)
|
| 202 |
+
```
|
| 203 |
+
|
| 204 |
+
### Using pickle
|
| 205 |
+
|
| 206 |
+
```python
|
| 207 |
+
import pickle
|
| 208 |
+
|
| 209 |
+
# Load the model
|
| 210 |
+
with open('models/random_forest.pkl', 'rb') as f:
|
| 211 |
+
model = pickle.load(f)
|
| 212 |
+
|
| 213 |
+
# Make predictions
|
| 214 |
+
prediction = model.predict(X_test)
|
| 215 |
+
```
|
adaboost.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:55ccb71299f2573836929219945e1b244a9c09ffce9b66ab0fc70a5beaffcdd4
|
| 3 |
+
size 36628
|
decision_tree.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8f9ada3533633eb37065776f66800ed024b43093ff3d2cd4b82b1a7617976fd6
|
| 3 |
+
size 4526681
|
extra_trees_classifier.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fcab25db6b4e0a7f49bfd5678dac9e566f722b865172fd3d8999a4fd6c8e9cce
|
| 3 |
+
size 852962137
|
gaussian_naive_bayes.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8ddcd8cfd42f2b0ea6d23df58325e8035a7e3fcfccfb402d181e90d61b44c241
|
| 3 |
+
size 2551
|
gradient_boosting_classifier.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:44c1cdb5d3d4cea5ca739afda082edecb8e792c566603aa9c117ec4ef8cff8a5
|
| 3 |
+
size 530569
|
label_encoder.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1f1afcf02394ae87fa6c1c299b874785530ece909b53caa0e5e70e9355a041c7
|
| 3 |
+
size 516
|
logistic_regression.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:45088fc709d21bec582de00df39a8416663087d2d363cd9d4998527b85cda631
|
| 3 |
+
size 1767
|
mlp_classifier.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1d7acc5b2ee69c411e760b0cdf203e55454e64aff6d621d4ccc00fe1e57c73fe
|
| 3 |
+
size 113424
|
random_forest.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1eec6d2fd709214916e65577cdb61de235a5051e8fb2b3755cd616e012e4e1f0
|
| 3 |
+
size 434828169
|
scaler.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bd0bf48348e7e28ace5be28f02f11450435f3ec472e47ad4e98576b903e41632
|
| 3 |
+
size 1791
|
sgd_classifier.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0ac2dd599bbc464c98901bde157d8a7b8873d5e65f0828835d76abdf11c19126
|
| 3 |
+
size 2013
|
xgboost.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fda61cdd809c4edeefe573e33b7587d2682a9c572c46e0a887438a652fdbd456
|
| 3 |
+
size 1375414
|