Skip to main content

Tremetrics

PyPi

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.

Metadata

Release files for tremetrics 0.2.0

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

Source distribution (sdist)

Source distribution for tremetrics 0.2.0
File Size Uploaded
tremetrics-0.2.0.tar.gz 5.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tremetrics 0.2.0
File Interpreter ABI Platform
tremetrics-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.3 kB

Release files / tremetrics-0.2.0.tar.gz

Download URL tremetrics-0.2.0.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
1b9b6b10036e1e0eba731921c62b4eb1d85475dae887a82a7556532958b6ef6b
BLAKE2b-256 checksum
How to use checksums
66fd6f4b13a0ae69429d7a4dcd665d13ae18631d508d95513478fc8a8e125cfb
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / tremetrics-0.2.0-py3-none-any.whl

Download URL tremetrics-0.2.0-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba0435fe57c51bbf3e51c02eba767dc72c1790ea12fca64bad618bc940ab1a6e
BLAKE2b-256 checksum
How to use checksums
76114af08f5a86451b868d90b09d5cbc18dae9757af622ac1a15ef45282ffaab
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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