Evaluate a CoreML classifier model and compare against predictions
    from the original framework (for testing correctness of conversion). Use
    this evaluation for models that don't deal with probabilities.

    Parameters
    ----------
    filename: [str | MLModel]
        File from where to load the model from (OR) a loaded
        version of the MLModel.

    data: [str | Dataframe]
        Test data on which to evaluate the models (dataframe,
        or path to a csv file).

    target: str
       Column to interpret as the target column

    verbose: bool
       Set to true for a more verbose output.

    See Also
    --------
    evaluate_regressor, evaluate_classifier_with_probabilities

    Examples
    --------
    .. sourcecode:: python

        >>> metrics =  coremltools.utils.evaluate_classifier(spec, 'data_and_predictions.csv', 'target')
        >>> print(metrics)
        {"samples": 10, num_errors: 0}

def evaluate_classifier(model, data, target='target', verbose=False):
    """
    Evaluate a CoreML classifier model and compare against predictions
    from the original framework (for testing correctness of conversion). Use
    this evaluation for models that don't deal with probabilities.

    Parameters
    ----------
    filename: [str | MLModel]
        File from where to load the model from (OR) a loaded
        version of the MLModel.

    data: [str | Dataframe]
        Test data on which to evaluate the models (dataframe,
        or path to a csv file).

    target: str
       Column to interpret as the target column

    verbose: bool
       Set to true for a more verbose output.

    See Also
    --------
    evaluate_regressor, evaluate_classifier_with_probabilities

    Examples
    --------
    .. sourcecode:: python

        >>> metrics =  coremltools.utils.evaluate_classifier(spec, 'data_and_predictions.csv', 'target')
        >>> print(metrics)
        {"samples": 10, num_errors: 0}
    """
    model = _get_model(model)
    if verbose:
        print("")
        print("Other Framework\t\tPredicted")

    num_errors = 0

    for index,row in data.iterrows():
        predicted = model.predict(dict(row))[_to_unicode(target)]
        other_framework = row["prediction"]
        if predicted != other_framework:
            num_errors += 1

        if verbose:
            print("%s\t\t\t\t%s" % (other_framework, predicted))

    ret = {
        "num_samples": len(data),
        "num_errors": num_errors
    }

    if verbose:
        print("results: %s" % ret)

    return ret