Ensures that predictions is stored as a numpy array and checks that
    all values are either 0 or 1.

def verify_predictions(predictions):
    """Ensures that predictions is stored as a numpy array and checks that
    all values are either 0 or 1.
    """
    # Check that it contains only zeros and ones
    predictions = np.array(predictions, copy=False)
    if not np.array_equal(predictions, predictions.astype(bool)):
        raise ValueError("predictions contains invalid values. " +
                         "The only permitted values are 0 or 1.")
    if predictions.ndim == 1:
        predictions = predictions[:,np.newaxis]
    return predictions