November 2019
Intermediate to advanced
346 pages
9h 36m
English
In the following steps, we show three different methods for selecting the most informative N-grams. The recipe assumes that binaryFileToNgramCounts(file, N) and all other helper functions from the previous recipe have been included:
from os import listdirfrom os.path import isfile, joindirectories = ["Benign PE Samples", "Malicious PE Samples"]N = 2
Ngram_counts_all_files = collections.Counter([])for dataset_path in directories: all_samples = [f for f in listdir(dataset_path) if isfile(join(dataset_path, f))] for sample in all_samples: file_path = join(dataset_path, ...