Spaces:
Sleeping
Sleeping
albin
commited on
Commit
·
48d1b6a
1
Parent(s):
f60f8c3
clean code and modify threshold
Browse files
main.py
CHANGED
|
@@ -97,37 +97,8 @@ async def predict(request: Request, requess: Req = Depends(form_req)):
|
|
| 97 |
|
| 98 |
data = dataFrame_features[selected_columns].values.reshape(1, -1)
|
| 99 |
|
| 100 |
-
# data = []
|
| 101 |
-
# data.append(str(features['URL']))
|
| 102 |
-
# data.extend(int(features['URLLength']))
|
| 103 |
-
# data.extend(str(features['Domain']))
|
| 104 |
-
# data.extend(int(features['DomainLength']))
|
| 105 |
-
# data.extend(str(features['TLD']))
|
| 106 |
-
# data.extend(float(features['CharContinuationRate']))
|
| 107 |
-
# data.extend(int(features['TLDLength']))
|
| 108 |
-
# data.extend(int(features['NoOfSubDomain']))
|
| 109 |
-
# data.extend(float(features['DegitRatioInURL']))
|
| 110 |
-
# data.extend(float(features['SpacialCharRatioInURL']))
|
| 111 |
-
# data.extend(int(features['IsHTTPS']))
|
| 112 |
-
# data.append(features['URL'])
|
| 113 |
-
# data.append(features['URLLength'])
|
| 114 |
-
# data.append(features['Domain'])
|
| 115 |
-
# data.append(features['DomainLength'])
|
| 116 |
-
# data.append(features['TLD'])
|
| 117 |
-
# data.append(features['CharContinuationRate'])
|
| 118 |
-
# data.append(features['TLDLength'])
|
| 119 |
-
# data.append(features['NoOfSubDomain'])
|
| 120 |
-
# data.append(features['DegitRatioInURL'])
|
| 121 |
-
# data.append(features['SpacialCharRatioInURL'])
|
| 122 |
-
# data.append(features['IsHTTPS'])
|
| 123 |
-
|
| 124 |
-
# Check number of dimensions before prediction
|
| 125 |
-
print("Nb dimensions before prediction:", data.shape)
|
| 126 |
-
print("Data sent to predict:", data)
|
| 127 |
-
print("Data types:", dataFrame_features[selected_columns].dtypes)
|
| 128 |
-
|
| 129 |
prediction_proba = model.predict_proba(data)[:, 1]
|
| 130 |
-
threshold = 0.
|
| 131 |
output = 1 if prediction_proba >= threshold else 0
|
| 132 |
|
| 133 |
output_text = "Legitimate" if output == 1 else "Phishing"
|
|
|
|
| 97 |
|
| 98 |
data = dataFrame_features[selected_columns].values.reshape(1, -1)
|
| 99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
prediction_proba = model.predict_proba(data)[:, 1]
|
| 101 |
+
threshold = 0.2
|
| 102 |
output = 1 if prediction_proba >= threshold else 0
|
| 103 |
|
| 104 |
output_text = "Legitimate" if output == 1 else "Phishing"
|