def dship(table_file, **kwargs): """Build models from dshiped table file """ chained = chain_files(table_file) loaded = stream.load(chained) basename = '-'.join(os.path.basename(f).split('.')[0] for f in table_file) for k1 in loaded: for k2 in loaded[k1]: assert k2 == 'NULL' model = loaded[k1][k2] save_model(model, 'data/%s_%s.model' % (basename, k1))
def classify_all(file_names, models, use_duration=True, window=semi_markov.WINDOW): """Return classify results per terminal type :param file_names: samples to read from :param models: the models :param use_duration: use duration density or not :param window: smoothing window size when using duration :return: {terminal: [(path, result)]} """ results = defaultdict(list) for line in chain_files(file_names): ret = query_line(line, models, use_duration, window) if ret: results[ret.term].append((ret.path, ret.result)) return results