Пример #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)
Пример #2
0
def main():
    args = docopt(__doc__)

    use_duration = True if args["-D"] else False
    window = int(args["-w"])

    models = model.extract_models(model.ZIPPED_MODELS)

    if args["-B"]:
        models = classification.binarize(models)

    for line in sys.stdin:
        splitted = line.strip().split("\t")

        if len(splitted) == 5:
            mid_terminal, uid, bid, aid, histories = splitted
            term = classification.terminal_name(mid_terminal)
            paths = stream.decode(histories)
            assert len(paths) == 1

            decision = classification.query(term, paths[0], models, use_duration=use_duration, window=window)

            if decision:
                forward(
                    mid_terminal,
                    uid,
                    bid,
                    aid,
                    decision.decision,
                    decision.prob,
                    decision.path,
                    decision.probs,
                    decision.principal,
                )