Skip to main content

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.

Metadata

Release files for confidence-correctness-matrix 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for confidence-correctness-matrix 1.0.1
File Size Uploaded Provenance Actions
confidence_correctness_matrix-1.0.1.tar.gz 10.0 kB Without provenance Details for confidence_correctness_matrix-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for confidence-correctness-matrix 1.0.1
File Interpreter ABI Platform Actions
confidence_correctness_matrix-1.0.1-py3-none-any.whl Python 3 none any Details for confidence_correctness_matrix-1.0.1-py3-none-any.whl

Total release size: 19.3 kB

Release files / confidence_correctness_matrix-1.0.1.tar.gz

Download URL confidence_correctness_matrix-1.0.1.tar.gz
Size 10.0 kB
Tags Source
SHA-256 checksum
How to use checksums
22fba8593a9d7149cd9627a5ffca678ff80980546927fb0289515e772c601d1d
BLAKE2b-256 checksum
How to use checksums
6f568ebb11a73e55aa137ce48e7092d22deb7e13afd9435d8fd402c062265aca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.1

Release files / confidence_correctness_matrix-1.0.1-py3-none-any.whl

Download URL confidence_correctness_matrix-1.0.1-py3-none-any.whl
Size 9.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
98bec66c53908db1032cc5a1615ca82912f97f11bb3f7d274ef39bf1b9ac90d9
BLAKE2b-256 checksum
How to use checksums
76ba52dae76c8abdbfe6e0a0f227c113f56d500b0c90466ecd411531e3e074d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.1

Security for confidence-correctness-matrix 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page