Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test(self, data_dir, save_path):
# Initialize results dictionary
results = {}
results['labels'] = self.conf_labels
# Get the true label assignments
self.logger.info('Getting label assignments')
label_assignments = get_labels(
'networkml/configs/label_assignments.json', model_labels=self.model.labels)
if not label_assignments:
self.logger.warn(
'Could not read label assignments; continuing anyway.')
# Walk through testing directory and get all the pcaps
self.logger.info('Getting pcaps')
pcaps = get_pcap_paths(data_dir)
if not pcaps:
self.logger.error(
'No pcaps were found in data directory; exiting.')
return
# Evaluate the model on each pcap
file_size = 0
file_num = 0
time_slices = 0
self.logger.info('processing pcaps')
tick = time.clock()
for pcap in pcaps:
# Get the true label
name, label = get_true_label(pcap, label_assignments)
single_result = {}
single_result['label'] = label
# Initialize results dictionary
results = {}
results['labels'] = self.conf_labels
# Get the true label assignments
self.logger.info('Getting label assignments')
label_assignments = get_labels(
'networkml/configs/label_assignments.json', model_labels=self.model.labels)
if not label_assignments:
self.logger.warn(
'Could not read label assignments; continuing anyway.')
# Walk through testing directory and get all the pcaps
self.logger.info('Getting pcaps')
pcaps = get_pcap_paths(data_dir)
if not pcaps:
self.logger.error(
'No pcaps were found in data directory; exiting.')
return
# Evaluate the model on each pcap
file_size = 0
file_num = 0
time_slices = 0
self.logger.info('processing pcaps')
tick = time.clock()
for pcap in pcaps:
# Get the true label
name, label = get_true_label(pcap, label_assignments)
single_result = {}
single_result['label'] = label