2017-07-12 10:25:55 +02:00
|
|
|
import logging
|
2017-07-09 23:58:08 +02:00
|
|
|
import os
|
2017-07-03 13:48:12 +02:00
|
|
|
|
2017-07-12 10:25:55 +02:00
|
|
|
import numpy as np
|
2017-07-14 14:58:17 +02:00
|
|
|
import pandas as pd
|
|
|
|
import tensorflow as tf
|
2017-09-28 12:23:22 +02:00
|
|
|
from keras.callbacks import CSVLogger, EarlyStopping, ModelCheckpoint
|
2017-10-05 12:55:46 +02:00
|
|
|
from keras.models import Model
|
|
|
|
from sklearn.metrics import confusion_matrix
|
2017-06-30 10:12:20 +02:00
|
|
|
|
2017-07-12 10:25:55 +02:00
|
|
|
import arguments
|
2017-06-30 10:12:20 +02:00
|
|
|
import dataset
|
2017-07-07 16:48:10 +02:00
|
|
|
import hyperband
|
2017-06-30 10:12:20 +02:00
|
|
|
import models
|
2017-07-12 10:25:55 +02:00
|
|
|
# create logger
|
2017-07-14 14:58:17 +02:00
|
|
|
import visualize
|
2017-09-01 10:42:26 +02:00
|
|
|
from arguments import get_model_args
|
2017-10-05 12:55:46 +02:00
|
|
|
from utils import exists_or_make_path, get_custom_class_weights, load_model
|
2017-07-14 14:58:17 +02:00
|
|
|
|
2017-07-12 10:25:55 +02:00
|
|
|
logger = logging.getLogger('logger')
|
|
|
|
logger.setLevel(logging.DEBUG)
|
2017-07-03 13:48:12 +02:00
|
|
|
|
2017-07-12 10:25:55 +02:00
|
|
|
# create console handler and set level to debug
|
|
|
|
ch = logging.StreamHandler()
|
|
|
|
ch.setLevel(logging.DEBUG)
|
2017-07-05 21:19:19 +02:00
|
|
|
|
2017-07-12 10:25:55 +02:00
|
|
|
# create formatter
|
|
|
|
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
2017-07-05 21:19:19 +02:00
|
|
|
|
2017-07-12 10:25:55 +02:00
|
|
|
# add formatter to ch
|
|
|
|
ch.setFormatter(formatter)
|
2017-07-03 13:48:12 +02:00
|
|
|
|
2017-07-12 10:25:55 +02:00
|
|
|
# add ch to logger
|
|
|
|
logger.addHandler(ch)
|
2017-07-05 21:19:19 +02:00
|
|
|
|
2017-07-12 10:25:55 +02:00
|
|
|
ch = logging.FileHandler("info.log")
|
|
|
|
ch.setLevel(logging.DEBUG)
|
2017-07-07 16:48:10 +02:00
|
|
|
|
2017-07-12 10:25:55 +02:00
|
|
|
# create formatter
|
|
|
|
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
2017-07-03 13:48:12 +02:00
|
|
|
|
2017-07-12 10:25:55 +02:00
|
|
|
# add formatter to ch
|
|
|
|
ch.setFormatter(formatter)
|
2017-07-03 13:48:12 +02:00
|
|
|
|
2017-07-12 10:25:55 +02:00
|
|
|
# add ch to logger
|
|
|
|
logger.addHandler(ch)
|
2017-07-05 17:37:08 +02:00
|
|
|
|
2017-07-14 14:58:17 +02:00
|
|
|
args = arguments.parse()
|
2017-07-05 17:37:08 +02:00
|
|
|
|
2017-07-14 14:58:17 +02:00
|
|
|
if args.gpu:
|
|
|
|
config = tf.ConfigProto(log_device_placement=True)
|
|
|
|
config.gpu_options.per_process_gpu_memory_fraction = 0.5
|
|
|
|
config.gpu_options.allow_growth = True
|
|
|
|
session = tf.Session(config=config)
|
2017-06-30 10:42:21 +02:00
|
|
|
|
2017-07-30 13:47:11 +02:00
|
|
|
# default parameter
|
|
|
|
PARAMS = {
|
|
|
|
"type": args.model_type,
|
2017-09-01 10:42:26 +02:00
|
|
|
"depth": args.model_depth,
|
2017-09-07 15:53:58 +02:00
|
|
|
# "batch_size": 64,
|
2017-07-30 13:47:11 +02:00
|
|
|
"window_size": args.window,
|
|
|
|
"domain_length": args.domain_length,
|
|
|
|
"flow_features": 3,
|
|
|
|
#
|
2017-09-07 15:53:58 +02:00
|
|
|
'dropout': 0.5, # currently fix
|
2017-07-30 13:47:11 +02:00
|
|
|
'domain_features': args.domain_embedding,
|
2017-10-03 18:58:54 +02:00
|
|
|
'embedding': args.embedding,
|
2017-07-30 13:47:11 +02:00
|
|
|
'flow_features': 3,
|
2017-09-07 15:53:58 +02:00
|
|
|
'filter_embedding': args.filter_embedding,
|
|
|
|
'dense_embedding': args.dense_embedding,
|
|
|
|
'kernel_embedding': args.kernel_embedding,
|
|
|
|
'filter_main': args.filter_main,
|
|
|
|
'dense_main': args.dense_main,
|
|
|
|
'kernel_main': args.kernel_main,
|
2017-08-02 12:58:09 +02:00
|
|
|
'input_length': 40,
|
|
|
|
'model_output': args.model_output
|
2017-07-30 13:47:11 +02:00
|
|
|
}
|
|
|
|
|
2017-06-30 10:42:21 +02:00
|
|
|
|
2017-09-08 13:55:13 +02:00
|
|
|
def create_model(model, output_type):
|
|
|
|
if output_type == "both":
|
|
|
|
return Model(inputs=[model.in_domains, model.in_flows], outputs=(model.out_client, model.out_server))
|
|
|
|
elif output_type == "client":
|
|
|
|
return Model(inputs=[model.in_domains, model.in_flows], outputs=(model.out_client,))
|
|
|
|
else:
|
|
|
|
raise Exception("unknown model output")
|
|
|
|
|
|
|
|
|
2017-07-08 11:53:03 +02:00
|
|
|
def main_paul_best():
|
2017-07-14 14:58:17 +02:00
|
|
|
pauls_best_params = models.pauls_networks.best_config
|
|
|
|
main_train(pauls_best_params)
|
2017-07-08 11:53:03 +02:00
|
|
|
|
|
|
|
|
2017-07-07 16:48:10 +02:00
|
|
|
def main_hyperband():
|
2017-10-05 12:55:46 +02:00
|
|
|
param_dist = {
|
2017-07-07 16:48:10 +02:00
|
|
|
# static params
|
2017-09-29 22:59:57 +02:00
|
|
|
"type": [args.model_type],
|
|
|
|
"depth": [args.model_depth],
|
2017-09-29 23:34:39 +02:00
|
|
|
"model_output": [args.model_output],
|
2017-07-12 10:25:55 +02:00
|
|
|
"batch_size": [args.batch_size],
|
2017-09-29 23:34:39 +02:00
|
|
|
"window_size": [args.window],
|
2017-07-07 16:48:10 +02:00
|
|
|
"flow_features": [3],
|
2017-09-29 23:34:39 +02:00
|
|
|
"domain_length": [args.domain_length],
|
|
|
|
'input_length': [40],
|
2017-07-07 16:48:10 +02:00
|
|
|
# model params
|
2017-09-29 22:59:57 +02:00
|
|
|
"embedding_size": [2 ** x for x in range(3, 7)],
|
|
|
|
"filter_embedding": [2 ** x for x in range(1, 10)],
|
2017-07-07 16:48:10 +02:00
|
|
|
"kernel_embedding": [1, 3, 5, 7, 9],
|
2017-09-29 22:59:57 +02:00
|
|
|
"dense_embedding": [2 ** x for x in range(4, 10)],
|
2017-07-07 16:48:10 +02:00
|
|
|
"dropout": [0.5],
|
2017-09-29 22:59:57 +02:00
|
|
|
"filter_main": [2 ** x for x in range(1, 10)],
|
|
|
|
"kernel_main": [1, 3, 5, 7, 9],
|
|
|
|
"dense_main": [2 ** x for x in range(1, 12)],
|
2017-07-07 16:48:10 +02:00
|
|
|
}
|
2017-10-05 12:55:46 +02:00
|
|
|
|
2017-07-12 10:25:55 +02:00
|
|
|
logger.info("create training dataset")
|
2017-10-05 12:55:46 +02:00
|
|
|
domain_tr, flow_tr, name_tr, client_tr, server_windows_tr = dataset.load_or_generate_h5data(args.data,
|
|
|
|
args.data,
|
2017-09-29 22:59:57 +02:00
|
|
|
args.domain_length,
|
|
|
|
args.window)
|
|
|
|
server_tr = np.max(server_windows_tr, axis=1)
|
2017-10-05 12:55:46 +02:00
|
|
|
|
2017-09-29 22:59:57 +02:00
|
|
|
if args.model_type in ("inter", "staggered"):
|
|
|
|
server_tr = np.expand_dims(server_windows_tr, 2)
|
2017-10-05 12:55:46 +02:00
|
|
|
|
|
|
|
hp = hyperband.Hyperband(param_dist,
|
2017-07-12 10:25:55 +02:00
|
|
|
[domain_tr, flow_tr],
|
2017-10-05 12:55:46 +02:00
|
|
|
[client_tr, server_tr],
|
|
|
|
max_iter=81,
|
|
|
|
savefile=args.hyperband_results)
|
2017-07-12 10:25:55 +02:00
|
|
|
results = hp.run()
|
2017-10-05 12:55:46 +02:00
|
|
|
|
|
|
|
return results
|
2017-07-07 16:48:10 +02:00
|
|
|
|
|
|
|
|
2017-07-30 14:07:39 +02:00
|
|
|
def main_train(param=None):
|
|
|
|
logger.info(f"Create model path {args.model_path}")
|
2017-07-11 21:06:58 +02:00
|
|
|
exists_or_make_path(args.model_path)
|
2017-07-30 14:07:39 +02:00
|
|
|
logger.info(f"Use command line arguments: {args}")
|
2017-07-11 21:06:58 +02:00
|
|
|
|
2017-10-05 12:55:46 +02:00
|
|
|
domain_tr, flow_tr, name_tr, client_tr, server_windows_tr = dataset.load_or_generate_h5data(args.data,
|
|
|
|
args.data,
|
2017-09-08 19:10:23 +02:00
|
|
|
args.domain_length,
|
|
|
|
args.window)
|
2017-07-12 10:25:55 +02:00
|
|
|
logger.info("define callbacks")
|
2017-07-14 14:58:17 +02:00
|
|
|
callbacks = []
|
|
|
|
callbacks.append(ModelCheckpoint(filepath=args.clf_model,
|
2017-09-16 15:25:34 +02:00
|
|
|
monitor='loss',
|
2017-07-14 14:58:17 +02:00
|
|
|
verbose=False,
|
|
|
|
save_best_only=True))
|
|
|
|
callbacks.append(CSVLogger(args.train_log))
|
2017-07-30 14:07:39 +02:00
|
|
|
logger.info(f"Use early stopping: {args.stop_early}")
|
2017-07-14 14:58:17 +02:00
|
|
|
if args.stop_early:
|
|
|
|
callbacks.append(EarlyStopping(monitor='val_loss',
|
|
|
|
patience=5,
|
|
|
|
verbose=False))
|
|
|
|
custom_metrics = models.get_metric_functions()
|
2017-07-14 15:57:52 +02:00
|
|
|
|
2017-07-30 12:50:26 +02:00
|
|
|
server_tr = np.max(server_windows_tr, axis=1)
|
2017-07-29 19:42:36 +02:00
|
|
|
|
2017-07-14 15:57:52 +02:00
|
|
|
if args.class_weights:
|
|
|
|
logger.info("class weights: compute custom weights")
|
2017-07-30 13:47:11 +02:00
|
|
|
custom_class_weights = get_custom_class_weights(client_tr.value, server_tr)
|
2017-07-14 21:01:08 +02:00
|
|
|
logger.info(custom_class_weights)
|
2017-07-14 15:57:52 +02:00
|
|
|
else:
|
|
|
|
logger.info("class weights: set default")
|
|
|
|
custom_class_weights = None
|
2017-07-30 13:47:11 +02:00
|
|
|
|
2017-09-12 08:36:23 +02:00
|
|
|
if not param:
|
|
|
|
param = PARAMS
|
|
|
|
logger.info(f"Generator model with params: {param}")
|
|
|
|
embedding, model, new_model = models.get_models_by_params(param)
|
2017-09-07 14:24:55 +02:00
|
|
|
|
2017-09-12 08:36:23 +02:00
|
|
|
model = create_model(model, args.model_output)
|
|
|
|
new_model = create_model(new_model, args.model_output)
|
|
|
|
|
|
|
|
if args.model_type in ("inter", "staggered"):
|
2017-07-30 13:47:11 +02:00
|
|
|
server_tr = np.expand_dims(server_windows_tr, 2)
|
2017-09-12 08:36:23 +02:00
|
|
|
model = new_model
|
|
|
|
|
2017-09-17 09:56:18 +02:00
|
|
|
features = {"ipt_domains": domain_tr.value, "ipt_flows": flow_tr.value}
|
2017-09-12 08:36:23 +02:00
|
|
|
if args.model_output == "both":
|
2017-09-17 09:56:18 +02:00
|
|
|
labels = {"client": client_tr.value, "server": server_tr}
|
2017-09-12 08:36:23 +02:00
|
|
|
loss_weights = {"client": 1.0, "server": 1.0}
|
|
|
|
elif args.model_output == "client":
|
2017-09-17 09:56:18 +02:00
|
|
|
labels = {"client": client_tr.value}
|
2017-09-12 08:36:23 +02:00
|
|
|
loss_weights = {"client": 1.0}
|
|
|
|
elif args.model_output == "server":
|
|
|
|
labels = {"server": server_tr}
|
|
|
|
loss_weights = {"server": 1.0}
|
|
|
|
else:
|
|
|
|
raise ValueError("unknown model output")
|
|
|
|
|
|
|
|
logger.info(f"select model: {args.model_type}")
|
|
|
|
if args.model_type == "staggered":
|
|
|
|
logger.info("compile and pre-train server model")
|
2017-09-05 17:40:57 +02:00
|
|
|
logger.info(model.get_config())
|
|
|
|
|
|
|
|
model.compile(optimizer='adam',
|
|
|
|
loss='binary_crossentropy',
|
2017-09-07 14:24:55 +02:00
|
|
|
loss_weights={"client": 0.0, "server": 1.0},
|
2017-09-05 17:40:57 +02:00
|
|
|
metrics=['accuracy'] + custom_metrics)
|
|
|
|
|
2017-10-06 10:38:00 +02:00
|
|
|
model.summary()
|
2017-09-17 09:56:18 +02:00
|
|
|
model.fit(features, labels,
|
2017-09-07 14:24:55 +02:00
|
|
|
batch_size=args.batch_size,
|
|
|
|
epochs=args.epochs,
|
|
|
|
class_weight=custom_class_weights)
|
2017-09-26 19:25:37 +02:00
|
|
|
|
2017-09-12 08:36:23 +02:00
|
|
|
logger.info("fix server model")
|
|
|
|
model.get_layer("domain_cnn").trainable = False
|
2017-10-06 10:38:00 +02:00
|
|
|
model.get_layer("domain_cnn").layer.trainable = False
|
2017-09-07 14:24:55 +02:00
|
|
|
model.get_layer("dense_server").trainable = False
|
2017-09-07 15:31:04 +02:00
|
|
|
model.get_layer("server").trainable = False
|
2017-09-12 08:36:23 +02:00
|
|
|
loss_weights = {"client": 1.0, "server": 0.0}
|
|
|
|
|
|
|
|
logger.info("compile and train model")
|
|
|
|
embedding.summary()
|
|
|
|
logger.info(model.get_config())
|
|
|
|
model.compile(optimizer='adam',
|
|
|
|
loss='binary_crossentropy',
|
|
|
|
loss_weights=loss_weights,
|
|
|
|
metrics=['accuracy'] + custom_metrics)
|
|
|
|
|
|
|
|
model.summary()
|
2017-09-17 09:56:18 +02:00
|
|
|
model.fit(features, labels,
|
2017-09-12 08:36:23 +02:00
|
|
|
batch_size=args.batch_size,
|
|
|
|
epochs=args.epochs,
|
|
|
|
callbacks=callbacks,
|
|
|
|
class_weight=custom_class_weights)
|
2017-07-07 16:48:10 +02:00
|
|
|
|
2017-07-05 21:19:19 +02:00
|
|
|
|
2017-09-28 12:23:22 +02:00
|
|
|
def main_retrain():
|
|
|
|
source = os.path.join(args.model_source, "clf.h5")
|
|
|
|
destination = os.path.join(args.model_destination, "clf.h5")
|
|
|
|
|
|
|
|
logger.info(f"Use command line arguments: {args}")
|
2017-09-29 23:03:07 +02:00
|
|
|
exists_or_make_path(args.model_destination)
|
2017-10-05 12:55:46 +02:00
|
|
|
|
|
|
|
domain_tr, flow_tr, name_tr, client_tr, server_windows_tr = dataset.load_or_generate_h5data(args.data,
|
|
|
|
args.data,
|
2017-09-28 12:23:22 +02:00
|
|
|
args.domain_length,
|
|
|
|
args.window)
|
|
|
|
logger.info("define callbacks")
|
|
|
|
callbacks = []
|
|
|
|
callbacks.append(ModelCheckpoint(filepath=destination,
|
|
|
|
monitor='loss',
|
|
|
|
verbose=False,
|
|
|
|
save_best_only=True))
|
|
|
|
callbacks.append(CSVLogger(args.train_log))
|
|
|
|
logger.info(f"Use early stopping: {args.stop_early}")
|
|
|
|
if args.stop_early:
|
|
|
|
callbacks.append(EarlyStopping(monitor='val_loss',
|
|
|
|
patience=5,
|
|
|
|
verbose=False))
|
|
|
|
|
|
|
|
server_tr = np.max(server_windows_tr, axis=1)
|
|
|
|
|
|
|
|
if args.class_weights:
|
|
|
|
logger.info("class weights: compute custom weights")
|
|
|
|
custom_class_weights = get_custom_class_weights(client_tr.value, server_tr)
|
|
|
|
logger.info(custom_class_weights)
|
|
|
|
else:
|
|
|
|
logger.info("class weights: set default")
|
|
|
|
custom_class_weights = None
|
|
|
|
|
|
|
|
logger.info(f"Load pretrained model")
|
2017-10-05 12:55:46 +02:00
|
|
|
embedding, model = load_model(source, custom_objects=models.get_custom_objects())
|
2017-09-28 12:23:22 +02:00
|
|
|
|
|
|
|
if args.model_type in ("inter", "staggered"):
|
|
|
|
server_tr = np.expand_dims(server_windows_tr, 2)
|
|
|
|
|
|
|
|
features = {"ipt_domains": domain_tr.value, "ipt_flows": flow_tr.value}
|
|
|
|
if args.model_output == "both":
|
|
|
|
labels = {"client": client_tr.value, "server": server_tr}
|
|
|
|
elif args.model_output == "client":
|
|
|
|
labels = {"client": client_tr.value}
|
|
|
|
elif args.model_output == "server":
|
|
|
|
labels = {"server": server_tr}
|
|
|
|
else:
|
|
|
|
raise ValueError("unknown model output")
|
|
|
|
|
|
|
|
logger.info("re-train model")
|
|
|
|
embedding.summary()
|
|
|
|
model.summary()
|
|
|
|
model.fit(features, labels,
|
|
|
|
batch_size=args.batch_size,
|
|
|
|
epochs=args.epochs,
|
|
|
|
callbacks=callbacks,
|
|
|
|
class_weight=custom_class_weights,
|
|
|
|
initial_epoch=args.initial_epoch)
|
|
|
|
|
|
|
|
|
2017-07-06 16:27:47 +02:00
|
|
|
def main_test():
|
2017-09-01 10:42:26 +02:00
|
|
|
logger.info("start test: load data")
|
2017-10-05 12:55:46 +02:00
|
|
|
domain_val, flow_val, _, _, _, _ = dataset.load_or_generate_raw_h5data(args.data,
|
|
|
|
args.data,
|
2017-09-08 19:10:23 +02:00
|
|
|
args.domain_length,
|
|
|
|
args.window)
|
2017-10-05 12:55:46 +02:00
|
|
|
domain_encs, _ = dataset.load_or_generate_domains(args.data, args.domain_length)
|
2017-09-08 19:10:23 +02:00
|
|
|
|
2017-09-01 10:42:26 +02:00
|
|
|
for model_args in get_model_args(args):
|
2017-09-08 13:55:13 +02:00
|
|
|
results = {}
|
2017-09-01 10:42:26 +02:00
|
|
|
logger.info(f"process model {model_args['model_path']}")
|
2017-10-05 12:55:46 +02:00
|
|
|
embd_model, clf_model = load_model(model_args["clf_model"], custom_objects=models.get_custom_objects())
|
|
|
|
|
2017-09-01 10:42:26 +02:00
|
|
|
pred = clf_model.predict([domain_val, flow_val],
|
|
|
|
batch_size=args.batch_size,
|
|
|
|
verbose=1)
|
|
|
|
|
|
|
|
if args.model_output == "both":
|
|
|
|
c_pred, s_pred = pred
|
2017-09-08 13:55:13 +02:00
|
|
|
results["client_pred"] = c_pred
|
|
|
|
results["server_pred"] = s_pred
|
2017-09-01 10:42:26 +02:00
|
|
|
elif args.model_output == "client":
|
2017-09-08 13:55:13 +02:00
|
|
|
results["client_pred"] = pred
|
2017-09-01 10:42:26 +02:00
|
|
|
else:
|
2017-09-08 13:55:13 +02:00
|
|
|
results["server_pred"] = pred
|
2017-09-01 10:42:26 +02:00
|
|
|
|
|
|
|
domain_embeddings = embd_model.predict(domain_encs, batch_size=args.batch_size, verbose=1)
|
2017-09-08 13:55:13 +02:00
|
|
|
results["domain_embds"] = domain_embeddings
|
2017-09-08 19:10:23 +02:00
|
|
|
|
|
|
|
dataset.save_predictions(model_args["model_path"], results)
|
2017-07-29 19:42:36 +02:00
|
|
|
|
|
|
|
|
2017-07-07 08:43:16 +02:00
|
|
|
def main_visualization():
|
2017-10-05 12:55:46 +02:00
|
|
|
def plot_model(clf_model, path):
|
|
|
|
embd, model = load_model(clf_model, custom_objects=models.get_custom_objects())
|
|
|
|
visualize.plot_model_as(embd, os.path.join(path, "model_embd.pdf"))
|
|
|
|
visualize.plot_model_as(model, os.path.join(path, "model_clf.pdf"))
|
|
|
|
|
|
|
|
def vis(model_name, model_path, df, df_paul, aggregation, curve):
|
|
|
|
visualize.plot_clf()
|
|
|
|
if aggregation == "user":
|
|
|
|
df = df.groupby(df.names).max()
|
|
|
|
df_paul = df_paul.groupby(df_paul.names).max()
|
|
|
|
if curve == "prc":
|
|
|
|
visualize.plot_precision_recall(df.client_val.as_matrix(), df.client_pred.as_matrix(), model_name)
|
|
|
|
visualize.plot_precision_recall(df_paul.client_val.as_matrix(), df_paul.client_pred.as_matrix(), "paul")
|
|
|
|
elif curve == "roc":
|
|
|
|
visualize.plot_roc_curve(df.client_val.as_matrix(), df.client_pred.as_matrix(), model_name)
|
|
|
|
visualize.plot_roc_curve(df_paul.client_val.as_matrix(), df_paul.client_pred.as_matrix(), "paul")
|
|
|
|
|
|
|
|
visualize.plot_legend()
|
|
|
|
visualize.plot_save("{}/{}_{}.png".format(model_path, aggregation, curve))
|
|
|
|
|
|
|
|
_, _, name_val, hits_vt, hits_trusted, server_val = dataset.load_or_generate_raw_h5data(args.data,
|
|
|
|
args.data,
|
2017-09-08 22:59:55 +02:00
|
|
|
args.domain_length,
|
|
|
|
args.window)
|
|
|
|
|
|
|
|
results = dataset.load_predictions(args.model_path)
|
|
|
|
df = pd.DataFrame(data={
|
|
|
|
"names": name_val, "client_pred": results["client_pred"].flatten(),
|
|
|
|
"hits_vt": hits_vt, "hits_trusted": hits_trusted
|
|
|
|
})
|
|
|
|
df["client_val"] = np.logical_or(df.hits_vt == 1.0, df.hits_trusted >= 3)
|
|
|
|
df_user = df.groupby(df.names).max()
|
2017-10-05 12:55:46 +02:00
|
|
|
|
2017-09-10 18:06:40 +02:00
|
|
|
paul = dataset.load_predictions("results/paul/")
|
|
|
|
df_paul = pd.DataFrame(data={
|
|
|
|
"names": paul["testNames"].flatten(), "client_pred": paul["testScores"].flatten(),
|
|
|
|
"hits_vt": paul["testLabel"].flatten(), "hits_trusted": paul["testHits"].flatten()
|
|
|
|
})
|
|
|
|
df_paul["client_val"] = np.logical_or(df_paul.hits_vt == 1.0, df_paul.hits_trusted >= 3)
|
2017-09-08 19:10:23 +02:00
|
|
|
|
2017-09-05 17:40:57 +02:00
|
|
|
logger.info("plot model")
|
2017-10-05 12:55:46 +02:00
|
|
|
plot_model(args.clf_model, args.model_path)
|
|
|
|
|
2017-09-16 15:25:34 +02:00
|
|
|
# logger.info("plot training curve")
|
|
|
|
# logs = pd.read_csv(args.train_log)
|
|
|
|
# if "acc" in logs.keys():
|
|
|
|
# visualize.plot_training_curve(logs, "", "{}/client_train.png".format(args.model_path))
|
|
|
|
# elif "client_acc" in logs.keys() and "server_acc" in logs.keys():
|
|
|
|
# visualize.plot_training_curve(logs, "client_", "{}/client_train.png".format(args.model_path))
|
|
|
|
# visualize.plot_training_curve(logs, "server_", "{}/server_train.png".format(args.model_path))
|
|
|
|
# else:
|
|
|
|
# logger.warning("Error while plotting training curves")
|
2017-09-08 19:10:23 +02:00
|
|
|
|
2017-10-05 12:55:46 +02:00
|
|
|
logger.info("plot window prc")
|
|
|
|
vis(args.model_name, args.model_path, df, df_paul, "window", "prc")
|
|
|
|
logger.info("plot window roc")
|
|
|
|
vis(args.model_name, args.model_path, df, df_paul, "window", "roc")
|
|
|
|
logger.info("plot user prc")
|
|
|
|
vis(args.model_name, args.model_path, df, df_paul, "user", "prc")
|
|
|
|
logger.info("plot user roc")
|
|
|
|
vis(args.model_name, args.model_path, df, df_paul, "user", "roc")
|
2017-09-08 19:10:23 +02:00
|
|
|
|
2017-09-10 23:40:14 +02:00
|
|
|
# absolute values
|
2017-09-08 22:59:55 +02:00
|
|
|
visualize.plot_confusion_matrix(df.client_val.as_matrix(), df.client_pred.as_matrix().round(),
|
2017-07-14 15:57:52 +02:00
|
|
|
"{}/client_cov.png".format(args.model_path),
|
|
|
|
normalize=False, title="Client Confusion Matrix")
|
2017-09-08 22:59:55 +02:00
|
|
|
visualize.plot_confusion_matrix(df_user.client_val.as_matrix(), df_user.client_pred.as_matrix().round(),
|
2017-09-07 14:24:55 +02:00
|
|
|
"{}/user_cov.png".format(args.model_path),
|
|
|
|
normalize=False, title="User Confusion Matrix")
|
2017-09-10 23:40:14 +02:00
|
|
|
# normalized
|
|
|
|
visualize.plot_confusion_matrix(df.client_val.as_matrix(), df.client_pred.as_matrix().round(),
|
|
|
|
"{}/client_cov_norm.png".format(args.model_path),
|
|
|
|
normalize=True, title="Client Confusion Matrix")
|
|
|
|
visualize.plot_confusion_matrix(df_user.client_val.as_matrix(), df_user.client_pred.as_matrix().round(),
|
|
|
|
"{}/user_cov_norm.png".format(args.model_path),
|
|
|
|
normalize=True, title="User Confusion Matrix")
|
2017-10-05 12:55:46 +02:00
|
|
|
plot_embedding(args.model_path, results["domain_embds"], args.data, args.domain_length)
|
2017-09-22 10:01:12 +02:00
|
|
|
|
|
|
|
|
2017-10-05 12:55:46 +02:00
|
|
|
def plot_embedding(model_path, domain_embedding, data, domain_length):
|
2017-09-22 10:01:12 +02:00
|
|
|
logger.info("visualize embedding")
|
2017-10-05 12:55:46 +02:00
|
|
|
domain_encs, labels = dataset.load_or_generate_domains(data, domain_length)
|
|
|
|
visualize.plot_embedding(domain_embedding, labels, path="{}/embd_svd.png".format(model_path), method="svd")
|
2017-07-07 08:43:16 +02:00
|
|
|
|
|
|
|
|
2017-09-01 10:42:26 +02:00
|
|
|
def main_visualize_all():
|
2017-10-05 12:55:46 +02:00
|
|
|
_, _, name_val, hits_vt, hits_trusted, server_val = dataset.load_or_generate_raw_h5data(args.data,
|
|
|
|
args.data,
|
2017-09-08 22:59:55 +02:00
|
|
|
args.domain_length,
|
|
|
|
args.window)
|
|
|
|
|
|
|
|
def load_df(path):
|
|
|
|
res = dataset.load_predictions(path)
|
|
|
|
res = pd.DataFrame(data={
|
|
|
|
"names": name_val, "client_pred": res["client_pred"].flatten(),
|
|
|
|
"hits_vt": hits_vt, "hits_trusted": hits_trusted
|
|
|
|
})
|
|
|
|
res["client_val"] = np.logical_or(res.hits_vt == 1.0, res.hits_trusted >= 3)
|
|
|
|
return res
|
2017-10-05 12:55:46 +02:00
|
|
|
|
2017-09-10 18:06:40 +02:00
|
|
|
paul = dataset.load_predictions("results/paul/")
|
|
|
|
df_paul = pd.DataFrame(data={
|
|
|
|
"names": paul["testNames"].flatten(), "client_pred": paul["testScores"].flatten(),
|
|
|
|
"hits_vt": paul["testLabel"].flatten(), "hits_trusted": paul["testHits"].flatten()
|
|
|
|
})
|
|
|
|
df_paul["client_val"] = np.logical_or(df_paul.hits_vt == 1.0, df_paul.hits_trusted >= 3)
|
|
|
|
df_paul_user = df_paul.groupby(df_paul.names).max()
|
2017-09-08 22:59:55 +02:00
|
|
|
|
2017-09-01 10:42:26 +02:00
|
|
|
logger.info("plot pr curves")
|
|
|
|
visualize.plot_clf()
|
|
|
|
for model_args in get_model_args(args):
|
2017-09-08 22:59:55 +02:00
|
|
|
df = load_df(model_args["model_path"])
|
2017-09-10 18:06:40 +02:00
|
|
|
visualize.plot_precision_recall(df.client_val.as_matrix(), df.client_pred.as_matrix(), model_args["model_name"])
|
|
|
|
visualize.plot_precision_recall(df_paul.client_val.as_matrix(), df_paul.client_pred.as_matrix(), "paul")
|
2017-09-01 10:42:26 +02:00
|
|
|
visualize.plot_legend()
|
2017-09-07 17:38:21 +02:00
|
|
|
visualize.plot_save(f"{args.output_prefix}_window_client_prc.png")
|
2017-09-08 19:10:23 +02:00
|
|
|
|
2017-09-01 10:42:26 +02:00
|
|
|
logger.info("plot roc curves")
|
|
|
|
visualize.plot_clf()
|
|
|
|
for model_args in get_model_args(args):
|
2017-09-08 22:59:55 +02:00
|
|
|
df = load_df(model_args["model_path"])
|
2017-09-10 18:06:40 +02:00
|
|
|
visualize.plot_roc_curve(df.client_val.as_matrix(), df.client_pred.as_matrix(), model_args["model_name"])
|
|
|
|
visualize.plot_roc_curve(df_paul.client_val.as_matrix(), df_paul.client_pred.as_matrix(), "paul")
|
2017-09-01 10:42:26 +02:00
|
|
|
visualize.plot_legend()
|
2017-09-07 17:38:21 +02:00
|
|
|
visualize.plot_save(f"{args.output_prefix}_window_client_roc.png")
|
2017-09-08 19:10:23 +02:00
|
|
|
|
2017-09-04 13:37:26 +02:00
|
|
|
logger.info("plot user pr curves")
|
|
|
|
visualize.plot_clf()
|
|
|
|
for model_args in get_model_args(args):
|
2017-09-08 22:59:55 +02:00
|
|
|
df = load_df(model_args["model_path"])
|
|
|
|
df = df.groupby(df.names).max()
|
2017-09-10 18:06:40 +02:00
|
|
|
visualize.plot_precision_recall(df.client_val.as_matrix(), df.client_pred.as_matrix(), model_args["model_name"])
|
|
|
|
visualize.plot_precision_recall(df_paul_user.client_val.as_matrix(), df_paul_user.client_pred.as_matrix(), "paul")
|
2017-09-04 13:37:26 +02:00
|
|
|
visualize.plot_legend()
|
2017-09-05 17:40:57 +02:00
|
|
|
visualize.plot_save(f"{args.output_prefix}_user_client_prc.png")
|
2017-09-08 19:10:23 +02:00
|
|
|
|
2017-09-04 13:37:26 +02:00
|
|
|
logger.info("plot user roc curves")
|
|
|
|
visualize.plot_clf()
|
|
|
|
for model_args in get_model_args(args):
|
2017-09-08 22:59:55 +02:00
|
|
|
df = load_df(model_args["model_path"])
|
|
|
|
df = df.groupby(df.names).max()
|
2017-09-10 18:06:40 +02:00
|
|
|
visualize.plot_roc_curve(df.client_val.as_matrix(), df.client_pred.as_matrix(), model_args["model_name"])
|
|
|
|
visualize.plot_roc_curve(df_paul_user.client_val.as_matrix(), df_paul_user.client_pred.as_matrix(), "paul")
|
2017-09-04 13:37:26 +02:00
|
|
|
visualize.plot_legend()
|
2017-09-05 17:40:57 +02:00
|
|
|
visualize.plot_save(f"{args.output_prefix}_user_client_roc.png")
|
2017-09-04 13:37:26 +02:00
|
|
|
|
2017-09-01 10:42:26 +02:00
|
|
|
|
2017-09-26 19:25:37 +02:00
|
|
|
import joblib
|
|
|
|
|
|
|
|
|
|
|
|
def main_beta():
|
2017-10-05 12:55:46 +02:00
|
|
|
_, _, name_val, hits_vt, hits_trusted, server_val = dataset.load_or_generate_raw_h5data(args.data,
|
|
|
|
args.data,
|
2017-09-26 19:25:37 +02:00
|
|
|
args.domain_length,
|
|
|
|
args.window)
|
|
|
|
path, model_prefix = os.path.split(os.path.normpath(args.output_prefix))
|
|
|
|
try:
|
|
|
|
results = joblib.load(f"{path}/curves.joblib")
|
|
|
|
except Exception:
|
|
|
|
results = {}
|
2017-10-05 12:55:46 +02:00
|
|
|
results[model_prefix] = {"all": {}}
|
2017-09-26 19:25:37 +02:00
|
|
|
|
|
|
|
def load_df(path):
|
|
|
|
res = dataset.load_predictions(path)
|
|
|
|
res = pd.DataFrame(data={
|
|
|
|
"names": name_val, "client_pred": res["client_pred"].flatten(),
|
|
|
|
"hits_vt": hits_vt, "hits_trusted": hits_trusted
|
|
|
|
})
|
|
|
|
res["client_val"] = np.logical_or(res.hits_vt == 1.0, res.hits_trusted >= 3)
|
|
|
|
return res
|
|
|
|
|
|
|
|
paul = dataset.load_predictions("results/paul/")
|
|
|
|
df_paul = pd.DataFrame(data={
|
|
|
|
"names": paul["testNames"].flatten(), "client_pred": paul["testScores"].flatten(),
|
|
|
|
"hits_vt": paul["testLabel"].flatten(), "hits_trusted": paul["testHits"].flatten()
|
|
|
|
})
|
|
|
|
df_paul["client_val"] = np.logical_or(df_paul.hits_vt == 1.0, df_paul.hits_trusted >= 3)
|
|
|
|
df_paul_user = df_paul.groupby(df_paul.names).max()
|
|
|
|
|
|
|
|
logger.info("plot pr curves")
|
|
|
|
visualize.plot_clf()
|
|
|
|
predictions = []
|
|
|
|
for model_args in get_model_args(args):
|
|
|
|
df = load_df(model_args["model_path"])
|
|
|
|
predictions.append(df.client_pred.as_matrix())
|
2017-10-05 12:55:46 +02:00
|
|
|
results[model_prefix][model_args["model_name"]] = confusion_matrix(df.client_val.as_matrix(),
|
|
|
|
df.client_pred.as_matrix().round())
|
|
|
|
results[model_prefix]["all"]["window_prc"] = visualize.calc_pr_mean(df.client_val.as_matrix(), predictions)
|
2017-09-26 19:25:37 +02:00
|
|
|
visualize.plot_pr_mean(df.client_val.as_matrix(), predictions, "mean")
|
|
|
|
visualize.plot_pr_mean(df_paul.client_val.as_matrix(), [df_paul.client_pred.as_matrix()], "paul")
|
|
|
|
visualize.plot_legend()
|
|
|
|
visualize.plot_save(f"{args.output_prefix}_window_client_prc_all.png")
|
|
|
|
|
|
|
|
logger.info("plot roc curves")
|
|
|
|
visualize.plot_clf()
|
|
|
|
predictions = []
|
|
|
|
for model_args in get_model_args(args):
|
|
|
|
df = load_df(model_args["model_path"])
|
|
|
|
predictions.append(df.client_pred.as_matrix())
|
2017-10-05 12:55:46 +02:00
|
|
|
results[model_prefix][model_args["model_name"]] = confusion_matrix(df.client_val.as_matrix(),
|
|
|
|
df.client_pred.as_matrix().round())
|
|
|
|
results[model_prefix]["all"]["window_roc"] = visualize.calc_roc_mean(df.client_val.as_matrix(), predictions)
|
2017-09-26 19:25:37 +02:00
|
|
|
visualize.plot_roc_mean(df.client_val.as_matrix(), predictions, "mean")
|
|
|
|
visualize.plot_roc_mean(df_paul.client_val.as_matrix(), [df_paul.client_pred.as_matrix()], "paul")
|
|
|
|
visualize.plot_legend()
|
|
|
|
visualize.plot_save(f"{args.output_prefix}_window_client_roc_all.png")
|
|
|
|
|
|
|
|
logger.info("plot user pr curves")
|
|
|
|
visualize.plot_clf()
|
|
|
|
predictions = []
|
|
|
|
for model_args in get_model_args(args):
|
|
|
|
df = load_df(model_args["model_path"])
|
|
|
|
df = df.groupby(df.names).max()
|
|
|
|
predictions.append(df.client_pred.as_matrix())
|
2017-10-05 12:55:46 +02:00
|
|
|
results[model_prefix][model_args["model_name"]] = confusion_matrix(df.client_val.as_matrix(),
|
|
|
|
df.client_pred.as_matrix().round())
|
|
|
|
results[model_prefix]["all"]["user_prc"] = visualize.calc_pr_mean(df.client_val.as_matrix(), predictions)
|
2017-09-26 19:25:37 +02:00
|
|
|
visualize.plot_pr_mean(df.client_val.as_matrix(), predictions, "mean")
|
|
|
|
visualize.plot_pr_mean(df_paul_user.client_val.as_matrix(), [df_paul_user.client_pred.as_matrix()], "paul")
|
|
|
|
visualize.plot_legend()
|
|
|
|
visualize.plot_save(f"{args.output_prefix}_user_client_prc_all.png")
|
|
|
|
|
|
|
|
logger.info("plot user roc curves")
|
|
|
|
visualize.plot_clf()
|
|
|
|
predictions = []
|
|
|
|
for model_args in get_model_args(args):
|
|
|
|
df = load_df(model_args["model_path"])
|
|
|
|
df = df.groupby(df.names).max()
|
|
|
|
predictions.append(df.client_pred.as_matrix())
|
2017-10-05 12:55:46 +02:00
|
|
|
results[model_prefix]["all"]["user_roc"] = visualize.calc_roc_mean(df.client_val.as_matrix(), predictions)
|
2017-09-26 19:25:37 +02:00
|
|
|
visualize.plot_roc_mean(df.client_val.as_matrix(), predictions, "mean")
|
|
|
|
visualize.plot_roc_mean(df_paul_user.client_val.as_matrix(), [df_paul_user.client_pred.as_matrix()], "paul")
|
|
|
|
visualize.plot_legend()
|
|
|
|
visualize.plot_save(f"{args.output_prefix}_user_client_roc_all.png")
|
|
|
|
|
|
|
|
joblib.dump(results, f"{path}/curves.joblib")
|
2017-10-05 12:55:46 +02:00
|
|
|
|
2017-09-28 12:23:22 +02:00
|
|
|
plot_overall_result()
|
|
|
|
|
|
|
|
|
|
|
|
def plot_overall_result():
|
|
|
|
path, model_prefix = os.path.split(os.path.normpath(args.output_prefix))
|
|
|
|
try:
|
|
|
|
results = joblib.load(f"{path}/curves.joblib")
|
|
|
|
except Exception:
|
|
|
|
results = {}
|
2017-09-26 19:25:37 +02:00
|
|
|
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
x = np.linspace(0, 1, 10000)
|
|
|
|
for vis in ["window_prc", "window_roc", "user_prc", "user_roc"]:
|
|
|
|
logger.info(f"plot {vis}")
|
|
|
|
visualize.plot_clf()
|
|
|
|
for model_key in results.keys():
|
2017-10-05 12:55:46 +02:00
|
|
|
ys_mean, ys_std, score = results[model_key]["all"][vis]
|
2017-09-26 19:25:37 +02:00
|
|
|
plt.plot(x, ys_mean, label=f"{model_key} - {score:5.4}")
|
2017-09-28 12:23:22 +02:00
|
|
|
plt.fill_between(x, ys_mean - ys_std, ys_mean + ys_std, alpha=0.2)
|
2017-09-26 19:25:37 +02:00
|
|
|
if vis.endswith("prc"):
|
|
|
|
plt.xlabel('Recall')
|
|
|
|
plt.ylabel('Precision')
|
|
|
|
else:
|
|
|
|
plt.xlabel('False Positive Rate')
|
|
|
|
plt.ylabel('True Positive Rate')
|
|
|
|
plt.ylim([0.0, 1.0])
|
|
|
|
plt.xlim([0.0, 1.0])
|
|
|
|
visualize.plot_legend()
|
|
|
|
visualize.plot_save(f"{path}/{vis}_all.png")
|
|
|
|
|
2017-10-05 14:50:59 +02:00
|
|
|
for cat, models in results.items():
|
|
|
|
visualize.plot_clf()
|
|
|
|
visualize.plot_error_bars(models)
|
|
|
|
visualize.plot_legend()
|
|
|
|
visualize.plot_save(f"{path}/error_bars_{cat}.png")
|
2017-10-05 15:26:53 +02:00
|
|
|
|
|
|
|
|
|
|
|
def train_server_only():
|
|
|
|
logger.info(f"Create model path {args.model_path}")
|
|
|
|
exists_or_make_path(args.model_path)
|
|
|
|
logger.info(f"Use command line arguments: {args}")
|
2017-10-05 14:50:59 +02:00
|
|
|
|
2017-10-05 15:26:53 +02:00
|
|
|
domain_tr, flow_tr, name_tr, client_tr, server_windows_tr = dataset.load_or_generate_h5data(args.data,
|
|
|
|
args.data,
|
|
|
|
args.domain_length,
|
|
|
|
args.window)
|
|
|
|
domain_tr = domain_tr.value.reshape(-1, 40)
|
|
|
|
flow_tr = flow_tr.value.reshape(-1, 3)
|
|
|
|
server_tr = server_windows_tr.value.reshape(-1)
|
|
|
|
|
|
|
|
logger.info("define callbacks")
|
|
|
|
callbacks = []
|
|
|
|
callbacks.append(ModelCheckpoint(filepath=args.clf_model,
|
|
|
|
monitor='loss',
|
|
|
|
verbose=False,
|
|
|
|
save_best_only=True))
|
|
|
|
callbacks.append(CSVLogger(args.train_log))
|
|
|
|
logger.info(f"Use early stopping: {args.stop_early}")
|
|
|
|
if args.stop_early:
|
|
|
|
callbacks.append(EarlyStopping(monitor='val_loss',
|
|
|
|
patience=5,
|
|
|
|
verbose=False))
|
|
|
|
custom_metrics = models.get_metric_functions()
|
|
|
|
|
|
|
|
model = models.get_server_model_by_params(params=PARAMS)
|
|
|
|
|
|
|
|
features = {"ipt_domains": domain_tr, "ipt_flows": flow_tr}
|
|
|
|
if args.model_output == "both":
|
|
|
|
labels = {"client": client_tr, "server": server_tr}
|
|
|
|
elif args.model_output == "client":
|
|
|
|
labels = {"client": client_tr}
|
|
|
|
elif args.model_output == "server":
|
|
|
|
labels = {"server": server_tr}
|
|
|
|
else:
|
|
|
|
raise ValueError("unknown model output")
|
|
|
|
|
|
|
|
logger.info("compile and train model")
|
|
|
|
logger.info(model.get_config())
|
|
|
|
model.compile(optimizer='adam',
|
|
|
|
loss='binary_crossentropy',
|
|
|
|
metrics=['accuracy'] + custom_metrics)
|
|
|
|
|
|
|
|
model.summary()
|
|
|
|
model.fit(features, labels,
|
|
|
|
batch_size=args.batch_size,
|
|
|
|
epochs=args.epochs,
|
|
|
|
validation_split=0.2,
|
|
|
|
callbacks=callbacks)
|
|
|
|
|
2017-09-26 19:25:37 +02:00
|
|
|
|
2017-10-06 10:38:00 +02:00
|
|
|
def test_server_only():
|
|
|
|
logger.info("start test: load data")
|
|
|
|
domain_val, flow_val, _, _, _, _ = dataset.load_or_generate_raw_h5data(args.data,
|
|
|
|
args.data,
|
|
|
|
args.domain_length,
|
|
|
|
args.window)
|
|
|
|
domain_val = domain_val.value.reshape(-1, 40)
|
|
|
|
flow_val = flow_val.value.reshape(-1, 3)
|
|
|
|
domain_encs, _ = dataset.load_or_generate_domains(args.data, args.domain_length)
|
|
|
|
|
|
|
|
for model_args in get_model_args(args):
|
|
|
|
results = {}
|
|
|
|
logger.info(f"process model {model_args['model_path']}")
|
|
|
|
embd_model, clf_model = load_model(model_args["clf_model"], custom_objects=models.get_custom_objects())
|
|
|
|
|
|
|
|
pred = clf_model.predict([domain_val, flow_val],
|
|
|
|
batch_size=args.batch_size,
|
|
|
|
verbose=1)
|
|
|
|
|
|
|
|
results["server_pred"] = pred
|
|
|
|
|
|
|
|
domain_embeddings = embd_model.predict(domain_encs, batch_size=args.batch_size, verbose=1)
|
|
|
|
results["domain_embds"] = domain_embeddings
|
|
|
|
|
|
|
|
dataset.save_predictions(model_args["model_path"], results)
|
|
|
|
|
|
|
|
|
2017-07-07 08:43:16 +02:00
|
|
|
def main():
|
2017-07-30 15:49:37 +02:00
|
|
|
if "train" == args.mode:
|
2017-07-07 16:48:10 +02:00
|
|
|
main_train()
|
2017-09-28 12:23:22 +02:00
|
|
|
if "retrain" == args.mode:
|
|
|
|
main_retrain()
|
2017-07-30 15:49:37 +02:00
|
|
|
if "hyperband" == args.mode:
|
2017-07-07 16:48:10 +02:00
|
|
|
main_hyperband()
|
2017-07-30 15:49:37 +02:00
|
|
|
if "test" == args.mode:
|
2017-07-07 16:48:10 +02:00
|
|
|
main_test()
|
2017-07-30 15:49:37 +02:00
|
|
|
if "fancy" == args.mode:
|
2017-07-07 16:48:10 +02:00
|
|
|
main_visualization()
|
2017-09-01 10:42:26 +02:00
|
|
|
if "all_fancy" == args.mode:
|
|
|
|
main_visualize_all()
|
2017-09-26 19:25:37 +02:00
|
|
|
if "beta" == args.mode:
|
|
|
|
main_beta()
|
2017-10-05 14:50:59 +02:00
|
|
|
if "all_beta" == args.mode:
|
|
|
|
plot_overall_result()
|
2017-10-05 15:26:53 +02:00
|
|
|
if "server" == args.mode:
|
|
|
|
train_server_only()
|
2017-10-06 10:38:00 +02:00
|
|
|
if "server_test" == args.mode:
|
|
|
|
test_server_only()
|
2017-07-07 08:43:16 +02:00
|
|
|
|
|
|
|
|
2017-06-30 10:12:20 +02:00
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|