def test_validation(threshold, output_log_prefix, validation_leveldb, deploy_file, width, height,
            inference_width, inference_height, input_weight_file, training_mean_pickle):
    """
    Takes validation images and runs them through a trained model to see how
    well they do. Generates statistics like precision and recall, F1, and a confusion matrix,
    in order to gauge progress.
    """
    print "Generating predictions for validation images..."

    validation_data = _load_validation_data(validation_leveldb, width, height)
    target_details = _run_through_caffe(validation_data, deploy_file, input_weight_file, threshold,
            training_mean_pickle, inference_width, inference_height)
    statistics = _calculate_positives_negatives(target_details)

    accuracy = _calculate_accuracy(statistics)
    precision = _calculate_precision(statistics)
    recall = _calculate_recall(statistics)
    f1 = _calculate_f1(precision, recall)

    # TODO: Write these out to a file as well as the screen.
    results = ""
    results += "\n"
    results += threshold % "\nStatistics on validation dataset using threshold %f:"
    results += "\n\tAccuracy: {0:.2f}%".format(accuracy)
    results += "\n\tPrecision: %.2f" % precision
    results += "\n\tRecall: %.2f" % recall
    results += "\n\tF1 Score: %.2f" % f1

    results += "\n"
    results += _print_confusion_matrix(statistics)

    print results

    with open(output_log_prefix + ".statistics.txt", "w") as f:
        f.write(results)
dataset/ETHPy150Open BradNeuberg/cloudless/src/cloudless/train/predict.py/test_validation/swapped operands of `%`