Example #1
0
def crossval_baseline(folds):
    # This is essentially a "one-hit-all" evaluation of policy 4

    results = {}

    for fold_name, data in folds:
        predictions = {}
        truths = {}

        for datum in data:
            prediction = classifier.policy(datum, 6)
            truth = datum.label
            key = (datum.evt, datum.ctxGrounded)

            if key in predictions:
                # If the prediction if false, but the value is true,
                # lets override it. Otherwise the result is the same
                if predictions[key] == 0:
                    predictions[key] = prediction

                if truths[key] == 0:
                    truths[key] = truth
            else:
                # Store a result anyway
                predictions[key] = prediction
                truths[key] = truth

        keys = predictions.keys()
        result = ClassificationResults(fold_name, [truths[k] for k in keys], [predictions[k] for k in keys], [k for k in keys])
        results[fold_name] = result

    return results
Example #2
0
def crossval_baseline(folds):
    # This is essentially a "one-hit-all" evaluation of policy 4

    results = {}

    for fold_name, data in folds:
        predictions = {}
        truths = {}

        for datum in data:
            prediction = classifier.policy(datum, 6)
            truth = datum.label
            key = (datum.evt, datum.ctxGrounded)

            if key in predictions:
                # If the prediction if false, but the value is true,
                # lets override it. Otherwise the result is the same
                if predictions[key] == 0:
                    predictions[key] = prediction

                if truths[key] == 0:
                    truths[key] = truth
            else:
                # Store a result anyway
                predictions[key] = prediction
                truths[key] = truth

        keys = predictions.keys()
        result = ClassificationResults(fold_name, [truths[k] for k in keys],
                                       [predictions[k] for k in keys],
                                       [k for k in keys])
        results[fold_name] = result

    return results
Example #3
0
def policy(datum):
    return classifier.policy(datum, 3)
Example #4
0
def policy(datum):
    return classifier.policy(datum, 3)