{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# PyCM Document"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Version : 1.8\n",
"-----"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Table of contents"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"
\n",
" - Overview
\n",
" - Installation
\n",
" \n",
" - Source Code
\n",
" - PyPI
\n",
" - Easy Install
\n",
"
\n",
" \n",
" - Usage
\n",
" \n",
" - From Vector
\n",
" - Direct CM
\n",
" - Activation Threshold
\n",
" - Load From File
\n",
" - Sample Weights
\n",
" - Transpose
\n",
" - Relabel
\n",
" - Online Help
\n",
" - Acceptable Data Types
\n",
"
\n",
" \n",
" - Basic Parameters
\n",
" \n",
" - True Positive
\n",
" - True Negative
\n",
" - False Positive
\n",
" - False Negative
\n",
" - Condition Positive
\n",
" - Condition Negative
\n",
" - Test Outcome Positive
\n",
" - Test Outcome Negative
\n",
" - Population
\n",
"
\n",
" \n",
" - Class Statistics
\n",
" \n",
" - True Positive Rate
\n",
" - True Negative Rate
\n",
" - Positive Predictive Value
\n",
" - Negative Predictive Value
\n",
" - False Negative Rate
\n",
" - False Positive Rate
\n",
" - False Discovery Rate
\n",
" - False Omission Rate
\n",
" - Accuracy
\n",
" - Error Rate
\n",
" - FBeta Score
\n",
" - Matthews Correlation Coefficient
\n",
" - Informedness
\n",
" - Markedness
\n",
" - Positive Likelihood Ratio
\n",
" - Negative Likelihood Ratio
\n",
" - Diagnostic Odds Ratio
\n",
" - Prevalence
\n",
" - G-Measure
\n",
" - Random Accuracy
\n",
" - Random Accuracy Unbiased
\n",
" - Jaccard Index
\n",
" - Information Score
\n",
" - Confusion Entropy
\n",
" - Modified Confusion Entropy
\n",
" - Area Under The ROC Curve
\n",
" - Distance Index
\n",
" - Similarity Index
\n",
" - Discriminant Power
\n",
" - Youden Index
\n",
" - Positive Likelihood Ratio Interpretation
\n",
" - Discriminant Power Interpretation
\n",
" - AUC Value Interpretation
\n",
" - Gini Index
\n",
" - Lift Score
\n",
"
\n",
" \n",
" - Overall Statistics
\n",
" \n",
" - Kappa
\n",
" - Kappa Unbiased
\n",
" - Kappa No Prevalence
\n",
" - Kappa 95% CI
\n",
" - Kappa Standard Error
\n",
" - Chi Squared
\n",
" - Chi Squared DF
\n",
" - Phi Squared
\n",
" - Cramer's V
\n",
" - 95% CI
\n",
" - Standard Error
\n",
" - Bennett's S
\n",
" - Scott's PI
\n",
" - Gwet's AC1
\n",
" - Reference Entropy
\n",
" - Response Entropy
\n",
" - Cross Entropy
\n",
" - Joint Entropy
\n",
" - Conditional Entropy
\n",
" - Kullback-Liebler Divergence
\n",
" - Mutual Information
\n",
" - Goodman-Kruskal's Lambda A
\n",
" - Goodman-Kruskal's Lambda B
\n",
" - Landis-Koch Benchmark
\n",
" - Fleiss’ Benchmark
\n",
" - Altman’s Benchmark
\n",
" - Cicchetti’s Benchmark
\n",
" - Overall Accuracy
\n",
" - Overall Random Accuracy
\n",
" - Overall Random Accuracy Unbiased
\n",
" - Positive Predictive Value Micro
\n",
" - True Positive Rate Micro
\n",
" - Positive Predictive Value Macro
\n",
" - True Positive Rate Macro
\n",
" - Overall Jaccard Index
\n",
" - Hamming Loss
\n",
" - Zero-one Loss
\n",
" - No Information Rate
\n",
" - P Value
\n",
" - Overall Confusion Entropy
\n",
" - Overall Modified Confusion Entropy
\n",
" - Overall Matthews Correlation Coefficient
\n",
" - Global Performance Index
\n",
" - Class Balance Accuracy
\n",
" - AUNU
\n",
" - AUNP
\n",
" - Relative Classifier Information
\n",
"
\n",
" \n",
" - Print
\n",
" \n",
" - Full
\n",
" - Matrix
\n",
" - Normalized Matrix
\n",
" - Stat
\n",
"
\n",
" \n",
" - Save
\n",
" \n",
" - pycm
\n",
" - HTML
\n",
" - CSV
\n",
" - Object
\n",
"
\n",
" \n",
" - Input Errors
\n",
" - Examples
\n",
" - References
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Overview"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"PyCM is a multi-class confusion matrix library written in Python that supports both input data vectors and direct matrix, and a proper tool for post-classification model evaluation that supports most classes and overall statistics parameters.\t\n",
"PyCM is the swiss-army knife of confusion matrices, targeted mainly at data scientists that need a broad array of metrics for predictive models and an accurate evaluation of large variety of classifiers.\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"
\n",
"
\n",
"Fig1. PyCM Block Diagram
\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Installation\t"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Source code\n",
"- Download [Version 1.8](https://github.com/sepandhaghighi/pycm/archive/v1.8.zip) or [Latest Source ](https://github.com/sepandhaghighi/pycm/archive/dev.zip)\n",
"- Run `pip install -r requirements.txt` or `pip3 install -r requirements.txt` (Need root access)\n",
"- Run `python3 setup.py install` or `python setup.py install` (Need root access)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### PyPI\n",
"\n",
"\n",
"- Check [Python Packaging User Guide](https://packaging.python.org/installing/) \n",
"- Run `pip install pycm==1.8` or `pip3 install pycm==1.8` (Need root access)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Conda\n",
"\n",
"- Check [Conda Managing Package](https://conda.io/docs/user-guide/tasks/manage-pkgs.html#installing-packages-from-anaconda-org)\n",
"- `conda install -c sepandhaghighi pycm` (Need root access)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Easy install\n",
"\n",
"- Run `easy_install --upgrade pycm` (Need root access)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Usage"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### From vector"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from pycm import *"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"y_actu = [2, 0, 2, 2, 0, 1, 1, 2, 2, 0, 1, 2]\n",
"y_pred = [0, 0, 2, 1, 0, 2, 1, 0, 2, 0, 2, 2]"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"cm = ConfusionMatrix(y_actu, y_pred,digit=5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : `digit` (the number of digits to the right of the decimal point in a number) is new in version 0.6 (default value : 5)
\n",
" - Only for print and save
\n",
"
\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"pycm.ConfusionMatrix(classes: [0, 1, 2])"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[2, 0, 2, 2, 0, 1, 1, 2, 2, 0, 1, 2]"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.actual_vector"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[0, 0, 2, 1, 0, 2, 1, 0, 2, 0, 2, 2]"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.predict_vector"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[0, 1, 2]"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.classes"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'ACC': {0: 0.8333333333333334, 1: 0.75, 2: 0.5833333333333334},\n",
" 'AUC': {0: 0.8888888888888888, 1: 0.611111111111111, 2: 0.5833333333333333},\n",
" 'AUCI': {0: 'Very Good', 1: 'Fair', 2: 'Poor'},\n",
" 'BM': {0: 0.7777777777777777, 1: 0.2222222222222221, 2: 0.16666666666666652},\n",
" 'CEN': {0: 0.25, 1: 0.49657842846620864, 2: 0.6044162769630221},\n",
" 'DOR': {0: 'None', 1: 3.999999999999998, 2: 1.9999999999999998},\n",
" 'DP': {0: 'None', 1: 0.331933069996499, 2: 0.16596653499824957},\n",
" 'DPI': {0: 'None', 1: 'Poor', 2: 'Poor'},\n",
" 'ERR': {0: 0.16666666666666663, 1: 0.25, 2: 0.41666666666666663},\n",
" 'F0.5': {0: 0.6521739130434783,\n",
" 1: 0.45454545454545453,\n",
" 2: 0.5769230769230769},\n",
" 'F1': {0: 0.75, 1: 0.4, 2: 0.5454545454545454},\n",
" 'F2': {0: 0.8823529411764706, 1: 0.35714285714285715, 2: 0.5172413793103449},\n",
" 'FDR': {0: 0.4, 1: 0.5, 2: 0.4},\n",
" 'FN': {0: 0, 1: 2, 2: 3},\n",
" 'FNR': {0: 0.0, 1: 0.6666666666666667, 2: 0.5},\n",
" 'FOR': {0: 0.0, 1: 0.19999999999999996, 2: 0.4285714285714286},\n",
" 'FP': {0: 2, 1: 1, 2: 2},\n",
" 'FPR': {0: 0.2222222222222222,\n",
" 1: 0.11111111111111116,\n",
" 2: 0.33333333333333337},\n",
" 'G': {0: 0.7745966692414834, 1: 0.408248290463863, 2: 0.5477225575051661},\n",
" 'GI': {0: 0.7777777777777777, 1: 0.2222222222222221, 2: 0.16666666666666652},\n",
" 'IS': {0: 1.263034405833794, 1: 1.0, 2: 0.2630344058337938},\n",
" 'J': {0: 0.6, 1: 0.25, 2: 0.375},\n",
" 'LS': {0: 2.4, 1: 2.0, 2: 1.2},\n",
" 'MCC': {0: 0.6831300510639732, 1: 0.25819888974716115, 2: 0.1690308509457033},\n",
" 'MCEN': {0: 0.2643856189774724, 1: 0.5, 2: 0.6875},\n",
" 'MK': {0: 0.6000000000000001, 1: 0.30000000000000004, 2: 0.17142857142857126},\n",
" 'N': {0: 9, 1: 9, 2: 6},\n",
" 'NLR': {0: 0.0, 1: 0.7500000000000001, 2: 0.75},\n",
" 'NPV': {0: 1.0, 1: 0.8, 2: 0.5714285714285714},\n",
" 'P': {0: 3, 1: 3, 2: 6},\n",
" 'PLR': {0: 4.5, 1: 2.9999999999999987, 2: 1.4999999999999998},\n",
" 'PLRI': {0: 'Poor', 1: 'Poor', 2: 'Poor'},\n",
" 'POP': {0: 12, 1: 12, 2: 12},\n",
" 'PPV': {0: 0.6, 1: 0.5, 2: 0.6},\n",
" 'PRE': {0: 0.25, 1: 0.25, 2: 0.5},\n",
" 'RACC': {0: 0.10416666666666667,\n",
" 1: 0.041666666666666664,\n",
" 2: 0.20833333333333334},\n",
" 'RACCU': {0: 0.1111111111111111,\n",
" 1: 0.04340277777777778,\n",
" 2: 0.21006944444444442},\n",
" 'TN': {0: 7, 1: 8, 2: 4},\n",
" 'TNR': {0: 0.7777777777777778, 1: 0.8888888888888888, 2: 0.6666666666666666},\n",
" 'TON': {0: 7, 1: 10, 2: 7},\n",
" 'TOP': {0: 5, 1: 2, 2: 5},\n",
" 'TP': {0: 3, 1: 1, 2: 3},\n",
" 'TPR': {0: 1.0, 1: 0.3333333333333333, 2: 0.5},\n",
" 'Y': {0: 0.7777777777777777, 1: 0.2222222222222221, 2: 0.16666666666666652},\n",
" 'dInd': {0: 0.2222222222222222, 1: 0.6758625033664689, 2: 0.6009252125773316},\n",
" 'sInd': {0: 0.8428651597363228, 1: 0.5220930407198541, 2: 0.5750817072006014}}"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.class_stat"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : `cm.statistic_result` prev versions (0.2 >)
\n",
"
"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'95% CI': (0.30438856248221097, 0.8622781041844558),\n",
" 'AUNP': 0.6666666666666666,\n",
" 'AUNU': 0.6944444444444443,\n",
" 'Bennett S': 0.37500000000000006,\n",
" 'CBA': 0.4777777777777778,\n",
" 'Chi-Squared': 6.6,\n",
" 'Chi-Squared DF': 4,\n",
" 'Conditional Entropy': 0.9591479170272448,\n",
" 'Cramer V': 0.5244044240850757,\n",
" 'Cross Entropy': 1.5935164295556343,\n",
" 'Gwet AC1': 0.3893129770992367,\n",
" 'Hamming Loss': 0.41666666666666663,\n",
" 'Joint Entropy': 2.4591479170272446,\n",
" 'KL Divergence': 0.09351642955563438,\n",
" 'Kappa': 0.35483870967741943,\n",
" 'Kappa 95% CI': (-0.07707577422109269, 0.7867531935759315),\n",
" 'Kappa No Prevalence': 0.16666666666666674,\n",
" 'Kappa Standard Error': 0.2203645326012817,\n",
" 'Kappa Unbiased': 0.34426229508196726,\n",
" 'Lambda A': 0.16666666666666666,\n",
" 'Lambda B': 0.42857142857142855,\n",
" 'Mutual Information': 0.5242078379544426,\n",
" 'NIR': 0.5,\n",
" 'Overall ACC': 0.5833333333333334,\n",
" 'Overall CEN': 0.4638112995385119,\n",
" 'Overall J': (1.225, 0.4083333333333334),\n",
" 'Overall MCC': 0.36666666666666664,\n",
" 'Overall MCEN': 0.5189369467580801,\n",
" 'Overall RACC': 0.3541666666666667,\n",
" 'Overall RACCU': 0.3645833333333333,\n",
" 'P-Value': 0.38720703125,\n",
" 'PPV Macro': 0.5666666666666668,\n",
" 'PPV Micro': 0.5833333333333334,\n",
" 'Phi-Squared': 0.5499999999999999,\n",
" 'RCI': 0.3494718919696284,\n",
" 'RR': 4.0,\n",
" 'Reference Entropy': 1.5,\n",
" 'Response Entropy': 1.4833557549816874,\n",
" 'SOA1(Landis & Koch)': 'Fair',\n",
" 'SOA2(Fleiss)': 'Poor',\n",
" 'SOA3(Altman)': 'Fair',\n",
" 'SOA4(Cicchetti)': 'Poor',\n",
" 'Scott PI': 0.34426229508196726,\n",
" 'Standard Error': 0.14231876063832777,\n",
" 'TPR Macro': 0.611111111111111,\n",
" 'TPR Micro': 0.5833333333333334,\n",
" 'Zero-one Loss': 5}"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.overall_stat"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.3
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : `_` removed from overall statistics names in version 1.6
\n",
"
"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{0: {0: 3, 1: 0, 2: 0}, 1: {0: 0, 1: 1, 2: 2}, 2: {0: 2, 1: 1, 2: 3}}"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.table"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{0: {0: 3, 1: 0, 2: 0}, 1: {0: 0, 1: 1, 2: 2}, 2: {0: 2, 1: 1, 2: 3}}"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.matrix"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{0: {0: 1.0, 1: 0.0, 2: 0.0},\n",
" 1: {0: 0.0, 1: 0.33333, 2: 0.66667},\n",
" 2: {0: 0.33333, 1: 0.16667, 2: 0.5}}"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.normalized_matrix"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{0: {0: 1.0, 1: 0.0, 2: 0.0},\n",
" 1: {0: 0.0, 1: 0.33333, 2: 0.66667},\n",
" 2: {0: 0.33333, 1: 0.16667, 2: 0.5}}"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.normalized_table"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : `matrix`, `normalized_matrix` & `normalized_table` added in version 1.5 (changed from print style)
\n",
"
"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"import numpy"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"y_actu = numpy.array([2, 0, 2, 2, 0, 1, 1, 2, 2, 0, 1, 2])\n",
"y_pred = numpy.array([0, 0, 2, 1, 0, 2, 1, 0, 2, 0, 2, 2])"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
"cm = ConfusionMatrix(y_actu, y_pred,digit=5)"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"pycm.ConfusionMatrix(classes: [0, 1, 2])"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : `numpy.array` support in versions > 0.7
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Direct CM"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
"cm2 = ConfusionMatrix(matrix={0: {0: 3, 1: 0, 2: 0}, 1: {0: 0, 1: 1, 2: 2}, 2: {0: 2, 1: 1, 2: 3}},digit=5)"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"pycm.ConfusionMatrix(classes: [0, 1, 2])"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm2"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
"cm2.actual_vector"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
"cm2.predict_vector"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[0, 1, 2]"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm2.classes"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'ACC': {0: 0.8333333333333334, 1: 0.75, 2: 0.5833333333333334},\n",
" 'AUC': {0: 0.8888888888888888, 1: 0.611111111111111, 2: 0.5833333333333333},\n",
" 'AUCI': {0: 'Very Good', 1: 'Fair', 2: 'Poor'},\n",
" 'BM': {0: 0.7777777777777777, 1: 0.2222222222222221, 2: 0.16666666666666652},\n",
" 'CEN': {0: 0.25, 1: 0.49657842846620864, 2: 0.6044162769630221},\n",
" 'DOR': {0: 'None', 1: 3.999999999999998, 2: 1.9999999999999998},\n",
" 'DP': {0: 'None', 1: 0.331933069996499, 2: 0.16596653499824957},\n",
" 'DPI': {0: 'None', 1: 'Poor', 2: 'Poor'},\n",
" 'ERR': {0: 0.16666666666666663, 1: 0.25, 2: 0.41666666666666663},\n",
" 'F0.5': {0: 0.6521739130434783,\n",
" 1: 0.45454545454545453,\n",
" 2: 0.5769230769230769},\n",
" 'F1': {0: 0.75, 1: 0.4, 2: 0.5454545454545454},\n",
" 'F2': {0: 0.8823529411764706, 1: 0.35714285714285715, 2: 0.5172413793103449},\n",
" 'FDR': {0: 0.4, 1: 0.5, 2: 0.4},\n",
" 'FN': {0: 0, 1: 2, 2: 3},\n",
" 'FNR': {0: 0.0, 1: 0.6666666666666667, 2: 0.5},\n",
" 'FOR': {0: 0.0, 1: 0.19999999999999996, 2: 0.4285714285714286},\n",
" 'FP': {0: 2, 1: 1, 2: 2},\n",
" 'FPR': {0: 0.2222222222222222,\n",
" 1: 0.11111111111111116,\n",
" 2: 0.33333333333333337},\n",
" 'G': {0: 0.7745966692414834, 1: 0.408248290463863, 2: 0.5477225575051661},\n",
" 'GI': {0: 0.7777777777777777, 1: 0.2222222222222221, 2: 0.16666666666666652},\n",
" 'IS': {0: 1.263034405833794, 1: 1.0, 2: 0.2630344058337938},\n",
" 'J': {0: 0.6, 1: 0.25, 2: 0.375},\n",
" 'LS': {0: 2.4, 1: 2.0, 2: 1.2},\n",
" 'MCC': {0: 0.6831300510639732, 1: 0.25819888974716115, 2: 0.1690308509457033},\n",
" 'MCEN': {0: 0.2643856189774724, 1: 0.5, 2: 0.6875},\n",
" 'MK': {0: 0.6000000000000001, 1: 0.30000000000000004, 2: 0.17142857142857126},\n",
" 'N': {0: 9, 1: 9, 2: 6},\n",
" 'NLR': {0: 0.0, 1: 0.7500000000000001, 2: 0.75},\n",
" 'NPV': {0: 1.0, 1: 0.8, 2: 0.5714285714285714},\n",
" 'P': {0: 3, 1: 3, 2: 6},\n",
" 'PLR': {0: 4.5, 1: 2.9999999999999987, 2: 1.4999999999999998},\n",
" 'PLRI': {0: 'Poor', 1: 'Poor', 2: 'Poor'},\n",
" 'POP': {0: 12, 1: 12, 2: 12},\n",
" 'PPV': {0: 0.6, 1: 0.5, 2: 0.6},\n",
" 'PRE': {0: 0.25, 1: 0.25, 2: 0.5},\n",
" 'RACC': {0: 0.10416666666666667,\n",
" 1: 0.041666666666666664,\n",
" 2: 0.20833333333333334},\n",
" 'RACCU': {0: 0.1111111111111111,\n",
" 1: 0.04340277777777778,\n",
" 2: 0.21006944444444442},\n",
" 'TN': {0: 7, 1: 8, 2: 4},\n",
" 'TNR': {0: 0.7777777777777778, 1: 0.8888888888888888, 2: 0.6666666666666666},\n",
" 'TON': {0: 7, 1: 10, 2: 7},\n",
" 'TOP': {0: 5, 1: 2, 2: 5},\n",
" 'TP': {0: 3, 1: 1, 2: 3},\n",
" 'TPR': {0: 1.0, 1: 0.3333333333333333, 2: 0.5},\n",
" 'Y': {0: 0.7777777777777777, 1: 0.2222222222222221, 2: 0.16666666666666652},\n",
" 'dInd': {0: 0.2222222222222222, 1: 0.6758625033664689, 2: 0.6009252125773316},\n",
" 'sInd': {0: 0.8428651597363228, 1: 0.5220930407198541, 2: 0.5750817072006014}}"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm2.class_stat"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'95% CI': (0.30438856248221097, 0.8622781041844558),\n",
" 'AUNP': 0.6666666666666666,\n",
" 'AUNU': 0.6944444444444443,\n",
" 'Bennett S': 0.37500000000000006,\n",
" 'CBA': 0.4777777777777778,\n",
" 'Chi-Squared': 6.6,\n",
" 'Chi-Squared DF': 4,\n",
" 'Conditional Entropy': 0.9591479170272448,\n",
" 'Cramer V': 0.5244044240850757,\n",
" 'Cross Entropy': 1.5935164295556343,\n",
" 'Gwet AC1': 0.3893129770992367,\n",
" 'Hamming Loss': 0.41666666666666663,\n",
" 'Joint Entropy': 2.4591479170272446,\n",
" 'KL Divergence': 0.09351642955563438,\n",
" 'Kappa': 0.35483870967741943,\n",
" 'Kappa 95% CI': (-0.07707577422109269, 0.7867531935759315),\n",
" 'Kappa No Prevalence': 0.16666666666666674,\n",
" 'Kappa Standard Error': 0.2203645326012817,\n",
" 'Kappa Unbiased': 0.34426229508196726,\n",
" 'Lambda A': 0.16666666666666666,\n",
" 'Lambda B': 0.42857142857142855,\n",
" 'Mutual Information': 0.5242078379544426,\n",
" 'NIR': 0.5,\n",
" 'Overall ACC': 0.5833333333333334,\n",
" 'Overall CEN': 0.4638112995385119,\n",
" 'Overall J': (1.225, 0.4083333333333334),\n",
" 'Overall MCC': 0.36666666666666664,\n",
" 'Overall MCEN': 0.5189369467580801,\n",
" 'Overall RACC': 0.3541666666666667,\n",
" 'Overall RACCU': 0.3645833333333333,\n",
" 'P-Value': 0.38720703125,\n",
" 'PPV Macro': 0.5666666666666668,\n",
" 'PPV Micro': 0.5833333333333334,\n",
" 'Phi-Squared': 0.5499999999999999,\n",
" 'RCI': 0.3494718919696284,\n",
" 'RR': 4.0,\n",
" 'Reference Entropy': 1.5,\n",
" 'Response Entropy': 1.4833557549816874,\n",
" 'SOA1(Landis & Koch)': 'Fair',\n",
" 'SOA2(Fleiss)': 'Poor',\n",
" 'SOA3(Altman)': 'Fair',\n",
" 'SOA4(Cicchetti)': 'Poor',\n",
" 'Scott PI': 0.34426229508196726,\n",
" 'Standard Error': 0.14231876063832777,\n",
" 'TPR Macro': 0.611111111111111,\n",
" 'TPR Micro': 0.5833333333333334,\n",
" 'Zero-one Loss': 5}"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.overall_stat"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"\n",
" - Notice : new in version 0.8.1
\n",
" - In direct matrix mode `actual_vector` and `predict_vector` are empty
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Activation threshold"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"`threshold` is added in `version 0.9` for real value prediction.\t\t\t\n",
"\t\t\t\t\t\t\n",
"For more information visit [Example 3](http://www.shaghighi.ir/pycm/doc/Example3.html \"Example3\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"\n",
" - Notice : new in version 0.9
\n",
"
\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Load from file"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"`file` is added in `version 0.9.5` in order to load saved confusion matrix with `.obj` format generated by `save_obj` method.\n",
"\n",
"For more information visit [Example 4](http://www.shaghighi.ir/pycm/doc/Example4.html \"Example4\")\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"\n",
" - Notice : new in version 0.9.5
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Sample weights"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"`sample_weight` is added in `version 1.2`\n",
"\n",
"For more information visit [Example 5](http://www.shaghighi.ir/pycm/doc/Example5.html \"Example5\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 1.2
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Transpose"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"`transpose` is added in `version 1.2` in order to transpose input matrix (only in `Direct CM` mode)"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [],
"source": [
"cm = ConfusionMatrix(matrix={0: {0: 3, 1: 0, 2: 0}, 1: {0: 0, 1: 1, 2: 2}, 2: {0: 2, 1: 1, 2: 3}},digit=5,transpose=True)"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Predict 0 1 2 \n",
"Actual\n",
"0 3 0 2 \n",
"\n",
"1 0 1 1 \n",
"\n",
"2 0 2 3 \n",
"\n",
"\n"
]
}
],
"source": [
"cm.print_matrix()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"\n",
" - Notice : new in version 1.2
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Relabel"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"`relabel` method is added in `version 1.5` in order to change ConfusionMatrix classnames."
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [],
"source": [
"cm.relabel(mapping={0:\"L1\",1:\"L2\",2:\"L3\"})"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"pycm.ConfusionMatrix(classes: ['L1', 'L2', 'L3'])"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 1.5
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Online help"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"`online_help` function is added in `version 1.1` in order to open each statistics definition in web browser"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"```python\n",
"\n",
">>> from pycm import online_help\n",
">>> online_help(\"J\")\n",
">>> online_help(\"SOA1(Landis & Koch)\")\n",
">>> online_help(2)\n",
"\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* List of items are available by calling `online_help()` (without argument)"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Please choose one parameter : \n",
"\n",
"Example : online_help(\"J\") or online_help(2)\n",
"\n",
"1-95% CI\n",
"2-ACC\n",
"3-AUC\n",
"4-AUCI\n",
"5-AUNP\n",
"6-AUNU\n",
"7-BM\n",
"8-Bennett S\n",
"9-CBA\n",
"10-CEN\n",
"11-Chi-Squared\n",
"12-Chi-Squared DF\n",
"13-Conditional Entropy\n",
"14-Cramer V\n",
"15-Cross Entropy\n",
"16-DOR\n",
"17-DP\n",
"18-DPI\n",
"19-ERR\n",
"20-F0.5\n",
"21-F1\n",
"22-F2\n",
"23-FDR\n",
"24-FN\n",
"25-FNR\n",
"26-FOR\n",
"27-FP\n",
"28-FPR\n",
"29-G\n",
"30-GI\n",
"31-Gwet AC1\n",
"32-Hamming Loss\n",
"33-IS\n",
"34-J\n",
"35-Joint Entropy\n",
"36-KL Divergence\n",
"37-Kappa\n",
"38-Kappa 95% CI\n",
"39-Kappa No Prevalence\n",
"40-Kappa Standard Error\n",
"41-Kappa Unbiased\n",
"42-LS\n",
"43-Lambda A\n",
"44-Lambda B\n",
"45-MCC\n",
"46-MCEN\n",
"47-MK\n",
"48-Mutual Information\n",
"49-N\n",
"50-NIR\n",
"51-NLR\n",
"52-NPV\n",
"53-Overall ACC\n",
"54-Overall CEN\n",
"55-Overall J\n",
"56-Overall MCC\n",
"57-Overall MCEN\n",
"58-Overall RACC\n",
"59-Overall RACCU\n",
"60-P\n",
"61-P-Value\n",
"62-PLR\n",
"63-PLRI\n",
"64-POP\n",
"65-PPV\n",
"66-PPV Macro\n",
"67-PPV Micro\n",
"68-PRE\n",
"69-Phi-Squared\n",
"70-RACC\n",
"71-RACCU\n",
"72-RCI\n",
"73-RR\n",
"74-Reference Entropy\n",
"75-Response Entropy\n",
"76-SOA1(Landis & Koch)\n",
"77-SOA2(Fleiss)\n",
"78-SOA3(Altman)\n",
"79-SOA4(Cicchetti)\n",
"80-Scott PI\n",
"81-Standard Error\n",
"82-TN\n",
"83-TNR\n",
"84-TON\n",
"85-TOP\n",
"86-TP\n",
"87-TPR\n",
"88-TPR Macro\n",
"89-TPR Micro\n",
"90-Y\n",
"91-Zero-one Loss\n",
"92-dInd\n",
"93-sInd\n"
]
}
],
"source": [
"online_help()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Acceptable data types\t"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"1. `actual_vector` : python `list` or numpy `array` of any stringable objects\n",
"2. `predict_vector` : python `list` or numpy `array` of any stringable objects\n",
"3. `matrix` : `dict`\n",
"4. `digit`: `int`\n",
"5. `threshold` : `FunctionType (function or lambda)`\n",
"6. `file` : `File object`\n",
"7. `sample_weight` : python `list` or numpy `array` of any stringable objects\n",
"8. `transpose` : `bool`"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* run `help(ConfusionMatrix)` for more information"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Basic parameters"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### TP (True positive)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A true positive test result is one that detects the condition when the\n",
"condition is present (correctly identified) [[3]](#References)."
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 3, 'L2': 1, 'L3': 3}"
]
},
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.TP"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### TN (True negative)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A true negative test result is one that does not detect the condition when\n",
"the condition is absent correctly rejected) [[3]](#References)."
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 7, 'L2': 8, 'L3': 4}"
]
},
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.TN"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### FP (False positive)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A false positive test result is one that detects the condition when the\n",
"condition is absent (incorrectly identified) [[3]](#References)."
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 0, 'L2': 2, 'L3': 3}"
]
},
"execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.FP"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### FN (False negative)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A false negative test result is one that does not detect the condition when\n",
"the condition is present (incorrectly rejected) [[3]](#References)."
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 2, 'L2': 1, 'L3': 2}"
]
},
"execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.FN"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### P (Condition positive)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Number of positive samples.\n",
"Also known as support (the number of occurrences of each class in y_true) [[3]](#References)."
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 5, 'L2': 2, 'L3': 5}"
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.P"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### N (Condition negative)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Number of negative samples [[3]](#References)."
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 7, 'L2': 10, 'L3': 7}"
]
},
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.N"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### TOP (Test outcome positive)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Number of positive outcomes [[3]](#References)."
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 3, 'L2': 3, 'L3': 6}"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.TOP"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### TON (Test outcome negative)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Number of negative outcomes [[3]](#References)."
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 9, 'L2': 9, 'L3': 6}"
]
},
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.TON"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### POP (Population)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For more information visit [[3]](#References)."
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 12, 'L2': 12, 'L3': 12}"
]
},
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.POP"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* Wikipedia page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Class statistics"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### TPR (True positive rate)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Sensitivity (also called the true positive rate, the recall, or probability of detection in some fields) measures the proportion of positives that are correctly identified as such (e.g. the percentage of sick people who are correctly identified as having the condition) [[3]](#References).\n",
"\n",
"Wikipedia page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$TPR=\\frac{TP}{P}=\\frac{TP}{TP+FN}$$"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 0.6, 'L2': 0.5, 'L3': 0.6}"
]
},
"execution_count": 39,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.TPR"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### TNR (True negative rate)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Specificity (also called the true negative rate) measures the proportion of negatives that are correctly identified as such (e.g. the percentage of healthy people who are correctly identified as not having the condition) [[3]](#References).\n",
"\n",
"Wikipedia page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$TNR=\\frac{TN}{N}=\\frac{TN}{TN+FP}$$"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 1.0, 'L2': 0.8, 'L3': 0.5714285714285714}"
]
},
"execution_count": 40,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.TNR"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### PPV (Positive predictive value)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Predictive value positive is the proportion of positives that correspond to\n",
"the presence of the condition [[3]](#References).\n",
"\n",
"Wikipedia page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$PPV=\\frac{TP}{TP+FP}$$"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 1.0, 'L2': 0.3333333333333333, 'L3': 0.5}"
]
},
"execution_count": 41,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.PPV"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### NPV (Negative predictive value)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Predictive value negative is the proportion of negatives that correspond to\n",
"the absence of the condition [[3]](#References).\n",
"\n",
"Wikipedia page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$NPV=\\frac{TN}{TN+FN}$$"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 0.7777777777777778, 'L2': 0.8888888888888888, 'L3': 0.6666666666666666}"
]
},
"execution_count": 42,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.NPV"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### FNR (False negative rate)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The false negative rate is the proportion of positives which yield negative test outcomes with the test, i.e., the conditional probability of a negative test result given that the condition being looked for is present [[3]](#References).\n",
"\n",
"Wikipedia page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$FNR=\\frac{FN}{P}=\\frac{FN}{FN+TP}=1-TPR$$"
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 0.4, 'L2': 0.5, 'L3': 0.4}"
]
},
"execution_count": 43,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.FNR"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### FPR (False positive rate)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The false positive rate is the proportion of all negatives that still yield positive test outcomes, i.e., the conditional probability of a positive test result given an event that was not present [[3]](#References).\n",
"\n",
"The false positive rate is equal to the significance level. The specificity of the test is equal to 1 minus the false positive rate.\n",
"\n",
"Wikipedia page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$FPR=\\frac{FP}{N}=\\frac{FP}{FP+TN}=1-TNR$$"
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 0.0, 'L2': 0.19999999999999996, 'L3': 0.4285714285714286}"
]
},
"execution_count": 44,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.FPR"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### FDR (False discovery rate)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The false discovery rate (FDR) is a method of conceptualizing the rate of type I errors in null hypothesis testing when conducting multiple comparisons. FDR-controlling procedures are designed to control the expected proportion of \"discoveries\" (rejected null hypotheses) that are false (incorrect rejections) [[3]](#References).\n",
"\n",
"Wikipedia page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$FDR=\\frac{FP}{FP+TP}=1-PPV$$"
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 0.0, 'L2': 0.6666666666666667, 'L3': 0.5}"
]
},
"execution_count": 45,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.FDR"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### FOR (False omission rate)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"False omission rate (FOR) is a statistical method used in multiple hypothesis testing to correct for multiple comparisons and it is the complement of the negative predictive value. It measures the proportion of false negatives which are incorrectly rejected [[3]](#References).\n",
"\n",
"Wikipedia page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$FOR=\\frac{FN}{FN+TN}=1-NPV$$"
]
},
{
"cell_type": "code",
"execution_count": 46,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 0.2222222222222222,\n",
" 'L2': 0.11111111111111116,\n",
" 'L3': 0.33333333333333337}"
]
},
"execution_count": 46,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.FOR"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### ACC (Accuracy)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The accuracy is the number of correct predictions from all predictions made [[3]](#References).\n",
"\n",
"Wikipedia page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$ACC=\\frac{TP+TN}{P+N}=\\frac{TP+TN}{TP+TN+FP+FN}$$"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 0.8333333333333334, 'L2': 0.75, 'L3': 0.5833333333333334}"
]
},
"execution_count": 47,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.ACC"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### ERR (Error rate)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The accuracy is the number of incorrect predictions from all predictions made [[3]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$ERR=\\frac{FP+FN}{P+N}=\\frac{FP+FN}{TP+TN+FP+FN}=1-ACC$$"
]
},
{
"cell_type": "code",
"execution_count": 48,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 0.16666666666666663, 'L2': 0.25, 'L3': 0.41666666666666663}"
]
},
"execution_count": 48,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.ERR"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.4
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### FBeta-Score"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In statistical analysis of classification, the F1 score (also F-score or F-measure) is a measure of a test's accuracy. It considers both the precision p and the recall r of the test to compute the score.\n",
"The F1 score is the harmonic average of the precision and recall, where F1 score reaches its best value at 1 (perfect precision and recall) and worst at 0 [[3]](#References).\n",
"\n",
"Wikipedia page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$F_{\\beta}=(1+\\beta^2)\\times \\frac{PPV\\times TPR}{(\\beta^2 \\times PPV)+TPR}=\\frac{(1+\\beta^2) \\times TP}{(1+\\beta^2)\\times TP+FP+\\beta^2 \\times FN}$$"
]
},
{
"cell_type": "code",
"execution_count": 49,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 0.75, 'L2': 0.4, 'L3': 0.5454545454545454}"
]
},
"execution_count": 49,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.F1"
]
},
{
"cell_type": "code",
"execution_count": 50,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 0.8823529411764706, 'L2': 0.35714285714285715, 'L3': 0.5172413793103449}"
]
},
"execution_count": 50,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.F05"
]
},
{
"cell_type": "code",
"execution_count": 51,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 0.6521739130434783, 'L2': 0.45454545454545453, 'L3': 0.5769230769230769}"
]
},
"execution_count": 51,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.F2"
]
},
{
"cell_type": "code",
"execution_count": 52,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 0.6144578313253012, 'L2': 0.4857142857142857, 'L3': 0.5930232558139535}"
]
},
"execution_count": 52,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.F_beta(Beta=4)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.4
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### MCC (Matthews correlation coefficient)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The Matthews correlation coefficient is used in machine learning as a measure of the quality of binary (two-class) classifications, introduced by biochemist Brian W. Matthews in 1975. It takes into account true and false positives and negatives and is generally regarded as a balanced measure which can be used even if the classes are of very different sizes.The MCC is in essence a correlation coefficient between the observed and predicted binary classifications; it returns a value between −1 and +1. A coefficient of +1 represents a perfect prediction, 0 no better than random prediction and −1 indicates total disagreement between prediction and observation [[27]](#References).\n",
"\n",
"Wikipedia page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$MCC=\\frac{TP \\times TN-FP \\times FN}{\\sqrt{(TP+FP)\\times (TP+FN)\\times (TN+FP)\\times (TN+FN)}}$$"
]
},
{
"cell_type": "code",
"execution_count": 53,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 0.6831300510639732, 'L2': 0.25819888974716115, 'L3': 0.1690308509457033}"
]
},
"execution_count": 53,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.MCC"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### BM (Bookmaker informedness)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The informedness of a prediction method as captured by a contingency matrix is defined as the probability that the prediction method will make a correct decision as opposed to guessing and is calculated using the bookmaker algorithm [[2]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$BM=TPR+TNR-1$$"
]
},
{
"cell_type": "code",
"execution_count": 54,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 0.6000000000000001,\n",
" 'L2': 0.30000000000000004,\n",
" 'L3': 0.17142857142857126}"
]
},
"execution_count": 54,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.BM"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### MK (Markedness)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In statistics and psychology, the social science concept of markedness is quantified as a measure of how much one variable is marked as a predictor or possible cause of another, and is also known as Δp (deltaP) in simple two-choice cases [[2]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$MK=PPV+NPV-1$$"
]
},
{
"cell_type": "code",
"execution_count": 55,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 0.7777777777777777, 'L2': 0.2222222222222221, 'L3': 0.16666666666666652}"
]
},
"execution_count": 55,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.MK"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### PLR (Positive likelihood ratio)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Likelihood ratios are used for assessing the value of performing a diagnostic test. They use the sensitivity and specificity of the test to determine whether a test result usefully changes the probability that a condition (such as a disease state) exists. The first description of the use of likelihood ratios for decision rules was made at a symposium on information theory in 1954 [[28]](#References).\n",
"\n",
"Wikipedia page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$LR_+=PLR=\\frac{TPR}{FPR}$$"
]
},
{
"cell_type": "code",
"execution_count": 56,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 'None', 'L2': 2.5000000000000004, 'L3': 1.4}"
]
},
"execution_count": 56,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.PLR"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : `LR+` renamed to `PLR` in version 1.5
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### NLR (Negative likelihood ratio)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Likelihood ratios are used for assessing the value of performing a diagnostic test. They use the sensitivity and specificity of the test to determine whether a test result usefully changes the probability that a condition (such as a disease state) exists. The first description of the use of likelihood ratios for decision rules was made at a symposium on information theory in 1954 [[28]](#References).\n",
"\n",
"Wikipedia page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$LR_-=NLR=\\frac{FNR}{TNR}$$"
]
},
{
"cell_type": "code",
"execution_count": 57,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 0.4, 'L2': 0.625, 'L3': 0.7000000000000001}"
]
},
"execution_count": 57,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.NLR"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : `LR-` renamed to `NLR` in version 1.5
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### DOR (Diagnostic odds ratio)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The diagnostic odds ratio is a measure of the effectiveness of a diagnostic test. It is defined as the ratio of the odds of the test being positive if the subject has a disease relative to the odds of the test being positive if the subject does not have the disease [[28]](#References).\n",
"\n",
"Wikipedia page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$DOR=\\frac{LR+}{LR-}$$"
]
},
{
"cell_type": "code",
"execution_count": 58,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 'None', 'L2': 4.000000000000001, 'L3': 1.9999999999999998}"
]
},
"execution_count": 58,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.DOR"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### PRE (Prevalence)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Prevalence is a statistical concept referring to the number of cases of a disease that are present in a particular population at a given time (Reference Likelihood) [[14]](#References).\n",
"\n",
"Wikipedia page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$Prevalence=\\frac{P}{POP}$$"
]
},
{
"cell_type": "code",
"execution_count": 59,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 0.4166666666666667, 'L2': 0.16666666666666666, 'L3': 0.4166666666666667}"
]
},
"execution_count": 59,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.PRE"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### G (G-measure)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Geometric mean of precision and sensitivity [[3]](#References).\n",
"\n",
"Wikipedia page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$G=\\sqrt{PPV\\times TPR}$$"
]
},
{
"cell_type": "code",
"execution_count": 60,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 0.7745966692414834, 'L2': 0.408248290463863, 'L3': 0.5477225575051661}"
]
},
"execution_count": 60,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.G"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### RACC (Random accuracy)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The expected accuracy from a strategy of randomly guessing categories according to reference and response distributions [[24]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$RACC=\\frac{TOP \\times P}{POP^2}$$"
]
},
{
"cell_type": "code",
"execution_count": 61,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 0.10416666666666667,\n",
" 'L2': 0.041666666666666664,\n",
" 'L3': 0.20833333333333334}"
]
},
"execution_count": 61,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.RACC"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.3
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### RACCU (Random accuracy unbiased)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The expected accuracy from a strategy of randomly guessing categories according to the average of the reference and response distributions [[25]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$RACCU=(\\frac{TOP+P}{2 \\times POP})^2$$"
]
},
{
"cell_type": "code",
"execution_count": 62,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 0.1111111111111111,\n",
" 'L2': 0.04340277777777778,\n",
" 'L3': 0.21006944444444442}"
]
},
"execution_count": 62,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.RACCU"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.8.1
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### J (Jaccard index)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The Jaccard index, also known as Intersection over Union and the Jaccard similarity coefficient (originally coined coefficient de communauté by Paul Jaccard), is a statistic used for comparing the similarity and diversity of sample sets [[29]](#References).\n",
"\n",
"Wikipedia page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$A=Vector_{Actual}$$\n",
"$$B=Vector_{Predict}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$J(A,B)=\\frac{|A\\cap B|}{|A\\cup B|}=\\frac{|A\\cap B|}{|A|+|B|-|A\\cap B|}$$"
]
},
{
"cell_type": "code",
"execution_count": 63,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 0.6, 'L2': 0.25, 'L3': 0.375}"
]
},
"execution_count": 63,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.J"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.9
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### IS (Information score)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The amount of information needed to correctly classify an example into\n",
"class C, whose prior probability is p(C), is defined as -log2(p(C)) [[18]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$IS=-log_2(\\frac{TP+FN}{POP})+log_2(\\frac{TP}{TP+FP})$$"
]
},
{
"cell_type": "code",
"execution_count": 64,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 1.2630344058337937, 'L2': 0.9999999999999998, 'L3': 0.26303440583379367}"
]
},
"execution_count": 64,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.IS"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 1.3
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### CEN (Confusion entropy)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"CEN based upon the concept of entropy for evaluating classifier performances. By exploiting the misclassification information of confusion matrices, the measure evaluates the confusion level of the class distribution of\n",
"misclassified samples. Both theoretical analysis and statistical results show that the proposed measure is more discriminating than accuracy and RCI while it remains relatively consistent with the two measures. Moreover, it is more capable of measuring how the samples of different classes have been separated from each\n",
"other. Hence the proposed measure is more precise than the two measures and can substitute for them to evaluate classifiers in classification applications [[17]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$P_{i,j}^{j}=\\frac{Matrix(i,j)}{\\sum_{k=1}^{|C|}\\Big(Matrix(j,k)+Matrix(k,j)\\Big)}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$P_{i,j}^{i}=\\frac{Matrix(i,j)}{\\sum_{k=1}^{|C|}\\Big(Matrix(i,k)+Matrix(k,i)\\Big)}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$CEN_j=-\\sum_{k=1,k\\neq j}^{|C|}\\Bigg(P_{j,k}^jlog_{2(|C|-1)}\\Big(P_{j,k}^j\\Big)+P_{k,j}^jlog_{2(|C|-1)}\\Big(P_{k,j}^j\\Big)\\Bigg)$$"
]
},
{
"cell_type": "code",
"execution_count": 65,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 0.25, 'L2': 0.49657842846620864, 'L3': 0.6044162769630221}"
]
},
"execution_count": 65,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.CEN"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 1.3
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### MCEN (Modified confusion entropy)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Modified version of CEN [[19]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$P_{i,j}^{j}=\\frac{Matrix(i,j)}{\\sum_{k=1}^{|C|}\\Big(Matrix(j,k)+Matrix(k,j)\\Big)-Matrix(j,j)}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$P_{i,j}^{i}=\\frac{Matrix(i,j)}{\\sum_{k=1}^{|C|}\\Big(Matrix(i,k)+Matrix(k,i)\\Big)-Matrix(i,i)}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$MCEN_j=-\\sum_{k=1,k\\neq j}^{|C|}\\Bigg(P_{j,k}^jlog_{2(|C|-1)}\\Big(P_{j,k}^j\\Big)+P_{k,j}^jlog_{2(|C|-1)}\\Big(P_{k,j}^j\\Big)\\Bigg)$$"
]
},
{
"cell_type": "code",
"execution_count": 66,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 0.2643856189774724, 'L2': 0.5, 'L3': 0.6875}"
]
},
"execution_count": 66,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.MCEN"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 1.3
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### AUC (Area under the ROC curve)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Thus, AUC corresponds to the arithmetic mean of sensitivity and specificity values of each class [[23]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$AUC=\\frac{TNR+TPR}{2}$$"
]
},
{
"cell_type": "code",
"execution_count": 67,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 0.8, 'L2': 0.65, 'L3': 0.5857142857142856}"
]
},
"execution_count": 67,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.AUC"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 1.4
\n",
" - Notice : this is an approximate calculation of AUC
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### dInd (Distance index)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Euclidean distance of a ROC point from the top left corner of the ROC space, which can take values between 0 (perfect classification) and sqrt(2) [[23]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$dInd=\\sqrt{(1-TNR)^2+(1-TPR)^2}$$"
]
},
{
"cell_type": "code",
"execution_count": 68,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 0.4, 'L2': 0.5385164807134504, 'L3': 0.5862367008195198}"
]
},
"execution_count": 68,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.dInd"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 1.4
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### sInd (Similarity index)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"sInd is comprised between 0 (no correct classifications) and 1 (perfect classification) [[23]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$sInd = 1 - \\sqrt{\\frac{(1-TNR)^2+(1-TPR)^2}{2}}$$"
]
},
{
"cell_type": "code",
"execution_count": 69,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 0.717157287525381, 'L2': 0.6192113447068046, 'L3': 0.5854680534700882}"
]
},
"execution_count": 69,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.sInd"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 1.4
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### DP (Discriminant power) "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Discriminant power (DP) is a measure that summarizes sensitivity and specificity.\n",
"The DP has been used mainly in feature selection over imbalanced data [[33]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$X=\\frac{TPR}{1-TPR}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$Y=\\frac{TNR}{1-TNR}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$DP=\\frac{\\sqrt{3}}{\\pi}(log_{10}X+log_{10}Y)$$"
]
},
{
"cell_type": "code",
"execution_count": 70,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 'None', 'L2': 0.33193306999649924, 'L3': 0.1659665349982495}"
]
},
"execution_count": 70,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.DP"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 1.5
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Y (Youden index)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Youden’s index, evaluates the algorithm’s ability to avoid failure; it’s derived from sensitivity and\n",
"specificity and denotes a linear correspondence balanced accuracy.\n",
"As Youden’s index is a linear transformation of the mean sensitivity and specificity, its values are difficult to\n",
"interpret, we retain that a higher value of Y indicates better ability to avoid failure. \n",
"Youden’s index has been conventionally used to evaluate tests diagnostic, improve efficiency of\n",
"Telemedical prevention [[33]](#References) [[34]](#References).\n",
"\n",
"Wikipedia page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$\\gamma=BM=TPR+TNR-1$$"
]
},
{
"cell_type": "code",
"execution_count": 71,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 0.6000000000000001,\n",
" 'L2': 0.30000000000000004,\n",
" 'L3': 0.17142857142857126}"
]
},
"execution_count": 71,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.Y"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 1.5
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### PLRI (Positive likelihood ratio interpretation)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For more information visit [[33]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" \n",
" PLR | \n",
" Model contribution | \n",
"
\n",
" \n",
" 1 > | \n",
" Negligible | \n",
"
\n",
" \n",
" 1 - 5 | \n",
" Poor | \n",
"
\n",
" \n",
" 5 - 10 | \n",
" Fair | \n",
"
\n",
" \n",
" > 10 | \n",
" Good | \n",
"
\n",
" \n",
" \n",
"
"
]
},
{
"cell_type": "code",
"execution_count": 72,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 'None', 'L2': 'Poor', 'L3': 'Poor'}"
]
},
"execution_count": 72,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.PLRI"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 1.5
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### DPI (Discriminant power interpretation)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For more information visit [[33]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" \n",
" DP | \n",
" Model contribution | \n",
"
\n",
" \n",
" 1 > | \n",
" Poor | \n",
"
\n",
" \n",
" 1 - 2 | \n",
" Limited | \n",
"
\n",
" \n",
" 2 - 3 | \n",
" Fair | \n",
"
\n",
" \n",
" > 3 | \n",
" Good | \n",
"
\n",
" \n",
" \n",
"
"
]
},
{
"cell_type": "code",
"execution_count": 73,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 'None', 'L2': 'Poor', 'L3': 'Poor'}"
]
},
"execution_count": 73,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.DPI"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 1.5
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### AUCI (AUC value interpretation)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For more information visit [[33]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" \n",
" AUC | \n",
" Model performance | \n",
"
\n",
" \n",
" 0.5 - 0.6 | \n",
" Poor | \n",
"
\n",
" \n",
" 0.6 - 0.7 | \n",
" Fair | \n",
"
\n",
" \n",
" 0.7 - 0.8 | \n",
" Good | \n",
"
\n",
" \n",
" 0.8 - 0.9 | \n",
" Very Good | \n",
"
\n",
" \n",
" 0.9 - 1.0 | \n",
" Excellent | \n",
"
\n",
" \n",
"
"
]
},
{
"cell_type": "code",
"execution_count": 74,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 'Very Good', 'L2': 'Fair', 'L3': 'Poor'}"
]
},
"execution_count": 74,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.AUCI"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 1.6
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### GI (Gini index)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A chance-standardized variant of the AUC is given by Gini coefficient, taking values between 0 (no difference\n",
"between the score distributions of the two classes) and 1 (complete separation between the two distributions).\n",
"Gini coefficient is widespread use metric in imbalanced data learning [[33]](#References). \n",
"\n",
"Wikipedia page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$GI=2\\times AUC-1$$"
]
},
{
"cell_type": "code",
"execution_count": 75,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 0.6000000000000001,\n",
" 'L2': 0.30000000000000004,\n",
" 'L3': 0.17142857142857126}"
]
},
"execution_count": 75,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.GI"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 1.7
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### LS (Lift index)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In the context of classification, lift compares model predictions to randomly generated predictions. Lift is often used in marketing research combined with gain and lift charts as a visual aid [[35]](#References) [[36]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$LS=\\frac{PPV}{PRE}$$"
]
},
{
"cell_type": "code",
"execution_count": 76,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'L1': 2.4, 'L2': 2.0, 'L3': 1.2}"
]
},
"execution_count": 76,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.LS"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 1.8
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Overall statistics"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Kappa"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Kappa is a statistic which measures inter-rater agreement for qualitative (categorical) items. It is generally thought to be a more robust measure than simple percent agreement calculation, as kappa takes into account the possibility of the agreement occurring by chance [[24]](#References).\n",
"\n",
"Wikipedia page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$Kappa=\\frac{ACC_{Overall}-RACC_{Overall}}{1-RACC_{Overall}}$$"
]
},
{
"cell_type": "code",
"execution_count": 77,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.35483870967741943"
]
},
"execution_count": 77,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.Kappa"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.3
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Kappa unbiased"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The unbiased kappa value is defined in terms of total accuracy and a slightly different computation of expected likelihood that averages the reference and response probabilities [[25]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$Kappa_{Unbiased}=\\frac{ACC_{Overall}-RACCU_{Overall}}{1-RACCU_{Overall}}$$"
]
},
{
"cell_type": "code",
"execution_count": 78,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.34426229508196726"
]
},
"execution_count": 78,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.KappaUnbiased"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.8.1
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Kappa no prevalence"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The kappa statistic adjusted for prevalence [[14]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$Kappa_{NoPrevalence}=2 \\times ACC_{Overall}-1$$"
]
},
{
"cell_type": "code",
"execution_count": 79,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.16666666666666674"
]
},
"execution_count": 79,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.KappaNoPrevalence"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.8.1
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Kappa 95% CI"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Kappa 95% Confidence Interval [[24]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$SE_{Kappa}=\\sqrt{\\frac{ACC_{Overall}\\times (1-RACC_{Overall})}{(1-RACC_{Overall})^2}}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$Kappa \\pm 1.96\\times SE_{Kappa}$$"
]
},
{
"cell_type": "code",
"execution_count": 80,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.2203645326012817"
]
},
"execution_count": 80,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.Kappa_SE"
]
},
{
"cell_type": "code",
"execution_count": 81,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(-0.07707577422109269, 0.7867531935759315)"
]
},
"execution_count": 81,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.Kappa_CI"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.7
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Chi-squared"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Pearson's chi-squared test is a statistical test applied to sets of categorical data to evaluate how likely it is that any observed difference between the sets arose by chance. It is suitable for unpaired data from large samples [[10]](#References).\n",
"\n",
"Wikipedia page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$\\chi^2=\\sum_{i=1}^n\\sum_{j=1}^n\\frac{\\Big(Matrix(i,j)-E(i,j)\\Big)^2}{E(i,j)}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$E(i,j)=\\frac{TOP_j\\times P_i}{POP}$$"
]
},
{
"cell_type": "code",
"execution_count": 82,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"6.6000000000000005"
]
},
"execution_count": 82,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.Chi_Squared"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.7
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Chi-squared DF"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Number of degrees of freedom of this confusion matrix for the chi-squared statistic [[10]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$DF=(|C|-1)^2$$"
]
},
{
"cell_type": "code",
"execution_count": 83,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"4"
]
},
"execution_count": 83,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.DF"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.7
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Phi-squared"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In statistics, the phi coefficient (or mean square contingency coefficient) is a measure of association for two binary variables. Introduced by Karl Pearson, this measure is similar to the Pearson correlation coefficient in its interpretation. In fact, a Pearson correlation coefficient estimated for two binary variables will return the phi coefficient [[10]](#References).\n",
"\n",
"Wikipedia page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$\\phi^2=\\frac{\\chi^2}{POP}$$"
]
},
{
"cell_type": "code",
"execution_count": 84,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.55"
]
},
"execution_count": 84,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.Phi_Squared"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.7
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Cramer's V"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In statistics, Cramér's V (sometimes referred to as Cramér's phi) is a measure of association between two nominal variables, giving a value between 0 and +1 (inclusive). It is based on Pearson's chi-squared statistic and was published by Harald Cramér in 1946 [[26]](#References).\n",
"\n",
"Wikipedia page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$V=\\sqrt{\\frac{\\phi^2}{|C|-1}}$$"
]
},
{
"cell_type": "code",
"execution_count": 85,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.5244044240850758"
]
},
"execution_count": 85,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.V"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.7
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 95% CI"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In statistics, a confidence interval (CI) is a type of interval estimate (of a population parameter) that is computed from the observed data. The confidence level is the frequency (i.e., the proportion) of possible confidence intervals that contain the true value of their corresponding parameter. In other words, if confidence intervals are constructed using a given confidence level in an infinite number of independent experiments, the proportion of those intervals that contain the true value of the parameter will match the confidence level [[31]](#References).\n",
"\n",
"Wikipedia page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$SE_{ACC}=\\sqrt{\\frac{ACC\\times (1-ACC)}{POP}}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$ACC \\pm 1.96\\times SE_{ACC}$$"
]
},
{
"cell_type": "code",
"execution_count": 86,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(0.30438856248221097, 0.8622781041844558)"
]
},
"execution_count": 86,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.CI"
]
},
{
"cell_type": "code",
"execution_count": 87,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.14231876063832777"
]
},
"execution_count": 87,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.SE"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.7
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Bennett's S"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Bennett, Alpert & Goldstein’s S is a statistical measure of inter-rater agreement. It was created by Bennett et al. in 1954.\n",
"Bennett et al. suggested adjusting inter-rater reliability to accommodate the percentage of rater agreement that might be expected by chance was a better measure than simple agreement between raters [[8]](#References).\n",
"\n",
"Wikipedia Page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$p_c=\\frac{1}{|C|}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$S=\\frac{ACC_{Overall}-p_c}{1-p_c}$$"
]
},
{
"cell_type": "code",
"execution_count": 88,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.37500000000000006"
]
},
"execution_count": 88,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.S"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.5
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Scott's Pi"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Scott's pi (named after William A. Scott) is a statistic for measuring inter-rater reliability for nominal data in communication studies. Textual entities are annotated with categories by different annotators, and various measures are used to assess the extent of agreement between the annotators, one of which is Scott's pi. Since automatically annotating text is a popular problem in natural language processing, and goal is to get the computer program that is being developed to agree with the humans in the annotations it creates, assessing the extent to which humans agree with each other is important for establishing a reasonable upper limit on computer performance [[7]](#References).\n",
"\n",
"Wikipedia page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$p_c=\\sum_{i=1}^{|C|}(\\frac{TOP_i + P_i}{2\\times POP})^2$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$\\pi=\\frac{ACC_{Overall}-p_c}{1-p_c}$$"
]
},
{
"cell_type": "code",
"execution_count": 89,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.34426229508196726"
]
},
"execution_count": 89,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.PI"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.5
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Gwet's AC1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"AC1 was originally introduced by Gwet in 2001 (Gwet, 2001). The interpretation of AC1 is similar to generalized kappa (Fleiss, 1971), which is used to assess interrater reliability of when there are multiple raters. Gwet (2002) demonstrated that AC1 can overcome the limitations that kappa is sensitive to trait prevalence and rater's classification probabilities (i.e., marginal probabilities), whereas AC1 provides more robust measure of interrater reliability [[6]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$\\pi_i=\\frac{TOP_i + P_i}{2\\times POP}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$p_c=\\frac{1}{|C|-1}\\sum_{i=1}^{|C|}\\Big(\\pi_i\\times (1-\\pi_i)\\Big)$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$AC_1=\\frac{ACC_{Overall}-p_c}{1-p_c}$$"
]
},
{
"cell_type": "code",
"execution_count": 90,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.3893129770992367"
]
},
"execution_count": 90,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.AC1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.5
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Reference entropy"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The entropy of the decision problem itself as defined by the counts for the reference. The entropy of a distribution is the average negative log probability of outcomes [[30]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$Likelihood_{Reference}=\\frac{P_i}{POP}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$Entropy_{Reference}=-\\sum_{i=1}^{|C|}Likelihood_{Reference}(i)\\times\\log_{2}{Likelihood_{Reference}(i)}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$0\\times\\log_{2}{0}\\equiv0$$"
]
},
{
"cell_type": "code",
"execution_count": 91,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1.4833557549816874"
]
},
"execution_count": 91,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.ReferenceEntropy"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.8.1
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Response entropy"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The entropy of the response distribution. The entropy of a distribution is the average negative log probability of outcomes [[30]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$Likelihood_{Response}=\\frac{TOP_i}{POP}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$Entropy_{Response}=-\\sum_{i=1}^{|C|}Likelihood_{Response}(i)\\times\\log_{2}{Likelihood_{Response}(i)}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$0\\times\\log_{2}{0}\\equiv0$$"
]
},
{
"cell_type": "code",
"execution_count": 92,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1.5"
]
},
"execution_count": 92,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.ResponseEntropy"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.8.1
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Cross entropy"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The cross-entropy of the response distribution against the reference distribution. The cross-entropy is defined by the negative log probabilities of the response distribution weighted by the reference distribution [[30]](#References).\n",
"\n",
"Wikipedia page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$Likelihood_{Reference}=\\frac{P_i}{POP}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$Likelihood_{Response}=\\frac{TOP_i}{POP}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$Entropy_{Cross}=-\\sum_{i=1}^{|C|}Likelihood_{Reference}(i)\\times\\log_{2}{Likelihood_{Response}(i)}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$0\\times\\log_{2}{0}\\equiv0$$"
]
},
{
"cell_type": "code",
"execution_count": 93,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1.5833333333333335"
]
},
"execution_count": 93,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.CrossEntropy"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.8.1
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Joint entropy"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The entropy of the joint reference and response distribution as defined by the underlying matrix [[30]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$P^{'}(i,j)=\\frac{Matrix(i,j)}{POP}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$Entropy_{Joint}=-\\sum_{i=1}^{|C|}\\sum_{j=1}^{|C|}P^{'}(i,j)\\times\\log_{2}{P^{'}(i,j)}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$0\\times\\log_{2}{0}\\equiv0$$"
]
},
{
"cell_type": "code",
"execution_count": 94,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2.4591479170272446"
]
},
"execution_count": 94,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.JointEntropy"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.8.1
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Conditional entropy"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The entropy of the distribution of categories in the response given that the reference category was as specified [[30]](#References).\n",
"\n",
"Wikipedia page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$P^{'}(j|i)=\\frac{Matrix(j,i)}{P_i}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$Entropy_{Conditional}=\\sum_{i=1}^{|C|}\\Bigg(Likelihood_{Reference}(i)\\times\\Big(-\\sum_{j=1}^{|C|}P^{'}(j|i)\\times\\log_{2}{P^{'}(j|i)}\\Big)\\Bigg)$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$0\\times\\log_{2}{0}\\equiv0$$"
]
},
{
"cell_type": "code",
"execution_count": 95,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.9757921620455572"
]
},
"execution_count": 95,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.ConditionalEntropy"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.8.1
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Kullback-Liebler divergence"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In mathematical statistics, the Kullback–Leibler divergence (also called relative entropy) is a measure of how one probability distribution diverges from a second, expected probability distribution [[11]](#References) [[30]](#References).\n",
"\n",
"Wikipedia Page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$Likelihood_{Response}=\\frac{TOP_i}{POP}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$Likelihood_{Reference}=\\frac{P_i}{POP}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$Divergence=-\\sum_{i=1}^{|C|}Likelihood_{Reference}\\times\\log_{2}{\\frac{Likelihood_{Reference}}{Likelihood_{Response}}}$$"
]
},
{
"cell_type": "code",
"execution_count": 96,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.09997757835164581"
]
},
"execution_count": 96,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.KL"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.8.1
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Mutual information"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Mutual information is defined Kullback-Lieblier divergence, between the product of the individual distributions and the joint distribution.\n",
"Mutual information is symmetric. We could also subtract the conditional entropy of the reference given the response from the reference entropy to get the same result [[11]](#References) [[30]](#References).\n",
"\n",
"Wikipedia Page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$P^{'}(i,j)=\\frac{Matrix(i,j)}{POP}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$Likelihood_{Reference}=\\frac{P_i}{POP}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$Likelihood_{Response}=\\frac{TOP_i}{POP}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$MI=-\\sum_{i=1}^{|C|}\\sum_{j=1}^{|C|}P^{'}(i,j)\\times\\log_{2}\\Big({\\frac{P^{'}(i,j)}{Likelihood_{Reference}(i)\\times Likelihood_{Response}(i) }\\Big)}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$MI=Entropy_{Response}-Entropy_{Conditional}$$"
]
},
{
"cell_type": "code",
"execution_count": 97,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.5242078379544428"
]
},
"execution_count": 97,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.MutualInformation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.8.1
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Goodman & Kruskal's lambda A"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In probability theory and statistics, Goodman & Kruskal's lambda is a measure of proportional reduction in error in cross tabulation analysis [[12]](#References).\n",
"\n",
"Wikipedia page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$\\lambda_A=\\frac{\\sum_{j=1}^{|C|}Max\\Big(Matrix(-,j)\\Big)-Max(P)}{POP-Max(P)}$$"
]
},
{
"cell_type": "code",
"execution_count": 98,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.42857142857142855"
]
},
"execution_count": 98,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.LambdaA"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.8.1
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Goodman & Kruskal's lambda B"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In probability theory and statistics, Goodman & Kruskal's lambda is a measure of proportional reduction in error in cross tabulation analysis [[13]](#References).\n",
"\n",
"Wikipedia Page"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$\\lambda_B=\\frac{\\sum_{i=1}^{|C|}Max\\Big(Matrix(i,-)\\Big)-Max(TOP)}{POP-Max(TOP)}$$"
]
},
{
"cell_type": "code",
"execution_count": 99,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.16666666666666666"
]
},
"execution_count": 99,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.LambdaB"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.8.1
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### SOA1 (Landis & Koch’s benchmark)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For more information visit [[1]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" \n",
" Kappa | \n",
" Strength of Agreement | \n",
"
\n",
" \n",
" 0 > | \n",
" Poor | \n",
"
\n",
" \n",
" 0 - 0.20 | \n",
" Slight | \n",
"
\n",
" \n",
" 0.21 – 0.40 | \n",
" Fair | \n",
"
\n",
" \n",
" 0.41 – 0.60 | \n",
" Moderate | \n",
"
\n",
" \n",
" 0.61 – 0.80 | \n",
" Substantial | \n",
"
\n",
" \n",
" 0.81 – 1.00 | \n",
" Almost perfect | \n",
"
\n",
" \n",
" \n",
"
"
]
},
{
"cell_type": "code",
"execution_count": 100,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Fair'"
]
},
"execution_count": 100,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.SOA1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.3
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### SOA2 (Fleiss’ benchmark)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For more information visit [[4]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" \n",
" Kappa | \n",
" Strength of Agreement | \n",
"
\n",
" \n",
" 0.40 > | \n",
" Poor | \n",
"
\n",
" \n",
" 0.4 - 0.75 | \n",
" Intermediate to Good | \n",
"
\n",
" \n",
" More than 0.75 | \n",
" Excellent | \n",
"
\n",
" \n",
" \n",
"
"
]
},
{
"cell_type": "code",
"execution_count": 101,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Poor'"
]
},
"execution_count": 101,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.SOA2"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.4
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### SOA3 (Altman’s benchmark)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For more information visit [[5]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" \n",
" Kappa | \n",
" Strength of Agreement | \n",
"
\n",
" \n",
" 0.2 > | \n",
" Poor | \n",
"
\n",
" \n",
" 0.21 – 0.40 | \n",
" Fair | \n",
"
\n",
" \n",
" 0.41 – 0.60 | \n",
" Moderate | \n",
"
\n",
" \n",
" 0.61 – 0.80 | \n",
" Good | \n",
"
\n",
" \n",
" 0.81 – 1.00 | \n",
" Very Good | \n",
"
\n",
" \n",
" \n",
"
"
]
},
{
"cell_type": "code",
"execution_count": 102,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Fair'"
]
},
"execution_count": 102,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.SOA3"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.4
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### SOA4 (Cicchetti’s benchmark)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For more information visit [[9]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" \n",
" Kappa | \n",
" Strength of Agreement | \n",
"
\n",
" \n",
" 0.4 > | \n",
" Poor | \n",
"
\n",
" \n",
" 0.4 – 0.59 | \n",
" Fair | \n",
"
\n",
" \n",
" 0.6 – 0.74 | \n",
" Good | \n",
"
\n",
" \n",
" 0.74 – 1.00 | \n",
" Excellent | \n",
"
\n",
" \n",
" \n",
"
"
]
},
{
"cell_type": "code",
"execution_count": 103,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Poor'"
]
},
"execution_count": 103,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.SOA4"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.7
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Overall_ACC"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For more information visit [[3]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$ACC_{Overall}=\\frac{\\sum_{i=1}^{|C|}TP_i}{POP}$$"
]
},
{
"cell_type": "code",
"execution_count": 104,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.5833333333333334"
]
},
"execution_count": 104,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.Overall_ACC"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.4
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Overall_RACC"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For more information visit [[24]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$RACC_{Overall}=\\sum_{i=1}^{|C|}RACC_i$$"
]
},
{
"cell_type": "code",
"execution_count": 105,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.3541666666666667"
]
},
"execution_count": 105,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.Overall_RACC"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.4
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Overall_RACCU"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For more information visit [[25]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$RACCU_{Overall}=\\sum_{i=1}^{|C|}RACCU_i$$"
]
},
{
"cell_type": "code",
"execution_count": 106,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.3645833333333333"
]
},
"execution_count": 106,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.Overall_RACCU"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.8.1
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### PPV_Micro"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For more information visit [[3]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$PPV_{Micro}=\\frac{\\sum_{i=1}^{|C|}TP_i}{\\sum_{i=1}^{|C|}TP_i+FP_i}$$"
]
},
{
"cell_type": "code",
"execution_count": 107,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.5833333333333334"
]
},
"execution_count": 107,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.PPV_Micro"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.4
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### TPR_Micro"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For more information visit [[3]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$TPR_{Micro}=\\frac{\\sum_{i=1}^{|C|}TP_i}{\\sum_{i=1}^{|C|}TP_i+FN_i}$$"
]
},
{
"cell_type": "code",
"execution_count": 108,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.5833333333333334"
]
},
"execution_count": 108,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.TPR_Micro"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.4
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### PPV_Macro"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For more information visit [[3]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$PPV_{Macro}=\\frac{1}{|C|}\\sum_{i=1}^{|C|}\\frac{TP_i}{TP_i+FP_i}$$"
]
},
{
"cell_type": "code",
"execution_count": 109,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.611111111111111"
]
},
"execution_count": 109,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.PPV_Macro"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.4
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### TPR_Macro"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For more information visit [[3]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$TPR_{Macro}=\\frac{1}{|C|}\\sum_{i=1}^{|C|}\\frac{TP_i}{TP_i+FN_i}$$"
]
},
{
"cell_type": "code",
"execution_count": 110,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.5666666666666668"
]
},
"execution_count": 110,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.TPR_Macro"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.4
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Overall_J"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For more information visit [[29]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$J_{Mean}=\\frac{1}{|C|}\\sum_{i=1}^{|C|}J_i$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$J_{Sum}=\\sum_{i=1}^{|C|}J_i$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$J_{Overall}=(J_{Sum},J_{Mean})$$"
]
},
{
"cell_type": "code",
"execution_count": 111,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(1.225, 0.4083333333333334)"
]
},
"execution_count": 111,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.Overall_J"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.9
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Hamming loss"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The hamming_loss computes the average Hamming loss or Hamming distance between two sets of samples [[31]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$L_{Hamming}=\\frac{1}{POP}\\sum_{i=1}^{|P|}1(y_i \\neq \\widehat{y}_i)$$"
]
},
{
"cell_type": "code",
"execution_count": 112,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.41666666666666663"
]
},
"execution_count": 112,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.HammingLoss"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 1.0
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Zero-one loss"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For more information visit [[31]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$L_{0-1}=\\sum_{i=1}^{|P|}1(y_i \\neq \\widehat{y}_i)$$"
]
},
{
"cell_type": "code",
"execution_count": 113,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"5"
]
},
"execution_count": 113,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.ZeroOneLoss"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 1.1
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### NIR (No information rate)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The no information error rate is the error rate when the input and output are independent."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$NIR=\\frac{1}{POP}Max(P)$$"
]
},
{
"cell_type": "code",
"execution_count": 114,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.4166666666666667"
]
},
"execution_count": 114,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.NIR"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 1.2
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### P-Value"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For more information visit [[31]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$x=\\sum_{i=1}^{|C|}TP_{i}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$p=NIR$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$n=POP$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$P-Value_{(ACC > NIR)}=1-\\sum_{i=1}^{x}\\left(\\begin{array}{c}n\\\\ i\\end{array}\\right)p^{i}(1-p)^{n-i}$$"
]
},
{
"cell_type": "code",
"execution_count": 115,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.18926430237560654"
]
},
"execution_count": 115,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.PValue"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 1.2
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Overall_CEN"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For more information visit [[17]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$P_j=\\frac{\\sum_{k=1}^{|C|}\\Big(Matrix(j,k)+Matrix(k,j)\\Big)}{2\\sum_{k,l=1}^{|C|}Matrix(k,l)}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$CEN_{Overall}=\\sum_{j=1}^{|C|}P_jCEN_j$$"
]
},
{
"cell_type": "code",
"execution_count": 116,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.4638112995385119"
]
},
"execution_count": 116,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.Overall_CEN"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 1.3
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Overall_MCEN"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For more information visit [[19]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$\\alpha=\\begin{cases}1 & |C| > 2\\\\0 & |C| = 2\\end{cases}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$P_j=\\frac{\\sum_{k=1}^{|C|}\\Big(Matrix(j,k)+Matrix(k,j)\\Big)-Matrix(j,j)}{2\\sum_{k,l=1}^{|C|}Matrix(k,l)-\\alpha \\sum_{k=1}^{|C|}Matrix(k,k)}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$MCEN_{Overall}=\\sum_{j=1}^{|C|}P_jMCEN_j$$"
]
},
{
"cell_type": "code",
"execution_count": 117,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.5189369467580801"
]
},
"execution_count": 117,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.Overall_MCEN"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 1.3
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Overall_MCC"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For more information visit [[20]](#References) [[27]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$MCC_{Overall}=\\frac{cov(X,Y)}{\\sqrt{cov(X,X)\\times cov(Y,Y)}}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$cov(X,Y)=\\sum_{i,j,k=1}^{|C|}\\Big(Matrix(i,i)Matrix(k,j)-Matrix(j,i)Matrix(i,k)\\Big)$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$cov(X,X) = \\sum_{i=1}^{|C|}\\Bigg[\\Big(\\sum_{j=1}^{|C|}Matrix(j,i)\\Big)\\Big(\\sum_{k,l=1,k\\neq i}^{|C|}Matrix(l,k)\\Big)\\Bigg]$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$cov(Y,Y) = \\sum_{i=1}^{|C|}\\Bigg[\\Big(\\sum_{j=1}^{|C|}Matrix(i,j)\\Big)\\Big(\\sum_{k,l=1,k\\neq i}^{|C|}Matrix(k,l)\\Big)\\Bigg]$$"
]
},
{
"cell_type": "code",
"execution_count": 118,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.36666666666666664"
]
},
"execution_count": 118,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.Overall_MCC"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 1.4
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### RR (Global performance index)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For more information visit [[21]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$RR=\\frac{1}{|C|}\\sum_{i,j=1}^{|C|}Matrix(i,j)$$"
]
},
{
"cell_type": "code",
"execution_count": 119,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"4.0"
]
},
"execution_count": 119,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.RR"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 1.4
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### CBA (Class balance accuracy)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For more information visit [[22]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$CBA=\\frac{\\sum_{i=1}^{|C|}\\frac{Matrix(i,i)}{Max(TOP_i,P_i)}}{|C|}$$"
]
},
{
"cell_type": "code",
"execution_count": 120,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.4777777777777778"
]
},
"execution_count": 120,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.CBA"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 1.4
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### AUNU"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"When dealing with multiclass problems, a global measure of classification performances based on the ROC approach (AUNU) has been proposed as the average of single-class measures [[23]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$AUNU=\\frac{\\sum_{i=1}^{|C|}AUC_i}{|C|}$$"
]
},
{
"cell_type": "code",
"execution_count": 121,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.6785714285714285"
]
},
"execution_count": 121,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.AUNU"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 1.4
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### AUNP"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Another option (AUNP) is that of averaging the AUCi values with weights proportional to the number of samples experimentally belonging to each class, that is, the a priori class distribution [[23]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$AUNP=\\sum_{i=1}^{|C|}\\frac{P_i}{POP}AUC_i$$"
]
},
{
"cell_type": "code",
"execution_count": 122,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.6857142857142857"
]
},
"execution_count": 122,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.AUNP"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 1.4
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### RCI (Relative classifier information)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Performance of different classifiers on the same domain can be measured by\n",
"comparing relative classifier information while classifier information (mutual information) can be used for comparison across different decision problems [[32]](#References) [[22]](#References)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$H_d=-\\sum_{i=1}^{|C|}\\Big(\\frac{\\sum_{l=1}^{|C|}Matrix(i,l)}{\\sum_{h,k=1}^{|C|}Matrix(h,k)}log_2\\frac{\\sum_{l=1}^{|C|}Matrix(i,l)}{\\sum_{h,k=1}^{|C|}Matrix(h,k)}\\Big)=Entropy_{Reference}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$H_o=\\sum_{j=1}^{|C|}\\Big(\\frac{\\sum_{k=1}^{|C|}Matrix(k,j)}{\\sum_{h,l=0}^{|C|}Matrix(h,l)}H_{oj}\\Big)=Entropy_{Conditional}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$H_{oj}=-\\sum_{i=1}^{|C|}\\Big(\\frac{Matrix(i,j)}{\\sum_{k=1}^{|C|}Matrix(k,j)}log_2\\frac{Matrix(i,j)}{\\sum_{k=1}^{|C|}Matrix(k,j)}\\Big)$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$RCI=\\frac{H_d-H_o}{H_d}=\\frac{MI}{Entropy_{Reference}}$$"
]
},
{
"cell_type": "code",
"execution_count": 123,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.3533932006492363"
]
},
"execution_count": 123,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.RCI"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 1.5
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Print"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Full"
]
},
{
"cell_type": "code",
"execution_count": 124,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Predict L1 L2 L3 \n",
"Actual\n",
"L1 3 0 2 \n",
"\n",
"L2 0 1 1 \n",
"\n",
"L3 0 2 3 \n",
"\n",
"\n",
"\n",
"\n",
"\n",
"Overall Statistics : \n",
"\n",
"95% CI (0.30439,0.86228)\n",
"AUNP 0.68571\n",
"AUNU 0.67857\n",
"Bennett S 0.375\n",
"CBA 0.47778\n",
"Chi-Squared 6.6\n",
"Chi-Squared DF 4\n",
"Conditional Entropy 0.97579\n",
"Cramer V 0.5244\n",
"Cross Entropy 1.58333\n",
"Gwet AC1 0.38931\n",
"Hamming Loss 0.41667\n",
"Joint Entropy 2.45915\n",
"KL Divergence 0.09998\n",
"Kappa 0.35484\n",
"Kappa 95% CI (-0.07708,0.78675)\n",
"Kappa No Prevalence 0.16667\n",
"Kappa Standard Error 0.22036\n",
"Kappa Unbiased 0.34426\n",
"Lambda A 0.42857\n",
"Lambda B 0.16667\n",
"Mutual Information 0.52421\n",
"NIR 0.41667\n",
"Overall ACC 0.58333\n",
"Overall CEN 0.46381\n",
"Overall J (1.225,0.40833)\n",
"Overall MCC 0.36667\n",
"Overall MCEN 0.51894\n",
"Overall RACC 0.35417\n",
"Overall RACCU 0.36458\n",
"P-Value 0.18926\n",
"PPV Macro 0.61111\n",
"PPV Micro 0.58333\n",
"Phi-Squared 0.55\n",
"RCI 0.35339\n",
"RR 4.0\n",
"Reference Entropy 1.48336\n",
"Response Entropy 1.5\n",
"SOA1(Landis & Koch) Fair\n",
"SOA2(Fleiss) Poor\n",
"SOA3(Altman) Fair\n",
"SOA4(Cicchetti) Poor\n",
"Scott PI 0.34426\n",
"Standard Error 0.14232\n",
"TPR Macro 0.56667\n",
"TPR Micro 0.58333\n",
"Zero-one Loss 5\n",
"\n",
"Class Statistics :\n",
"\n",
"Classes L1 L2 L3 \n",
"ACC(Accuracy) 0.83333 0.75 0.58333 \n",
"AUC(Area under the roc curve) 0.8 0.65 0.58571 \n",
"AUCI(Auc value interpretation) Very Good Fair Poor \n",
"BM(Informedness or bookmaker informedness) 0.6 0.3 0.17143 \n",
"CEN(Confusion entropy) 0.25 0.49658 0.60442 \n",
"DOR(Diagnostic odds ratio) None 4.0 2.0 \n",
"DP(Discriminant power) None 0.33193 0.16597 \n",
"DPI(Discriminant power interpretation) None Poor Poor \n",
"ERR(Error rate) 0.16667 0.25 0.41667 \n",
"F0.5(F0.5 score) 0.88235 0.35714 0.51724 \n",
"F1(F1 score - harmonic mean of precision and sensitivity) 0.75 0.4 0.54545 \n",
"F2(F2 score) 0.65217 0.45455 0.57692 \n",
"FDR(False discovery rate) 0.0 0.66667 0.5 \n",
"FN(False negative/miss/type 2 error) 2 1 2 \n",
"FNR(Miss rate or false negative rate) 0.4 0.5 0.4 \n",
"FOR(False omission rate) 0.22222 0.11111 0.33333 \n",
"FP(False positive/type 1 error/false alarm) 0 2 3 \n",
"FPR(Fall-out or false positive rate) 0.0 0.2 0.42857 \n",
"G(G-measure geometric mean of precision and sensitivity) 0.7746 0.40825 0.54772 \n",
"GI(Gini index) 0.6 0.3 0.17143 \n",
"IS(Information score) 1.26303 1.0 0.26303 \n",
"J(Jaccard index) 0.6 0.25 0.375 \n",
"LS(Lift score) 2.4 2.0 1.2 \n",
"MCC(Matthews correlation coefficient) 0.68313 0.2582 0.16903 \n",
"MCEN(Modified confusion entropy) 0.26439 0.5 0.6875 \n",
"MK(Markedness) 0.77778 0.22222 0.16667 \n",
"N(Condition negative) 7 10 7 \n",
"NLR(Negative likelihood ratio) 0.4 0.625 0.7 \n",
"NPV(Negative predictive value) 0.77778 0.88889 0.66667 \n",
"P(Condition positive or support) 5 2 5 \n",
"PLR(Positive likelihood ratio) None 2.5 1.4 \n",
"PLRI(Positive likelihood ratio interpretation) None Poor Poor \n",
"POP(Population) 12 12 12 \n",
"PPV(Precision or positive predictive value) 1.0 0.33333 0.5 \n",
"PRE(Prevalence) 0.41667 0.16667 0.41667 \n",
"RACC(Random accuracy) 0.10417 0.04167 0.20833 \n",
"RACCU(Random accuracy unbiased) 0.11111 0.0434 0.21007 \n",
"TN(True negative/correct rejection) 7 8 4 \n",
"TNR(Specificity or true negative rate) 1.0 0.8 0.57143 \n",
"TON(Test outcome negative) 9 9 6 \n",
"TOP(Test outcome positive) 3 3 6 \n",
"TP(True positive/hit) 3 1 3 \n",
"TPR(Sensitivity, recall, hit rate, or true positive rate) 0.6 0.5 0.6 \n",
"Y(Youden index) 0.6 0.3 0.17143 \n",
"dInd(Distance index) 0.4 0.53852 0.58624 \n",
"sInd(Similarity index) 0.71716 0.61921 0.58547 \n",
"\n"
]
}
],
"source": [
"print(cm)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Matrix"
]
},
{
"cell_type": "code",
"execution_count": 125,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Predict L1 L2 L3 \n",
"Actual\n",
"L1 3 0 2 \n",
"\n",
"L2 0 1 1 \n",
"\n",
"L3 0 2 3 \n",
"\n",
"\n"
]
}
],
"source": [
"cm.print_matrix()"
]
},
{
"cell_type": "code",
"execution_count": 126,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{0: {0: 3, 1: 0, 2: 2},\n",
" 1: {0: 0, 1: 1, 2: 1},\n",
" 2: {0: 0, 1: 2, 2: 3},\n",
" 'L1': {'L1': 3, 'L2': 0, 'L3': 2},\n",
" 'L2': {'L1': 0, 'L2': 1, 'L3': 1},\n",
" 'L3': {'L1': 0, 'L2': 2, 'L3': 3}}"
]
},
"execution_count": 126,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.matrix"
]
},
{
"cell_type": "code",
"execution_count": 127,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Predict L1 ~ \n",
"Actual\n",
"L1 3 2 \n",
"\n",
"~ 0 7 \n",
"\n",
"\n"
]
}
],
"source": [
"cm.print_matrix(one_vs_all=True,class_name = \"L1\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Parameters "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"1. `one_vs_all` : One-Vs-All mode flag (type : `bool`)\n",
"2. `class_name` : target class name for One-Vs-All mode (type : `any valid type`)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : `one_vs_all` option, new in version 1.4
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : `matrix()` renamed to `print_matrix()` and `matrix` return confusion matrix as `dict` in version 1.5
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Normalized matrix"
]
},
{
"cell_type": "code",
"execution_count": 128,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Predict L1 L2 L3 \n",
"Actual\n",
"L1 0.6 0.0 0.4 \n",
"\n",
"L2 0.0 0.5 0.5 \n",
"\n",
"L3 0.0 0.4 0.6 \n",
"\n",
"\n"
]
}
],
"source": [
"cm.print_normalized_matrix()"
]
},
{
"cell_type": "code",
"execution_count": 129,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{0: {0: 0.6, 1: 0.0, 2: 0.4},\n",
" 1: {0: 0.0, 1: 0.5, 2: 0.5},\n",
" 2: {0: 0.0, 1: 0.4, 2: 0.6},\n",
" 'L1': {'L1': 0.6, 'L2': 0.0, 'L3': 0.4},\n",
" 'L2': {'L1': 0.0, 'L2': 0.5, 'L3': 0.5},\n",
" 'L3': {'L1': 0.0, 'L2': 0.4, 'L3': 0.6}}"
]
},
"execution_count": 129,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.normalized_matrix"
]
},
{
"cell_type": "code",
"execution_count": 130,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Predict L1 ~ \n",
"Actual\n",
"L1 0.6 0.4 \n",
"\n",
"~ 0.0 1.0 \n",
"\n",
"\n"
]
}
],
"source": [
"cm.print_normalized_matrix(one_vs_all=True,class_name = \"L1\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Parameters "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"1. `one_vs_all` : One-Vs-All mode flag (type : `bool`)\n",
"2. `class_name` : target class name for One-Vs-All mode (type : `any valid type`)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : `one_vs_all` option, new in version 1.4
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : `normalized_matrix()` renamed to `print_normalized_matrix()` and `normalized_matrix` return normalized confusion matrix as `dict` in version 1.5
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Stat"
]
},
{
"cell_type": "code",
"execution_count": 131,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Overall Statistics : \n",
"\n",
"95% CI (0.30439,0.86228)\n",
"AUNP 0.68571\n",
"AUNU 0.67857\n",
"Bennett S 0.375\n",
"CBA 0.47778\n",
"Chi-Squared 6.6\n",
"Chi-Squared DF 4\n",
"Conditional Entropy 0.97579\n",
"Cramer V 0.5244\n",
"Cross Entropy 1.58333\n",
"Gwet AC1 0.38931\n",
"Hamming Loss 0.41667\n",
"Joint Entropy 2.45915\n",
"KL Divergence 0.09998\n",
"Kappa 0.35484\n",
"Kappa 95% CI (-0.07708,0.78675)\n",
"Kappa No Prevalence 0.16667\n",
"Kappa Standard Error 0.22036\n",
"Kappa Unbiased 0.34426\n",
"Lambda A 0.42857\n",
"Lambda B 0.16667\n",
"Mutual Information 0.52421\n",
"NIR 0.41667\n",
"Overall ACC 0.58333\n",
"Overall CEN 0.46381\n",
"Overall J (1.225,0.40833)\n",
"Overall MCC 0.36667\n",
"Overall MCEN 0.51894\n",
"Overall RACC 0.35417\n",
"Overall RACCU 0.36458\n",
"P-Value 0.18926\n",
"PPV Macro 0.61111\n",
"PPV Micro 0.58333\n",
"Phi-Squared 0.55\n",
"RCI 0.35339\n",
"RR 4.0\n",
"Reference Entropy 1.48336\n",
"Response Entropy 1.5\n",
"SOA1(Landis & Koch) Fair\n",
"SOA2(Fleiss) Poor\n",
"SOA3(Altman) Fair\n",
"SOA4(Cicchetti) Poor\n",
"Scott PI 0.34426\n",
"Standard Error 0.14232\n",
"TPR Macro 0.56667\n",
"TPR Micro 0.58333\n",
"Zero-one Loss 5\n",
"\n",
"Class Statistics :\n",
"\n",
"Classes L1 L2 L3 \n",
"ACC(Accuracy) 0.83333 0.75 0.58333 \n",
"AUC(Area under the roc curve) 0.8 0.65 0.58571 \n",
"AUCI(Auc value interpretation) Very Good Fair Poor \n",
"BM(Informedness or bookmaker informedness) 0.6 0.3 0.17143 \n",
"CEN(Confusion entropy) 0.25 0.49658 0.60442 \n",
"DOR(Diagnostic odds ratio) None 4.0 2.0 \n",
"DP(Discriminant power) None 0.33193 0.16597 \n",
"DPI(Discriminant power interpretation) None Poor Poor \n",
"ERR(Error rate) 0.16667 0.25 0.41667 \n",
"F0.5(F0.5 score) 0.88235 0.35714 0.51724 \n",
"F1(F1 score - harmonic mean of precision and sensitivity) 0.75 0.4 0.54545 \n",
"F2(F2 score) 0.65217 0.45455 0.57692 \n",
"FDR(False discovery rate) 0.0 0.66667 0.5 \n",
"FN(False negative/miss/type 2 error) 2 1 2 \n",
"FNR(Miss rate or false negative rate) 0.4 0.5 0.4 \n",
"FOR(False omission rate) 0.22222 0.11111 0.33333 \n",
"FP(False positive/type 1 error/false alarm) 0 2 3 \n",
"FPR(Fall-out or false positive rate) 0.0 0.2 0.42857 \n",
"G(G-measure geometric mean of precision and sensitivity) 0.7746 0.40825 0.54772 \n",
"GI(Gini index) 0.6 0.3 0.17143 \n",
"IS(Information score) 1.26303 1.0 0.26303 \n",
"J(Jaccard index) 0.6 0.25 0.375 \n",
"LS(Lift score) 2.4 2.0 1.2 \n",
"MCC(Matthews correlation coefficient) 0.68313 0.2582 0.16903 \n",
"MCEN(Modified confusion entropy) 0.26439 0.5 0.6875 \n",
"MK(Markedness) 0.77778 0.22222 0.16667 \n",
"N(Condition negative) 7 10 7 \n",
"NLR(Negative likelihood ratio) 0.4 0.625 0.7 \n",
"NPV(Negative predictive value) 0.77778 0.88889 0.66667 \n",
"P(Condition positive or support) 5 2 5 \n",
"PLR(Positive likelihood ratio) None 2.5 1.4 \n",
"PLRI(Positive likelihood ratio interpretation) None Poor Poor \n",
"POP(Population) 12 12 12 \n",
"PPV(Precision or positive predictive value) 1.0 0.33333 0.5 \n",
"PRE(Prevalence) 0.41667 0.16667 0.41667 \n",
"RACC(Random accuracy) 0.10417 0.04167 0.20833 \n",
"RACCU(Random accuracy unbiased) 0.11111 0.0434 0.21007 \n",
"TN(True negative/correct rejection) 7 8 4 \n",
"TNR(Specificity or true negative rate) 1.0 0.8 0.57143 \n",
"TON(Test outcome negative) 9 9 6 \n",
"TOP(Test outcome positive) 3 3 6 \n",
"TP(True positive/hit) 3 1 3 \n",
"TPR(Sensitivity, recall, hit rate, or true positive rate) 0.6 0.5 0.6 \n",
"Y(Youden index) 0.6 0.3 0.17143 \n",
"dInd(Distance index) 0.4 0.53852 0.58624 \n",
"sInd(Similarity index) 0.71716 0.61921 0.58547 \n",
"\n"
]
}
],
"source": [
"cm.stat()"
]
},
{
"cell_type": "code",
"execution_count": 132,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Overall Statistics : \n",
"\n",
"Kappa 0.35484\n",
"\n",
"Class Statistics :\n",
"\n",
"Classes L1 L2 L3 \n",
"ACC(Accuracy) 0.83333 0.75 0.58333 \n",
"AUC(Area under the roc curve) 0.8 0.65 0.58571 \n",
"TPR(Sensitivity, recall, hit rate, or true positive rate) 0.6 0.5 0.6 \n",
"\n"
]
}
],
"source": [
"cm.stat(overall_param=[\"Kappa\"],class_param=[\"ACC\",\"AUC\",\"TPR\"])"
]
},
{
"cell_type": "code",
"execution_count": 133,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Overall Statistics : \n",
"\n",
"Kappa 0.35484\n",
"\n",
"Class Statistics :\n",
"\n",
"Classes L1 L3 \n",
"ACC(Accuracy) 0.83333 0.58333 \n",
"AUC(Area under the roc curve) 0.8 0.58571 \n",
"TPR(Sensitivity, recall, hit rate, or true positive rate) 0.6 0.6 \n",
"\n"
]
}
],
"source": [
"cm.stat(overall_param=[\"Kappa\"],class_param=[\"ACC\",\"AUC\",\"TPR\"],class_name=[\"L1\",\"L3\"])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Parameters "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"1. `overall_param` : overall statistics names for print (type : `list`)\n",
"2. `class_param` : class statistics names for print (type : `list`)\n",
"3. `class_name` : class names for print (sub set of classes) (type : `list`)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : `cm.params()` in prev versions (0.2 >)
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : `overall_param` & `class_param` , new in version 1.6
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : `class_name` , new in version 1.7
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Save"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### .pycm file"
]
},
{
"cell_type": "code",
"execution_count": 134,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Message': 'D:\\\\For Asus Laptop\\\\projects\\\\pycm\\\\Document\\\\cm1.pycm',\n",
" 'Status': True}"
]
},
"execution_count": 134,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.save_stat(\"cm1\")"
]
},
{
"cell_type": "code",
"execution_count": 135,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Message': 'D:\\\\For Asus Laptop\\\\projects\\\\pycm\\\\Document\\\\cm1_filtered.pycm',\n",
" 'Status': True}"
]
},
"execution_count": 135,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.save_stat(\"cm1_filtered\",overall_param=[\"Kappa\"],class_param=[\"ACC\",\"AUC\",\"TPR\"])"
]
},
{
"cell_type": "code",
"execution_count": 136,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Message': 'D:\\\\For Asus Laptop\\\\projects\\\\pycm\\\\Document\\\\cm1_filtered2.pycm',\n",
" 'Status': True}"
]
},
"execution_count": 136,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.save_stat(\"cm1_filtered2\",overall_param=[\"Kappa\"],class_param=[\"ACC\",\"AUC\",\"TPR\"],class_name=[\"L1\"])"
]
},
{
"cell_type": "code",
"execution_count": 137,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Message': \"[Errno 2] No such file or directory: 'cm1asdasd/.pycm'\",\n",
" 'Status': False}"
]
},
"execution_count": 137,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.save_stat(\"cm1asdasd/\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Parameters "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"1. `name` : output file name (type : `str`)\n",
"2. `address` : flag for address return (type : `bool`)\n",
"3. `overall_param` : overall statistics names for save (type : `list`)\n",
"4. `class_param` : class statistics names for save (type : `list`)\n",
"5. `class_name` : class names for print (sub set of classes) (type : `list`)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.4
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : `overall_param` & `class_param` , new in version 1.6
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : `class_name` , new in version 1.7
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### HTML"
]
},
{
"cell_type": "code",
"execution_count": 138,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Message': 'D:\\\\For Asus Laptop\\\\projects\\\\pycm\\\\Document\\\\cm1.html',\n",
" 'Status': True}"
]
},
"execution_count": 138,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.save_html(\"cm1\")"
]
},
{
"cell_type": "code",
"execution_count": 139,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Message': 'D:\\\\For Asus Laptop\\\\projects\\\\pycm\\\\Document\\\\cm1_filtered.html',\n",
" 'Status': True}"
]
},
"execution_count": 139,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.save_html(\"cm1_filtered\",overall_param=[\"Kappa\"],class_param=[\"ACC\",\"AUC\",\"TPR\"])"
]
},
{
"cell_type": "code",
"execution_count": 140,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Message': 'D:\\\\For Asus Laptop\\\\projects\\\\pycm\\\\Document\\\\cm1_filtered2.html',\n",
" 'Status': True}"
]
},
"execution_count": 140,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.save_html(\"cm1_filtered2\",overall_param=[\"Kappa\"],class_param=[\"ACC\",\"AUC\",\"TPR\"],class_name=[\"L1\"])"
]
},
{
"cell_type": "code",
"execution_count": 141,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Message': 'D:\\\\For Asus Laptop\\\\projects\\\\pycm\\\\Document\\\\cm1_colored.html',\n",
" 'Status': True}"
]
},
"execution_count": 141,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.save_html(\"cm1_colored\",color=(255, 204, 255))"
]
},
{
"cell_type": "code",
"execution_count": 142,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Message': \"[Errno 2] No such file or directory: 'cm1asdasd/.html'\",\n",
" 'Status': False}"
]
},
"execution_count": 142,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.save_html(\"cm1asdasd/\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Parameters "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"1. `name` : output file name (type : `str`)\n",
"2. `address` : flag for address return (type : `bool`)\n",
"3. `overall_param` : overall statistics names for save (type : `list`)\n",
"4. `class_param` : class statistics names for save (type : `list`)\n",
"5. `class_name` : class names for print (sub set of classes) (type : `list`)\n",
"6. `color` : matrix color (R,G,B) (type : `tuple`)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.5
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : `overall_param` & `class_param` , new in version 1.6
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : `class_name` , new in version 1.7
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : `color`, new in version 1.8
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### CSV"
]
},
{
"cell_type": "code",
"execution_count": 143,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Message': 'D:\\\\For Asus Laptop\\\\projects\\\\pycm\\\\Document\\\\cm1.csv',\n",
" 'Status': True}"
]
},
"execution_count": 143,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.save_csv(\"cm1\")"
]
},
{
"cell_type": "code",
"execution_count": 144,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Message': 'D:\\\\For Asus Laptop\\\\projects\\\\pycm\\\\Document\\\\cm1_filtered.csv',\n",
" 'Status': True}"
]
},
"execution_count": 144,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.save_csv(\"cm1_filtered\",class_param=[\"ACC\",\"AUC\",\"TPR\"])"
]
},
{
"cell_type": "code",
"execution_count": 145,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Message': 'D:\\\\For Asus Laptop\\\\projects\\\\pycm\\\\Document\\\\cm1_filtered2.csv',\n",
" 'Status': True}"
]
},
"execution_count": 145,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.save_csv(\"cm1_filtered2\",class_param=[\"ACC\",\"AUC\",\"TPR\"],class_name=[\"L1\"])"
]
},
{
"cell_type": "code",
"execution_count": 146,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Message': \"[Errno 2] No such file or directory: 'cm1asdasd/.csv'\",\n",
" 'Status': False}"
]
},
"execution_count": 146,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.save_csv(\"cm1asdasd/\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Parameters "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"1. `name` : output file name (type : `str`)\n",
"2. `address` : flag for address return (type : `bool`)\n",
"4. `class_param` : class statistics names for save (type : `list`)\n",
"5. `class_name` : class names for print (sub set of classes) (type : `list`)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.6
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : `class_param` , new in version 1.6
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : `class_name` , new in version 1.7
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### OBJ"
]
},
{
"cell_type": "code",
"execution_count": 147,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Message': 'D:\\\\For Asus Laptop\\\\projects\\\\pycm\\\\Document\\\\cm1.obj',\n",
" 'Status': True}"
]
},
"execution_count": 147,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.save_obj(\"cm1\")"
]
},
{
"cell_type": "code",
"execution_count": 148,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Message': \"[Errno 2] No such file or directory: 'cm1asdasd/.obj'\",\n",
" 'Status': False}"
]
},
"execution_count": 148,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cm.save_obj(\"cm1asdasd/\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Parameters "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"1. `name` : output file name (type : `str`)\n",
"2. `address` : flag for address return (type : `bool`)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : new in version 0.9.5
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Input errors"
]
},
{
"cell_type": "code",
"execution_count": 149,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The type of input vectors is assumed to be a list or a NumPy array\n"
]
}
],
"source": [
"try:\n",
" cm2=ConfusionMatrix(y_actu, 2)\n",
"except pycmVectorError as e:\n",
" print(str(e))"
]
},
{
"cell_type": "code",
"execution_count": 150,
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Input vectors must have same length\n"
]
}
],
"source": [
"try:\n",
" cm3=ConfusionMatrix(y_actu, [1,2,3])\n",
"except pycmVectorError as e:\n",
" print(str(e))"
]
},
{
"cell_type": "code",
"execution_count": 151,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Input vectors are empty\n"
]
}
],
"source": [
"try:\n",
" cm_4 = ConfusionMatrix([], [])\n",
"except pycmVectorError as e:\n",
" print(str(e))"
]
},
{
"cell_type": "code",
"execution_count": 152,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Input vectors must have same length\n"
]
}
],
"source": [
"try:\n",
" cm_5 = ConfusionMatrix([1,1,1,], [1,1,1,1])\n",
"except pycmVectorError as e:\n",
" print(str(e))"
]
},
{
"cell_type": "code",
"execution_count": 153,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Input confusion matrix format error\n"
]
}
],
"source": [
"try:\n",
" cm3=ConfusionMatrix(matrix={})\n",
"except pycmMatrixError as e:\n",
" print(str(e))"
]
},
{
"cell_type": "code",
"execution_count": 154,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Type of the input matrix classes is assumed be the same\n"
]
}
],
"source": [
"try:\n",
" cm_4=ConfusionMatrix(matrix={1:{1:2,\"1\":2},\"1\":{1:2,\"1\":3}})\n",
"except pycmMatrixError as e:\n",
" print(str(e))"
]
},
{
"cell_type": "code",
"execution_count": 155,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Number of the classes is lower than 2\n"
]
}
],
"source": [
"try:\n",
" cm_5=ConfusionMatrix(matrix={1:{1:2}})\n",
"except pycmVectorError as e:\n",
" print(str(e))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" - Notice : updated in version 0.8
\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"### Example-1 (Comparison of three different classifiers)\t\n",
"\n",
"- [Jupyter Notebook](https://nbviewer.jupyter.org/github/sepandhaghighi/pycm/blob/master/Document/Example1.ipynb)\n",
"- [HTML](http://www.pycm.ir/doc/Example1.html)\n",
"\n",
"### Example-2 (How to plot via matplotlib)\n",
"\n",
"- [Jupyter Notebook](https://nbviewer.jupyter.org/github/sepandhaghighi/pycm/blob/master/Document/Example2.ipynb)\n",
"- [HTML](http://www.pycm.ir/doc/Example2.html)\n",
"\n",
"### Example-3 (Activation threshold)\n",
"\n",
"- [Jupyter Notebook](https://nbviewer.jupyter.org/github/sepandhaghighi/pycm/blob/master/Document/Example3.ipynb)\n",
"- [HTML](http://www.pycm.ir/doc/Example3.html)\n",
"\n",
"### Example-4 (File)\n",
"\n",
"- [Jupyter Notebook](https://nbviewer.jupyter.org/github/sepandhaghighi/pycm/blob/master/Document/Example4.ipynb)\n",
"- [HTML](http://www.pycm.ir/doc/Example4.html)\n",
"\n",
"### Example-5 (Sample weights)\n",
"\n",
"- [Jupyter Notebook](https://nbviewer.jupyter.org/github/sepandhaghighi/pycm/blob/master/Document/Example5.ipynb)\n",
"- [HTML](http://www.pycm.ir/doc/Example5.html)\n",
"\n",
"### Example-6 (Unbalanced data)\n",
"\n",
"- [Jupyter Notebook](https://nbviewer.jupyter.org/github/sepandhaghighi/pycm/blob/master/Document/Example6.ipynb)\n",
"- [HTML](http://www.pycm.ir/doc/Example6.html)\n",
"\n",
"### Example-7 (How to plot via seaborn+pandas)\n",
"\n",
"- [Jupyter Notebook](https://nbviewer.jupyter.org/github/sepandhaghighi/pycm/blob/master/Document/Example7.ipynb)\n",
"- [HTML](http://www.pycm.ir/doc/Example7.html)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## References"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"1- J. R. Landis, G. G. Koch, “The measurement of observer agreement for categorical data. Biometrics,” in International Biometric Society, pp. 159–174, 1977.
\n",
"\n",
"2- D. M. W. Powers, “Evaluation: from precision, recall and f-measure to roc, informedness, markedness & correlation,” in Journal of Machine Learning Technologies, pp.37-63, 2011.
\n",
"\n",
"\n",
"3- C. Sammut, G. Webb, “Encyclopedia of Machine Learning” in Springer, 2011.
\n",
"\n",
"4- J. L. Fleiss, “Measuring nominal scale agreement among many raters,” in Psychological Bulletin, pp. 378-382.
\n",
"\n",
"5- D.G. Altman, “Practical Statistics for Medical Research,” in Chapman and Hall, 1990.
\n",
"\n",
"6- K. L. Gwet, “Computing inter-rater reliability and its variance in the presence of high agreement,” in The British Journal of Mathematical and Statistical Psychology, pp. 29–48, 2008.”
\n",
"\n",
"7- W. A. Scott, “Reliability of content analysis: The case of nominal scaling,” in Public Opinion Quarterly, pp. 321–325, 1955.
\n",
"\n",
"8- E. M. Bennett, R. Alpert, and A. C. Goldstein, “Communication through limited response questioning,” in The Public Opinion Quarterly, pp. 303–308, 1954.
\n",
"\n",
"9- D. V. Cicchetti, \"Guidelines, criteria, and rules of thumb for evaluating normed and standardized assessment instruments in psychology,\" in Psychological Assessment, pp. 284–290, 1994.
\n",
"\n",
"10- R.B. Davies, \"Algorithm AS155: The Distributions of a Linear Combination of χ2 Random Variables,\" in Journal of the Royal Statistical Society, pp. 323–333, 1980.
\n",
"\n",
"11- S. Kullback, R. A. Leibler \"On information and sufficiency,\" in Annals of Mathematical Statistics, pp. 79–86, 1951.
\n",
"\n",
"12- L. A. Goodman, W. H. Kruskal, \"Measures of Association for Cross Classifications, IV: Simplification of Asymptotic Variances,\" in Journal of the American Statistical Association, pp. 415–421, 1972.
\n",
"\n",
"13- L. A. Goodman, W. H. Kruskal, \"Measures of Association for Cross Classifications III: Approximate Sampling Theory,\" in Journal of the American Statistical Association, pp. 310–364, 1963.
\n",
"\n",
"14- T. Byrt, J. Bishop and J. B. Carlin, “Bias, prevalence, and kappa,” in Journal of Clinical Epidemiology pp. 423-429, 1993.
\n",
"\n",
"15- M. Shepperd, D. Bowes, and T. Hall, “Researcher Bias: The Use of Machine Learning in Software Defect Prediction,” in IEEE Transactions on Software Engineering, pp. 603-616, 2014.
\n",
"\n",
"16- X. Deng, Q. Liu, Y. Deng, and S. Mahadevan, “An improved method to construct basic probability assignment based on the confusion matrix for classification problem, ” in Information Sciences, pp.250-261, 2016.
\n",
"\n",
"17- Wei, J.-M., Yuan, X.-Y., Hu, Q.-H., Wang, S.-Q.: A novel measure for evaluating\n",
"classifiers. Expert Systems with Applications, Vol 37, 3799–3809 (2010).
\n",
"\n",
"18- Kononenko I. and Bratko I. Information-based evaluation criterion for classifier’s\n",
"performance. Machine Learning, 6:67–80, 1991.
\n",
"\n",
"19- Delgado R., Núñez-González J.D. (2019) Enhancing Confusion Entropy as Measure for Evaluating Classifiers. In: Graña M. et al. (eds) International Joint Conference SOCO’18-CISIS’18-ICEUTE’18. SOCO’18-CISIS’18-ICEUTE’18 2018. Advances in Intelligent Systems and Computing, vol 771. Springer, Cham
\n",
"\n",
"20- Gorodkin J (2004) Comparing two K-category assignments by a K-category\n",
"correlation coefficient. Computational Biology and Chemistry 28: 367–374
\n",
"\n",
"21- Freitas C.O.A., de Carvalho J.M., Oliveira J., Aires S.B.K., Sabourin R. (2007) Confusion Matrix Disagreement for Multiple Classifiers. In: Rueda L., Mery D., Kittler J. (eds) Progress in Pattern Recognition, Image Analysis and Applications. CIARP 2007. Lecture Notes in Computer Science, vol 4756. Springer, Berlin, Heidelberg
\n",
"\n",
"22- Branco P., Torgo L., Ribeiro R.P. (2017) Relevance-Based Evaluation Metrics for Multi-class Imbalanced Domains. In: Kim J., Shim K., Cao L., Lee JG., Lin X., Moon YS. (eds) Advances in Knowledge Discovery and Data Mining. PAKDD 2017. Lecture Notes in Computer Science, vol 10234. Springer, Cham
\n",
"\n",
"23- Ballabio, D., Grisoni, F. and Todeschini, R. (2018). Multivariate comparison of classification performance measures. Chemometrics and Intelligent Laboratory Systems, 174, pp.33-44.
\n",
"\n",
"24- Cohen, Jacob. 1960. A coefficient of agreement for nominal scales. Educational And Psychological Measurement 20:37-46
\n",
"\n",
"25- Siegel, Sidney and N. John Castellan, Jr. 1988. Nonparametric Statistics for the Behavioral Sciences. McGraw Hill.
\n",
"\n",
"26- Cramér, Harald. 1946. Mathematical Methods of Statistics. Princeton: Princeton University Press, page 282 (Chapter 21. The two-dimensional case)
\n",
"\n",
"27- Matthews, B. W. (1975). \"Comparison of the predicted and observed secondary structure of T4 phage lysozyme\". Biochimica et Biophysica Acta (BBA) - Protein Structure. 405 (2): 442–451.
\n",
"\n",
"28- Swets JA. (1973). \"The relative operating characteristic in Psychology\". Science. 182 (14116): 990–1000.
\n",
"\n",
"29- Jaccard, Paul (1901), \"Étude comparative de la distribution florale dans une portion des Alpes et des Jura\", Bulletin de la Société Vaudoise des Sciences Naturelles, 37: 547–579.
\n",
"\n",
"30- Thomas M. Cover and Joy A. Thomas. 2006. Elements of Information Theory (Wiley Series in Telecommunications and Signal Processing). Wiley-Interscience, New York, NY, USA.
\n",
"\n",
"31- Keeping, E.S. (1962) Introduction to Statistical Inference. D. Van Nostrand, Princeton, NJ.
\n",
"\n",
"32- Sindhwani V, Bhattacharge P, Rakshit S (2001) Information theoretic feature\n",
"crediting in multiclass Support Vector Machines. In: Grossman R, Kumar V,\n",
"editors, Proceedings First SIAM International Conference on Data Mining,\n",
"ICDM01. SIAM, pp. 1–18.
\n",
"\n",
"33- Bekkar, Mohamed & Djema, Hassiba & Alitouche, T.A.. (2013). Evaluation measures for models assessment over imbalanced data sets. Journal of Information Engineering and Applications. 3. 27-38.
\n",
"\n",
"34- Youden W, (1950),« Index for rating diagnostic tests »; Cancer, 3 :32–35
\n",
"\n",
"35- S. Brin, R. Motwani, J. D. Ullman, and S. Tsur. Dynamic itemset counting and implication rules for market basket data. In Proc. of the ACM SIGMOD Int'l Conf. on Management of Data (ACM SIGMOD '97), pages 265-276, 1997.
\n",
"\n",
"36- Raschka, Sebastian (2018) MLxtend: Providing machine learning and data science utilities and extensions to Python's scientific computing stack. J Open Source Softw 3(24).
"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}