Confidence-Correctness Matrix
Project description
Confidence-Correctness Matrix
The package provides the methods to provide the confidence-correctness matrix and for its visualization in a horizontal bar chart. 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
# Loads the dataset
iris = fetch_ucirepo(id=53)
X, y = iris.data.features, iris.data.targets.squeeze()
# Training and predict
model = GaussianNB().fit(X, y)
result = model.predict_proba(X)
# Calculates the probabilistic confusion matrix and the probabilistic accuracy
prob_conf_matrix = prob_confusion_matrix(y, result)
prob_acc = prob_accuracy(y, result)
print(np.round(prob_conf_matrix,3))
print(f"Acc*:{np.round(prob_acc,5)}\n")
# Calculates the certainty and uncertainty confusion matrix, their probabilistic accuracy and their lambda values
V, U = certainty_matrix(y, result)
lambda_V, lambda_U = certainty_weights(y, result)
print(np.round(V,3))
print(f"Acc_V*:{np.round(V_acc,5)}, lambda_V:{np.round(lambda_V,5)}\n")
print(np.round(U,3))
print(f"Acc_U*:{np.round(U_acc,5)}, lambda_U:{np.round(lambda_U,5)}")
Result sample
Probabilistic confusion matrix
| Iris-setosa | Iris-versicolor | Iris-virginica |
|---|---|---|
| 50 | 0 | 0 |
| 0 | 46.06 | 3.94 |
| 0 | 3.93 | 46.07 |
Acc* = 0.94754
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
Citation
The methodology is described in detail in:
[1] J. S. Aguilar-Ruiz and A. García Conde, “”
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file confidence_correctness_matrix-1.0.0.tar.gz.
File metadata
- Download URL: confidence_correctness_matrix-1.0.0.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9893a9af113699c5141766a05a41db6b9bf000ae1a109726e5568012553de9f2
|
|
| MD5 |
0bc28ff3cecdfdff325147a4e61e0a5c
|
|
| BLAKE2b-256 |
c4b9b7b8d7f264c96f57c26a653d7236fe43a6162bef98a58639eb8adcfef9fb
|
File details
Details for the file confidence_correctness_matrix-1.0.0-py3-none-any.whl.
File metadata
- Download URL: confidence_correctness_matrix-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37432a9d5f25d8683bb1ee04afbba8023a872dd1aae2cb76c6831efd29655aa1
|
|
| MD5 |
88f02bf8fb66e42baee320df508a2af9
|
|
| BLAKE2b-256 |
9bec4d0a84d1d655c825ffed29b0678d1bcfc65e7113ba43522ffb293e09381b
|