-
Notifications
You must be signed in to change notification settings - Fork 0
/
detector.py
29 lines (18 loc) · 838 Bytes
/
detector.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from flow_inspector import ml_flow
# from ml_detector import create_model, load_model
import os
## this is the pre monitor function that labels the removed flows as malicious or not
## if removed flows has suspected flows then monitoring can work
def flow_labeller(flow_table):
ml_flow_table = ml_flow(flow_table)
model = []
## check if there is model file, if not create a new model
if not os.path.exists('model.pkl'):
print('Model file does not exist, creating a new model...')
# model = create_model(ml_flow_table)
else:
print('Model file exists, loading the model...')
# model = load_model()
## get the prediction for each flow
ml_flow_table['label'] = model.predict(ml_flow_table.drop(columns=['cookie']))
return ml_flow_table