Esempio n. 1
0
def evaluate(sample_file, **kwargs):
    use_duration = True if kwargs['D'] else False
    window = int(kwargs['w'])
    pv('window', 'use_duration', stdout=True)

    samples = None
    models = None

    if kwargs['M'] or kwargs['B']:
        samples = {classification.normalize_name(t): [t] for t in sample_file}
        models = extract_models(ZIPPED_MODELS)

    if samples and models:
        if kwargs['M']:
            classification.evaluate(samples, models,
                                    use_duration=use_duration,
                                    window=window)

        if kwargs['B']:
            binary_samples = classification.binarize(samples)
            binary_models = classification.binarize(models)

            if binary_samples and binary_models:
                classification.evaluate(binary_samples, binary_models,
                                        use_duration=use_duration,
                                        window=window)
Esempio n. 2
0
def extract_models(zipped_models):
    zf = zipfile.ZipFile(zipped_models, 'r')
    models = {}

    for model_filename in zf.namelist():
        models[classification.normalize_name(model_filename)] = \
            extract_model(zipped_models, model_filename)

    return models