def classification_report(Y_hat, Y, beta=1):
    "\n\tCreate a report on classification statistics.\n\n\tParameters\n\t----------\n\tY_hat : array-like, shape=(n_samples,)\n\t\tList of data labels.\n\n\tY : array-like, shape=(n_samples,)\n\t\tList of target truth labels.\n\n\tbeta : float, default=1\n\t\tStrength of recall relative to precision in the F-score.\n\n\tReturns\n\t-------\n\treport : dict\n\t\tDictionary containing classification statistics in the following\n\t\tstructure:\n\t\t - 'label': {\n\t\t \t\t\t\t'precision':0.5,\n\t\t\t\t\t\t'recall':1.0,\n\t\t\t\t\t\t'f-score':0.67,\n\t\t\t\t\t\t'support':1\n\t\t \t\t\t},\n\t\t   ...\n\t\t - 'beta': 1,\n\t\t - 'support': 5,\n\t\t - 'accuracy': 0.8,\n\t\t - 'macro avg': {\n\t\t \t\t\t\t'precision':0.6,\n\t\t\t\t\t\t'recall':0.9,\n\t\t\t\t\t\t'f-score':0.67,\n\t\t \t\t\t},\n\t\t - 'weighted avg': {\n\t\t \t\t\t\t'precision':0.67,\n\t\t\t\t\t\t'recall':0.9,\n\t\t\t\t\t\t'f-score':0.67,\n\t\t \t\t\t}\n\t"
    stats = calculate_statistics(Y_hat, Y, beta=beta)
    (_, _, accuracy, total) = calculate_statistics(Y_hat, Y, beta=beta, average='micro')
    macro = calculate_statistics(Y_hat, Y, beta=beta, average='macro')
    weighted = calculate_statistics(Y_hat, Y, beta=beta, average='weighted')
    h = ['precision', 'recall', 'f-score', 'support']
    report = {'beta': beta, 'support': total, 'accuracy': accuracy, 'macro avg': {h[i]: macro[i] for i in range(len(h))}, 'weighted avg': {h[i]: weighted[i] for i in range(len(h))}}
    classes = set(stats[0].keys())
    for c in classes:
        report[c] = {h[i]: stats[i][c] for i in range(len(h))}
    return report
Create a report on classification statistics.

Parameters
----------
Y_hat : array-like, shape=(n_samples,)
        List of data labels.

Y : array-like, shape=(n_samples,)
        List of target truth labels.

beta : float, default=1
        Strength of recall relative to precision in the F-score.

Returns
-------
report : dict
        Dictionary containing classification statistics in the following
        structure:
         - 'label': {
                                        'precision':0.5,
                                        'recall':1.0,
                                        'f-score':0.67,
                                        'support':1
                                },
           ...
         - 'beta': 1,
         - 'support': 5,
         - 'accuracy': 0.8,
         - 'macro avg': {
                                        'precision':0.6,
                                        'recall':0.9,
                                        'f-score':0.67,
                                },
         - 'weighted avg': {
                                        'precision':0.67,
                                        'recall':0.9,
                                        'f-score':0.67,
                                }
def classification_report(Y_hat, Y, beta=1):
    "\n\tCreate a report on classification statistics.\n\n\tParameters\n\t----------\n\tY_hat : array-like, shape=(n_samples,)\n\t\tList of data labels.\n\n\tY : array-like, shape=(n_samples,)\n\t\tList of target truth labels.\n\n\tbeta : float, default=1\n\t\tStrength of recall relative to precision in the F-score.\n\n\tReturns\n\t-------\n\treport : dict\n\t\tDictionary containing classification statistics in the following\n\t\tstructure:\n\t\t - 'label': {\n\t\t \t\t\t\t'precision':0.5,\n\t\t\t\t\t\t'recall':1.0,\n\t\t\t\t\t\t'f-score':0.67,\n\t\t\t\t\t\t'support':1\n\t\t \t\t\t},\n\t\t   ...\n\t\t - 'beta': 1,\n\t\t - 'support': 5,\n\t\t - 'accuracy': 0.8,\n\t\t - 'macro avg': {\n\t\t \t\t\t\t'precision':0.6,\n\t\t\t\t\t\t'recall':0.9,\n\t\t\t\t\t\t'f-score':0.67,\n\t\t \t\t\t},\n\t\t - 'weighted avg': {\n\t\t \t\t\t\t'precision':0.67,\n\t\t\t\t\t\t'recall':0.9,\n\t\t\t\t\t\t'f-score':0.67,\n\t\t \t\t\t}\n\t"
    stats = calculate_statistics(Y_hat, Y, beta=beta)
    (_, _, accuracy, total) = calculate_statistics(Y_hat, Y, beta=beta, average='micro')
    macro = calculate_statistics(Y_hat, Y, beta=beta, average='macro')
    weighted = calculate_statistics(Y_hat, Y, beta=beta, average='weighted')
    h = ['precision', 'recall', 'f-score', 'support']
    report = {'beta': beta, 'support': total, 'accuracy': accuracy, 'macro avg': {h[i]: macro[i] for i in range(len(h))}, 'weighted avg': {h[i]: weighted[i] for i in range(len(h))}}
    classes = set(stats[0].keys())
    for c in classes:
        report[c] = {h[i]: stats[i][c] for i in range(len(h))}
    return report