Tremendous Metrics
Project description
Tremetrics
Tremendous Metrics.
Installation
You can install Tremetrics from PyPi using pip.
pip install tremetrics
Usage
ConfusionMatrix
from tremetrics import ConfusionMatrix
y_true, y_pred = ... # Generate predictions
cm = ConfusionMatrix.from_pred(y_true, y_pred) # Create a new confusion matrix object
print(cm) # Print the confusion matrix
array_for_further_use = cm.array # Get the matrix as a numpy array
print(cm.tp, cm.fn, cm.fp, cm.tn) # Get the individual quadrant values
print(cm.get_latex_table(multirow=True)) # Get the matrix as code for a Latex table
print(cm.recall_score(average='micro')) # Call any sklearn.metrics function using the data in the matrix
ROCCurve
from tremetrics import ROCCurve
import matplotlib.pyplot as plt
y_true, y_pred_prob = ... # Generate prediction probabilities
curve = ROCCurve.from_pred_prob(y_true, y_pred_prob) # Create a new roc curve object
print(curve.roc_auc) # Print the area under the roc curve
curve.plot() # plot the roc curve
plt.show() # show the curve plot
# generating convex roc curves
curve = ROCCurve.from_pred_prob(y_true, y_pred_prob, convex=True) # Create a convex roc curve object
print(curve.roc_auc) # Print the area under the roc curve
curve.plot() # plot the roc curve
plt.show() # show the curve plot
# static methods meant as sklearn drop-in replacement
fpr, tpr, thresholds = ROCCurve.roc_curve(y_true, y_pred_prob)
fpr, tpr, thresholds = ROCCurve.convex_roc_curve(y_true, y_pred_prob)
# exploiting pyplot state to draw both standard and convex roc curves
curve = ROCCurve.from_pred_prob(y_true, y_pred_prob)
curve.plot()
curve = ROCCurve.from_pred_prob(y_true, y_pred_prob, convex=True)
curve.plot()
plt.show()
Why should I make my ROC curve convex?
A nice explanation is given in this paper.
In essence, ROC points below the convex hull are suboptimal classifiers, which can be outperformed by interpolating nearby classifiers that are on the convex hull. Practically, this interpolation is a random choice (i.e. without considering input data or predictions made) between such better classifiers, where the probability of picking one over the other determines the position on the line segment between their ROC points.
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
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 tremetrics-0.2.0.tar.gz.
File metadata
- Download URL: tremetrics-0.2.0.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b9b6b10036e1e0eba731921c62b4eb1d85475dae887a82a7556532958b6ef6b
|
|
| MD5 |
9446fa1efd07f9d4d923355c8c052d0e
|
|
| BLAKE2b-256 |
66fd6f4b13a0ae69429d7a4dcd665d13ae18631d508d95513478fc8a8e125cfb
|
File details
Details for the file tremetrics-0.2.0-py3-none-any.whl.
File metadata
- Download URL: tremetrics-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba0435fe57c51bbf3e51c02eba767dc72c1790ea12fca64bad618bc940ab1a6e
|
|
| MD5 |
52744725b3e9b3ffd2b469d5ae8f7d15
|
|
| BLAKE2b-256 |
76114af08f5a86451b868d90b09d5cbc18dae9757af622ac1a15ef45282ffaab
|