Skip to main content

📏 Flax Metrics Flax Metrics PyPI version Documentation Status

Flax NXX implementation of common metrics. See the documentation for a comprehensive list of available metrics.

>>> from flax_metrics import Precision, Recall
>>> from jax import numpy as jnp

>>> labels = jnp.asarray([ 0,  0,  0,  1,  1,  1])
>>> logits = jnp.asarray([-1, -2,  2,  1, -1, -2])

>>> metric = Recall()
>>> metric.update(labels=labels, logits=logits)
Recall(...)
>>> metric.compute()
Array(0.333..., dtype=float32)

Masking

jax.jit requires re-compilation for arrays of different shapes, making evaluation on subsets challenging—we cannot index arrays with a mask. Flax Metrics supports masking through the keyword-only argument mask. The example below illustrates that passing mask is equivalent to indexing the input with a binary mask.

>>> mask = jnp.asarray([True, True, True, True, False, True])
>>> metric = Recall()
>>> metric.update(labels=labels, logits=logits, mask=mask)
Recall(...)
>>> metric.compute()
Array(0.5, dtype=float32)

>>> metric.reset()
Recall(...)
>>> metric.update(labels=labels[mask], logits=logits[mask])
Recall(...)
>>> metric.compute()
Array(0.5, dtype=float32)

Chaining

Metric creation, updates, and computation can be combined into one expression by chaining operations.

>>> Recall().update(labels=labels, logits=logits).compute()
Array(0.333..., dtype=float32)

Metadata

Release files for flax-metrics 0.4.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 flax-metrics 0.4.0
File Size Uploaded
flax_metrics-0.4.0.tar.gz 16.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flax-metrics 0.4.0
File Interpreter ABI Platform
flax_metrics-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 31.2 kB

Release files / flax_metrics-0.4.0.tar.gz

Download URL flax_metrics-0.4.0.tar.gz
Size 16.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7532ed538bc01c82392d3e024bedddac1a9077b8f3ea78301080cf08dba3bf06
BLAKE2b-256 checksum
How to use checksums
d7203e79ac9632f0ab783f46f2579c377fae8820b8922949bca3201985ca99fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 17, 2026.

Transparency log

Release files / flax_metrics-0.4.0-py3-none-any.whl

Download URL flax_metrics-0.4.0-py3-none-any.whl
Size 14.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2113ef30bd769e16f7e01cbcb53e6f829b2db9a393e817a586a61c383d4082da
BLAKE2b-256 checksum
How to use checksums
1394f1d92a3b0b8523b845993ba3a342cae241c171697d8e2ff4587ec617d5d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 17, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.0

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

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