Registry / ai-ml / zfit
library0.28.0pypypi✓ verified 21d ago

zfit is a modern, scalable Python library for statistical model fitting, primarily designed for High Energy Physics but applicable broadly. It leverages TensorFlow (and optionally JAX) for accelerated computations on CPUs and GPUs, offering a user-friendly API for defining, manipulating, and fitting complex probability density functions. The current version is 0.28.0, with a release cadence of typically a few months between minor versions, often driven by new feature development and backend compatibility updates.

pip install zfit[tf]
INSTALL
IMPORT
SIG · ZFIT
Z
zfit
ai-mlpythonv0.28.0
Install
51.5s avg
Import
18982ms
Disk
2519MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.28.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.915 runs
build_error
glibc
py 3.103.915 runs
installs and imports cleanly · install 51.5s · import 18.982s · 2457.6MB
2519MB installed
● package 2519MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Parameter
from zfit import Parameter
Space
from zfit import Space
pdf
import zfit.pdf as zpdf
Commonly aliased for brevity, e.g., zfit.pdf.Gauss
data
import zfit.data as zdata
Commonly aliased for brevity, e.g., zfit.data.Data
loss
import zfit.loss as zloss
Commonly aliased for brevity, e.g., zfit.loss.UnbinnedNLL
minimize
import zfit.minimize as zmin
Commonly aliased for brevity, e.g., zfit.minimize.Minuit

This quickstart demonstrates defining parameters, an observable space, creating a Gaussian Probability Density Function (PDF), generating data from it, setting up an unbinned negative log-likelihood loss, and performing a fit using the Minuit minimizer. It's a fundamental workflow for zfit.

import zfit from zfit import z # Define parameters mu = zfit.Parameter('mu', 0.0, -1.0, 1.0) sigma = zfit.Parameter('sigma', 1.0, 0.1, 10.0) # Define the observable space obs = zfit.Space('x', limits=(-5, 5)) # Create a Gaussian PDF gauss = zfit.pdf.Gauss(mu=mu, sigma=sigma, obs=obs) # Generate some data data = gauss.sample(n=1000) # Create a likelihood loss function nll = zfit.loss.UnbinnedNLL(model=gauss, data=data) # Create a minimizer minimizer = zfit.minimize.Minuit() # Perform the fit result = minimizer.minimize(nll) # Print the fit results print(result.params)
Debug
Known issues
breakingThe `effsize` weight correction parameter was renamed to `sumw2` in certain contexts for asymptotic uncertainty calculations.
fix
Update calls using `effsize` to `sumw2`.
affects: 0.26.0 and higher
gotchaThe default padding for KDE (Kernel Density Estimation) functions, specifically `KDE1DimExact`, changed from `False` to `0.1`.
fix
If exact reproduction of pre-0.27.0 KDE behavior at boundaries is critical, explicitly set `padding=False` when creating KDEs.
affects: 0.27.0 and higher
gotchazfit frequently updates its TensorFlow and TensorFlow-Probability backend requirements. Major version bumps of these dependencies can cause environment conflicts or necessitate upgrades.
fix
Always check the `requires_python` and the specific backend requirements in the release notes or `pyproject.toml`. Use `pip install zfit[tf]` or `zfit[jax]` to ensure compatible backend versions are installed, or manage your environment carefully if pinning specific backend versions.
affects: All versions, specifically 0.24.0 (TF ~2.18, TFP ~0.25) and subsequent releases.
breakingAs of v0.27.0, zfit explicitly requires Python 3.10 or newer. Support for Python 3.13 was added in v0.28.0.
fix
Ensure your Python environment is at least 3.10. For the latest features and compatibility, use Python 3.10-3.13.
affects: 0.27.0 and higher
Upgrade
Version history
0.28.0latest on PyPI · released Nov 18, 2025
Audit
Dependencies
tensorflowoptionalPrimary backend for numerical computation (CPU and GPU). Included by default or with `[tf]` extra.
tensorflow-probabilityoptionalUsed in conjunction with TensorFlow for advanced statistical operations.
jaxoptionalAlternative backend for numerical computation, enabled with `[jax]` extra.
arvizoptionalIntegrated for Bayesian inference diagnostics and visualization in v0.28.0+.
Agent activity
49 hits · last 30 days
node
40
OpenAI (training)
1
Resources
zfit — pip install zfit · libregistry