Skip to main content

Confidence-Correctness Matrix

Project description

Confidence-Correctness Matrix

The package provides the methods for building the confidence-correctness matrix, for its visualization in a horizontal bar chart and for computing different probabilistic metrics. The confidence-correctness matrix is an innovative method to understand the behavior of a prediction model for classification problems.

This matrix provides information about the degree of confidence that the classifier has in its own predictions, indicating whether it is robust and reliable or uncertain and doubtful. This method has two variants: the class-independent confidence-correctness matrix and the class-specific confidence-correctness matrix depending on the kind of analysis required.

By analyzing the data provided by them, our goal is to improve the reliability and explainability of prediction models and to provide users with a clearer understanding of why a model has a high or low confidence about its predictions.

Installation

Serendipity Matrix can be installed from PyPI

pip install confidence_correctness_matrix

Or you can clone the repository and run:

pip install .

Sample usage

import numpy as np
from sklearn.naive_bayes import GaussianNB
from ucimlrepo import fetch_ucirepo

iris  = fetch_ucirepo(id=53) 
X, y = iris.data.features, iris.data.targets.squeeze()

model = GaussianNB().fit(X, y)
y_score = model.predict_proba(X)

prob_conf_matrix = prob_confusion_matrix(y, y_score, labels=classes)
prob_acc = prob_accuracy_score(y, y_score)
prob_f1 = prob_f1_score(y, y_score, average="weighted")

H, L = confidence_matrices(y, y_score)
lambda_H, lambda_L = confidence_weights(y, y_score)

ci_confCorrM = confidence_correctness_matrix(y, y_score, class_specific=False)
cd_confCorrM = confidence_correctness_matrix(y, y_score, class_specific=True)

plot_confidence(y, y_score)

Result sample

Probabilistic confusion matrix

Iris-setosa Iris-versicolor Iris-virginica
50 0 0
0 46.06 3.94
0 3.93 46.07

High-confidence matrix (H)

Iris-setosa Iris-versicolor Iris-virginica
50 0 0
0 45.374 2.314
0 2.644 45.715

lambda_H = 0.97365

Low-confidence matrix (L)

Iris-setosa Iris-versicolor Iris-virginica
0 0 0
0 0.686 1.626
0 1.285 0.356

lambda_L = 0.02635

Confident-Correctness matrix

High-confidence Low-confidence
Prob. mass on True class 0.941 0.007
Prob. mass on Other classes 0.033 0.019

Class-specific Confidence-Correctness Matrix horizontal bar chart

Class-specific Confidence-Correctness matrix

For more detailed examples, please refer to the following link.

Citation

The methodology is described in detail in:

[1] J. S. Aguilar-Ruiz and A. García Conde, “”

Documentation

Full documentation is available here.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

confidence_correctness_matrix-1.0.1.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file confidence_correctness_matrix-1.0.1.tar.gz.

File metadata

File hashes

Hashes for confidence_correctness_matrix-1.0.1.tar.gz
Algorithm Hash digest
SHA256 22fba8593a9d7149cd9627a5ffca678ff80980546927fb0289515e772c601d1d
MD5 5c4e5590f9427cf785d0fab5b2d87dba
BLAKE2b-256 6f568ebb11a73e55aa137ce48e7092d22deb7e13afd9435d8fd402c062265aca

See more details on using hashes here.

File details

Details for the file confidence_correctness_matrix-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for confidence_correctness_matrix-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 98bec66c53908db1032cc5a1615ca82912f97f11bb3f7d274ef39bf1b9ac90d9
MD5 d8a01a847d40a5e135968a62072e42d0
BLAKE2b-256 76ba52dae76c8abdbfe6e0a0f227c113f56d500b0c90466ecd411531e3e074d4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page