Recent Releases of zfit
zfit - Import bugfix
What's Changed
Features
- fix imports by @jonas-eschle in https://github.com/zfit/zfit/pull/653
Full Changelog: https://github.com/zfit/zfit/compare/0.27.0...0.27.1
- Python
Published by jonas-eschle 8 months ago
zfit - Major speedups and fixes for binned PDF
0.2.7 (10 Jul 2025)
Major Features and Improvements
- significantly improved performance, especially when using a GPU for certain fits.
Breaking changes
- default padding of KDE switched to 0.1 instead of False. This should only improve KDEs at the boundary but technically changes the behavior
Bug fixes and small changes
- Fix
KDE1DimExactandExponentialTFPincorrectly handling label parameter: both classes now properly store and return thelabelattribute separately fromname - Fix AttributeError when calling
freeze()method twice on FitResult - Add
PositivePDFfunctor andto_positive()method toBasePDFfor ensuring PDF output values are always positive with a minimum epsilon (default is 1e-100). This also handles NaN values by replacing them with epsilon. - Add clipping functionality to parameter setting methods:
set_valueandset_valuesnow accept aclipparameter that clips values to parameter limits instead of raising errors when values are outside bounds - Remove conditional numeric checks in favor of unconditional assertions: some internal checks that were only performed when
run.numeric_checks=Trueare now always performed. To re-enable the old conditional behavior, setzfit.run.numeric_checks = Truefor debugging numerical issues - Clean up code by removing commented debug code, unused variables, and duplicate imports
- Simplify assertion handling in numerical integration to properly filter out None operations
- Add
FitResult.xattribute to access the best fit values of the parameters directly. - Add
OptimizeResultMixintoFitResultproviding fullscipy.optimize.OptimizeResultcompatibility with attributes likesuccess,fun,x,jac,hess,hess_inv,nfev,njev,nhev,nit, andmaxcv Fix critical bugs in binned PDF extended normalization methods:
_auto_ext_pdfincorrectly usedext_normalization()instead ofnormalization(), causing extended PDF values to be multiplied by yield squared instead of yield_auto_ext_log_pdfincorrectly usedznp.log(ext_normalization(norm))instead oflog_normalization(norm)
add
to_cachedto unbinned PDFs, returning a cached PDF. These do not support analytic gradients, an error will be raised if attempted.
- Python
Published by jonas-eschle 8 months ago
zfit - Weighted uncertainties
Major Features and Improvements
- asymptotic uncertainties for weighted fits have been optimized and fixed, working for yields and constraints correctly
Breaking changes
- renamed
effsizeweight corretion to actualsumw2
Bug fixes and small changes
- Allow BinnedSamplerData to be instantiated from a histogram and fix variance handling if not given.
- Enhance the precision of binned loss functions
- make adaptive bandwidth default in KDE
- Python
Published by jonas-eschle 9 months ago
zfit - New weight corrections
Major Features and Improvements
- New weighted corrections for Hesse uncertainty calculation. The corrections are now selectable by specifying
weighcorr=..., allowing for (currently) three values:"asymptotic"(current, and default),False(no correction), and"effsize"(new correction). effsize scales the uncertainties by the "effective size" of the dataset, a significantly faster, yet not asymptotically correct method. Useful for a quick estimate of the uncertainties.
Bug fixes and small changes
- allow the usage of
ZfitDataobjects (binned and unbinned version respectively) inupdate_datamethod of sampler objectszfit.data.SamplerDataandzfit.data.BinnedSamplerData(for example, the objects that are returned bycreate_sampler) - add an attribute
num_entriesto theDataobject that returns the number of entries in the data and an attributesamplesizereflecting the sum of the weights, deprecating the ambiguousneventsattribute. The former can be used to define the array shape, the latter matters in statistical tests. - The EDM calculation was optimized; additionally,it would error if the matrix was singular. The behavior is now changed to return 999'999 in this case. Could be reconsidered in the future to provide a "best fit" instead.
- A simple bug in the LevenbergMarquardt minimizer was fixed that would error due to a wrong return shape of an internal result.
- Python
Published by jonas-eschle 12 months ago
zfit - Relax TF and TFP version
Relax TF requirement to >= 2.16 (instead of 2.18) and equivalent TensorFlow-Probability to >= 0.24 (instead of 0.25)
- Python
Published by jonas-eschle about 1 year ago
zfit - Minor fix in minuit
Fixes the case if no covariance is available from minuit
- Python
Published by jonas-eschle about 1 year ago
zfit - Upgrade to new TF version
0.24.0 (10 Nov. 2024)
Upgrade to new TF version
Requirement changes
- TensorFlow ~2.18
- TensorFlow Probability ~0.25
- Python
Published by jonas-eschle about 1 year ago
zfit - Minor fixes
- remain order of some internal parameters to increase full reproducibility
- minuit minimizer could have no covariance albeit being advertised, lead to error in some cases
- Python
Published by jonas-eschle about 1 year ago
zfit - New minimizers and a better arbitrary function loss
Major Features and Improvements
- Minimizers can use the new
SimpleLoss.from_anymethod that allows other libraries to hook into the minimization. For example, using zfit-physics, minimizers can directly minimize RooFitRooNllVar(as created bycreateNLLdescribedhere <https://root.cern.ch/doc/master/classRooAbsPdf.html#a24b1afec4fd149e08967eac4285800de>_ - Added the well performing
LevenbergMarquardtminimizer, a new implementation of the Levenberg-Marquardt algorithm. - New BFGS minimizer implementation of Scipy,
ScipyBFGS. - Reactivate a few minimizers:
ScipyDogleg,ScipyNCG,ScipyCOBYLAandScipyNewtonCG
Breaking changes
- removed multiple, old deprecated methods and arguments
Deprecations
- use
stepsizeinstead ofstep_sizein thezfit.Parameterconstructor
Bug fixes and small changes
- add possibility to not jit by using
force_eagerintf.functionor raise az.DoNotCompileerror SimpleLosscan now be added together with another SimpleLossget_paramssupports anautogradargument to filter parameters that do not support automatic differentiation. An object with parameters can advertise, which parameters are differentiable (withautograd_params); by default, all parameters are assumed to be differentiable, the same effect asTrue. If autograd is performed on parameters that do not support it, an error is raised.- Use
kanahsum for larger likelihoods by default to improve numerical stability - Using the same
zfit.Parameterfor multiple arguments (i.e. to specify a common width in a PDF with a different width for left and right) could cause a crash due to some internal caching. This is now fixed. - Minimizers have now been renamed without the trailing
V1. The old names are still available but will be removed in the future.
- Python
Published by jonas-eschle over 1 year ago
zfit - Pydantic upgrade to V2
0.22.0 22 Aug 2024
Bug fixes and small changes
- change the truncated PDF with a yield to reflect a dynamic change in shape
Requirement changes
- Upgrade from Pydantic V1 to V2
- Python
Published by jonas-eschle over 1 year ago
zfit - Small fixes
Bug fixes and small changes
fullargument for binned NLLs was not working properly and return a partially optimized loss value.- jit compile all methods of the loss (gradient, hessian) to avoid recompilation every time. This can possibly speed up different minimizers significantly.
- Python
Published by jonas-eschle over 1 year ago
zfit - Minor fixes and the JohnsonSU
0.21.0 (2 Jul 2024)
Major Features and Improvements
- add
JohnsonSUPDF, the Johnson SU distribution.
Bug fixes and small changes
- increase reliability of
zfit.dill.dumpandzfit.dill.dumpswith an additionalverifyargument that reloads the dumped object to verify it was correctly dumped and retries if it wasn't. - fix missing imported namespaces
- fixed a memory leak when creating multiple parameters
- add data loaders to
zfit.datanamespace
Thanks
- Davide Lancierini for finding and helping to debug the dill dumping issue
- James Herd for finding and reproducing the memory leak
- Python
Published by jonas-eschle over 1 year ago
zfit - Minor bugfixes
Bug fixes and small changes
- enhanced loss: simple loss can take a gradient and hesse function and the default base loss provides fallbacks that work correctly between
value_gradientandgradient. This maybe matters if you've implemented a custom loss and should fix any issues with it. - multiprocessing would get stuck due to an
upstream bug in TensorFlow <https://github.com/tensorflow/tensorflow/issues/66115>_. Working around it by disabling an unused piece of code.
Thanks
- acampoverde for finding the bug in the multiprocessing
- Python
Published by jonas-eschle almost 2 years ago
zfit - Minor bugfix
0.20.2 (16 Apr 2024)
Two small bugfixes - fix backwards incompatible change of sampler - detect if a RegularBinning has been transformed, raise error.
- Python
Published by jonas-eschle almost 2 years ago
zfit - Minor fixes for stability
For a guide to the 0.20 changes, see here
0.20.1 (14 Apr 2024)
Major Features and Improvements
- fix dumping and add convenience wrapper
zfit.dillto dump and load objects with dill (a more powerful pickle). This way, any zfit object can be saved and loaded, such asFitResultthat contains all other important objects to recreate the fit. - improved performance for numerical gradient calculation, fixing also a minor numerical issue.
Bug fixes and small changes
- runing binned fits without a graph could deadlock, fixed.
- Python
Published by jonas-eschle almost 2 years ago
zfit - Usability overhaul and a ton of new PDFs
0.20.0 (12 Apr 2024)
Complete overhaul of zfit with a focus on usability and a variety of new pdfs!
Major Features and Improvements
- Parameter behavior has changed, multiple parameters with the same name can now coexist!
The
NameAlreadyTakenErrorhas been successfully removed (yay!). The new behavior only enforces that names and matching parameters within a function/PDF/loss are unique, as otherwise inconsistent expectations appear (for the full discussion on this, seehere <https://github.com/zfit/zfit/discussions/342>_). Spaceand limits have a complete overhaul in front of them, in short, these overcomplicated objects get simplified and the limits become more usable, in terms of dimensions. The full discussion and changes can befound here <https://github.com/zfit/zfit/discussions/533>_ .- add an unbinned
Samplerto the public namespace underzfit.data.Sampler: this object is returned in thecreate_samplermethod and allows to resample from a function without recreating the compiled function, i.e. loss. It has an additional methodupdate_datato update the data without recompiling the loss and can be created from a sample only. Useful to have a custom dataset in toys. - allow to use pandas DataFrame as input where zfit Data objects are expected
- Methods of PDFs and loss functions that depend on parameters take now the value of a parameter explicitly as arguments, as a mapping of str (parameter name) to value.
- Python 3.12 support
- add
GeneralizedCBPDF which is similar to theDoubleCBPDF but with different standard deviations for the left and right side. - Added functor for PDF caching
CachedPDF:pdf,integratePDF methods can be cacheable now - add
faddeeva_humlicekfunction under thezfit.z.numpynamespace. This is an implementation of the Faddeeva function, combining Humlicek's rational approximations according to Humlicek (JQSRT, 1979) and Humlicek (JQSRT, 1982). - add
Voigtprofile PDF which is a convolution of a Gaussian and a Cauchy distribution. - add
TruncatedPDFthat allows to truncate in one or multiple ranges (replaces "MultipleLimits" and "MultiSpace") - add
LogNormalPDF, a log-normal distribution, which is a normal distribution of the logarithm of the variable. - add
ChiSquaredPDF, the standard chi2 distribution, taken fromtensorflow-probability implementation <https://www.tensorflow.org/probability/api_docs/python/tfp/distributions/Chi2>_. - add
StudentTPDF, the standard Student's t distribution, taken fromtensorflow-probability implementation <https://www.tensorflow.org/probability/api_docs/python/tfp/distributions/StudentT>_. - add
GaussExpTailandGeneralizedGaussExpTailPDFs, which are a Gaussian with an exponential tail on one side and a Gaussian with different sigmas on each side and different exponential tails on each side respectively. - add
QGaussPDF, a distribution that arises from the maximization of the Tsallis entropy under appropriate constraints, seehere <https://en.wikipedia.org/wiki/Q-Gaussian_distribution>_. - add `
BifurGaussPDF, a Gaussian distribution with different sigmas on each side of the mean. - add
BernsteinPDF, which is a PDF defined by a linear combination of Bernstein polynomials given their coefficients. - add
GammaPDF, the Gamma distribution. Datahas now awith_weightsmethod that returns a new data object with different weights and an improvedwith_obsthat allows to set obs with new limits. These replace theset_weightsandset_data_rangemethods for a more functional approach.- add
labelto different objects (PDF, Data, etc.) that allows to give a human-readable name to the object. This is used in the plotting and can be used to identify objects. Notably, Parameters have a label that can be arbitrary.Spacehas one label for each observable if the space is a product of spaces.Space.labelis a string and only possible for one-dimensional spaces, whileSpace.labelsis a list of strings and can be used for any, one- or multi-dimensional spaces. - add
zfit.data.concat(...)to concatenate multiple data objects into one along the index or along the observables. Similar topd.concat. - PDFs now have a
to_truncatedmethod that allows to create a truncated version of the PDF, possibly with different and multiple limits. This allows to easily create a PDF with disjoint limits. DataandPDFthat takeobsin the initialization can now also take binned observables, i.e. azfit.Spacewithbinning=...and will return a binned version of the object (zfit.data.BinnedDataorzfit.pdf.BinnedFromUnbinned, where the latter is a generic wrapper). This is equivalent of callingto_binnedon the objects)zfit.Datacan be instantiated directly with most data types, such as numpy arrays, pandas DataFrames etc insead of using the dedicated constructorsfrom_numpy,from_pandasetc. The constructors may still provide additional functionality, but overall, the switch should be seamless.
Breaking changes
This release contains multiple "breaking changes", however, the vast majority if not all apply only for edge cases and undocummented functions.
- a few arguments are now keyword-only arguments. This can break existing code if the arguments were given as positional arguments. Just use the appropriate keyword arguments instead.
(Example: instead of using
zfit.Space(obs, limits)usezfit.Space(obs, limits=limits)). This was introduced to make the API more robust and to avoid errors due to the order of arguments, with a few new ways of creating objects. Data.from_root: deprecated argumentsbranchesandbranch_aliaseshave been removed. Useobsandobs_aliasesinstead.NameAlreadyTakenErrorwas removed, see above for the new behavior. This should not have an effect on any existing code except if you relied on the error being thrown.- Data objects had an intrinsic, TensorFlow V1 legacy behavior: they were actually cut when the data was retrieved. This is now changed and the data is cut when it is created. This should not have any impact on existing code and just improve runtime and memory usage.
- Partial integration used to use some broadcasting tricks that could potentially fail. It uses now a dynamic while loop that could be slower but works for arbitrary PDFs. This should not have any impact on existing code and just improve stability (but technically, the data given to the PDF if doing partial integration is now "different", in the sense that it's now not different anymore from any other call)
- if a
tf.Variablewas used to store the number of sampled values in a sampler, it was possible to change the value of that variable to change the number of samples drawn. This is now not possible anymore and the number of samples should be given as an argumentnto theresamplemethod, as was possible since a long time. create_samplerhas a breaking change forfixed_params: when the argument was set to False, any change in the parameters would be reflected when resampling. This highly statebased behavior was confusing and is now removed. The argument is now calledparamsand behaves as expected: the sampler will remember the parameters at the time of creation, possibly updated withparamsand will not change anymore. To sample from a different set of parameters, the params have to be passed to theresamplemethod explicitly.- the default names for
hesseanderrorshave now been changed tohesseanderrors, respectively. This was deprecated since a while and both names were available for backwards compatibility. The old names are now removed. If you get an error,minuit_hessseorminuit_minosnot found, just replace it withhesseanderrors.
Deprecations
result.fminfullis deprecated and will be removed in the future. Useresult.fmininstead.Data.set_data_rangeis deprecated and will be removed in the future. Usewith_rangeinstead.Spacehas many deprecated methods, such asrect_limitsand quite a few more. The full discussion can be foundhere <https://github.com/zfit/zfit/discussions/533>_.fixed_paramsincreate_sampleris deprecated and will be removed in the future. Useparamsinstead.fixed_paramsattribute of theSampleris deprecated and will be removed in the future. Useparamsinstead.uncertaintiesinGaussianConstraintis deprecated and will be removed in the future. Use either explicitlysigmaorcov.- the
ComposedParameterandComplexParameterargumentvalue_fnis deprecated in favor of the new argumentfunc. Identical behavior. zfit.run(...)is deprecated and will be removed in the future. Simply remove it should work in most cases. (if an explicity numpy, not just array-like, cast is needed, usenp.asarray(...). But usually this is not needed). This function is an old relic from the past TensorFlow 1.x,tf.Sessiontimes and is not needed anymore. We all remember well these days :)
Bug fixes and small changes
- complete overhaul of partial integration that used some broadcasting tricks that could potentially fail. It uses now a dynamic while loop that could be slower but works for arbitrary PDFs and no problems should be encountered anymore.
FitResultcan now be used as a context manager, which will automatically set the values of the parameters to the best fit values and reset them to the original values after the context is left. A new methodupdate_paramsallows to update the parameters with the best fit values explicitly.result.fminnow returns the full likelihood, whileresult.fminoptreturns the optimized likelihood with potential constant subtraction. The latter is mostly used by the minimizer and other libraries. This behavior is consistent with the behavior of other methods in the loss that return by default the full, unoptimized value.- serialization only allowed for one specific limit (space) of each obs. Multiple, independent limits can now be serialized.
- Increased numerical stability: this was compromised due to some involuntary float32 conversions in TF. This has been fixed.
- arguments
sigmaandcovare now used inGaussianConstraint, both mutually exclusive, to ensure the intent is clear. - improved hashing and precompilation in loss, works now safely also with samplers.
- seed setting is by default completely randomized. This is a change from the previous behavior where the seed was set to a more deterministic value. Use seeds only for reproducibility and not for real randomness, as some strange correlations between seeds have been observed. To guarantee full randomness, just call
zfit.run.set_seed()without arguments. zfit.run.set_seednow returns the seed that was set. This is useful for reproducibility.
Experimental
- a simple
plotmechanism has been added withpdf.plot.plotpdfto plot PDFs. This is simple and fully interacts with matplotlib, allowing to plot quickly in a more interactive way. zfit.run.experimental_disable_param_update: this is an experimental feature that allows to disable the parameter update in a fit as is currently done wheneverminimizeis called. In conjunction with the new methodupdate_params(), this can be used asresult = minimizer.minimize(...).update_params()to keep the same behavior as currently. Also, the context manager ofFitResultcan be used to achieve the same behavior in a context manager (with minimizer.minimize(...) as result: ...) also works.
Requirement changes
- upgrade to TensorFlow 2.16 and TensorFlow Probability 0.24
Thanks
- huge thanks to @iasonkrommydas for the addition of various PDFs and to welcome him on board as a new contributor!
- @anjabeck for the addition of the
ChiSquaredPDF
- Python
Published by jonas-eschle almost 2 years ago
zfit - Add missing dep
Hotfix release to add missing deps attrs
- Python
Published by jonas-eschle almost 2 years ago
zfit - Bug fixes in randomness and improved caching
0.18.1 (22 Feb 2024)
Major Features and Improvements
- reduced the number of graph caching reset, resulting in significant speedups in some cases
Bug fixes and small changes
- use random generated seeds for numpy and TF, as they can otherwise have unwanted correlations
Thanks
@anjabeck for the bug report and the idea to use random seeds for numpy and TF @acampoverde for reporting the caching issue
- Python
Published by jonas-eschle about 2 years ago
zfit - TF 2.15 upgrade, drop Python 3.8
Uprade to TensorFlow 2.15 (from 2.12/2.13 previously) and TensorFlow-Probability 0.23 Drop Python 3.8 support
- Python
Published by jonas-eschle about 2 years ago
zfit - Fixes in uncertainty corrections
0.17.0
Major Features and Improvements
- add correct uncertainty for unbinned, weighted fits with constraints and/or that are extended.
- allow mapping in
zfit.param.set_valuesfor values
Bug fixes and small changes
- fix issues where EDM goes negative, set to 999
- improved stability of the loss evaluation
- improved uncertainty calculation accuracy with
zfit_error
Thanks
Daniel Craik for the idea of allowing a mapping in set_values
- Python
Published by jonas-eschle about 2 years ago
zfit - 0.16.0 Minor fixes and improvements
0.16.0 (26 July 2023)
Major Features and Improvements
- add
fulloption to loss call ofvalue, which returns the unoptimized value allowing for easier statistical tests using the loss. This is the default behavior and should not break any backwards compatibility, as the "not full loss" was arbitrary. - changed the
FitResultto print both loss values, the unoptimized (full) and optimized (internal)
Bug fixes and small changes
- bandwidth preprocessing was ignored in KDE
unstack_xwith anobsas argument did return the wrong shape
Thanks
@schmitse for reporting the bug in the KDE bandwidth preprocessing @lorenzopaolucci for bringing up the absolute value of the loss in the fitresult as an issue
- Python
Published by jonas-eschle over 2 years ago
zfit - Minor fixes for binned fits
0.15.5
fix a bug in histmodifier that would not properly take into account the yield of the wrapped PDF
- Python
Published by jonas-eschle over 2 years ago
zfit - Fix missing dependency
0.15.2 (20 July 2023)
Fix missing attrs dependency
Major Features and Improvements
- add option
fullin loss to return the full, unoptimized value (currently not default), allowing for easier statistical tests using the loss
- Python
Published by jonas-eschle over 2 years ago
zfit - 0.15.0
Update to TensorFlow 2.13.x
Requirement changes
- TensorFlow upgraded to ~=2.13.0
- as TF 2.13.0 ships with the arm64 macos wheels, the requirement of
tensorflow_macosis removed
Thanks
- Iason Krommydas for helping with the macos requirements for TF
- Python
Published by jonas-eschle over 2 years ago
zfit - Pin pydantic dependency to < V2
Major Features and Improvements
- zfit broke for pydantic 2, which upgraded.
Requirement changes
- restrict pydantic to <2.0.0
- Python
Published by jonas-eschle over 2 years ago
zfit - Upgrade to Python 3.11
What's Changed
- Python 3.11 and TF 2.12 by @jonas-eschle in https://github.com/zfit/zfit/pull/462
- fix param caching by @jonas-eschle in https://github.com/zfit/zfit/pull/472
- Python
Published by jonas-eschle over 2 years ago
zfit - Minor fixes in CB and caching
0.13.2 (15. June 2023)
Bug fixes and small changes
- fix a caching problem with parameters (could cause issues with larger PDFs as params would be "remembered" wrongly)
- more helpful error message when jacobian (as used for weighted corrections) is analytically asked but fails
- make analytical gradient for CB integral work
- Python
Published by jonas-eschle over 2 years ago
zfit - Minor fix for KDE
0.13.1 (20 Apr 2023)
Bug fixes and small changes
- array bandwidth for KDE works now correctly
Requirement changes
- fixed uproot for Python 3.7 to <5
Thanks
- @schmitse for reporting and solving the bug in the KDE bandwidth with arrays
- Python
Published by jonas-eschle almost 3 years ago
zfit - Last Python 3.7 fixes
Version 0.13.0
Major Features and Improvements
last Python 3.7 version
Bug fixes and small changes
SampleDatais not used anymore, aDataobject is returned (for simple sampling). Thecreate_samplerwill still return aSamplerDataobject though as this differs fromData.
Experimental
- Added support on a best-effort for human-readable serialization of objects including an HS3-like representation, find a tutorial on serialization here . Most built-in unbinned PDFs are supported. This is still experimental and not yet fully supported. Dumping can be performed safely, loading maybe easily breaks (also between versions), so do not rely on it yet. Everything else - apart of trying to dump - should only be used for playing around and giving feedback purposes.
Requirement changes
- allow uproot 5 (remove previous restriction)
Thanks
- to Johannes Lade for the amazing work on the serialization, which made this HS3 implementation possible!
- Python
Published by jonas-eschle almost 3 years ago
zfit - Reproducibility fix
Fix some issues with setting seed globally and locally, fits should now be reproducible.
For all changes, see the changelog
Thanks to @schmitse for discovering the bug
- Python
Published by jonas-eschle almost 3 years ago
zfit - Binned and sampling fixes
Many smaller fixes that are crucial, most notably to avoid a bias in sampling.
Bug fixes and small changes
create_extendedaddedNoneto the name, removed.SimpleConstraintnow also takes a function that has an explicitparamsargument.- add
nameargument tocreate_extended. - adding binned losses would error due to the removed
fit_rangeargument. - setting a global seed made the sampler return constant values, fixed (unoptimized but correct). If you ran a fit with a global seed, you might want to rerun it.
- histogramming and limit checks failed due to a stricter Numpy check, fixed.
Thanks
- @P-H-Wagner for finding the bug in
SimpleConstraint. - Dan Johnson for finding the bug in the binned loss that would fail to sum them up.
- Hanae Tilquin for spotting the bug with TensorFlows changed behavior or random states inside a tf.function, leading to biased samples whenever a global seed was set.
- Python
Published by jonas-eschle almost 3 years ago
zfit - Reduced memory consumption and convenience functions
Major Features and Improvements
- reduce the memory footprint on (some) fits, especially repetitive (loops) ones.
Reduces the number of cached compiled functions. The cachesize can be set with
zfit.run.set_cache_size(int)and specifies the number of compiled functions that are kept in memory. The default is 10, but this can be tuned. Lower values can reduce memory usage, but potentially increase runtime.
Bug fixes and small changes
- Enable uniform binning for n-dimensional distributions with integer(s).
- Sum of histograms failed for calling the pdf method (can be indirectly), integrated over wrong axis.
- Binned PDFs expected binned spaces for limits, now unbinned limits are also allowed and automatically converted to binned limits using the PDFs binning.
- Speedup sampling of binned distributions.
- add
to_binnedandto_unbinnedmethods to PDF
Thanks
- Justin Skorupa for finding the bug in the sum of histograms and the missing automatic conversion of unbinned spaces to binned spaces.
- Python
Published by jonas-eschle over 3 years ago
zfit - Binned and mixed fits
Public release of binned fits and upgrade to Python 3.10 and TensorFlow 2.9.
While binned fits are now supported, they still lack some stability, public testing and features. Feedback is, as usual, very welcome!
Major Features and Improvements
- improved data handling in constructors
from_pandas(which allows now to have weights as columns, dataframes that are a superset of the obs) andfrom_root(obs can now be spaces and therefore cuts can be direcly applied) - add hashing of unbinned datasets with a
hashintattribute. None if no hash was possible.
Bug fixes and small changes
- SimpleLoss correctly supports both functions with implicit and explicit parameters, also if they are decorated.
- extended sampling errored for some cases of binned PDFs.
ConstantParametererrored when converted to numpy.- Simultaneous binned fits could error with different binning due to a missing sum over a dimension.
- improved stability in loss evaluation of constraints and poisson/chi2 loss.
- reduce gradient evaluation time in
errorsfor many parameters. - Speedup Parameter value assignement in fits, which is most notably when the parameter update time is comparably large to the fit evaluation time, such as is the case for binned fits with many nuisance parameters.
- fix ipyopt was not pickleable in a fitresult
- treat parameters sometimes as "stateless", possibly reducing the number of retraces and reducing the memory footprint.
Requirement changes
- nlopt and ipyopt are now optional dependencies.
- Python 3.10 added
- TensorFlow ~= 2.9.0 is now required and the corresponding TensorFlow-Probability version ~= 0.17.0
Thanks
- @YaniBion for discovering the bug in the extended sampling and testing the alpha release
- @ResStump for reporting the bug with the simultaneous binned fit
- Python
Published by jonas-eschle over 3 years ago
zfit - 0.9.0a2
Major Features and Improvements
- Save results by pickling, unpickling a frozen (
FitResult.freeze()) result and usingzfit.param.set_values(params, result)to set the values ofparams.
Deprecations
- the default name of the uncertainty methods
hesseanderrorsdepended on the method used (such as 'minuithesse', 'zfiterrors' etc.) and would be the exact method name. New names are now 'hesse' and 'errors', independent of the method used. This reflects better that the methods, while internally different, produce the same result. To update, use 'hesse' instead of 'minuithesse' or 'hessenp' and 'errors' instead of 'zfiterrors' or 'minuitminos' in order to access the uncertainties in the fitresult. Currently, the old names are still available for backwards compatibility. If a name was explicitly chosen in the error method, nothing changed.
Bug fixes and small changes
- KDE datasets are now correctly mirrored around observable space limits
- multinomial sampling would return wrong results when invoked multiple times in graph mode due to a non-dynamic shape. This is fixed and the sampling is now working as expected.
- increase precision in FitResult string representation and add that the value is rounded
Thanks
- schmitse for finding and fixing a mirroring bug in the KDEs
- Sebastian Bysiak for finding a bug in the multinomial sampling
- Python
Published by jonas-eschle almost 4 years ago
zfit - Fix DCB integral
0.8.2 (20 Sep 2021)
Bug fixes and small changes
- fixed a longstanding bug in the DoubleCB implementation of the integral.
- remove outdated deprecations
- Python
Published by jonas-eschle over 4 years ago
zfit - KDEs for large data and numerical integration
Kernel Density Estimation in 1 dimension for large data sets.
Introduction tutorial notebook
Major Features and Improvements
- allow
FitResulttofreeze(), making it pickleable. The parameters are replaced by their name, the objects such as loss and minimizer as well. - improve the numerical integration by adding a one dimensional efficient integrator, testing for the accuracy of multidimensional integrals. If there is a sharp peak, this maybe fails to integrate and the number of points has to be manually raised
- add highly performant kernel density estimation (mainly contributed by Marc Steiner)
in 1 dimension which allow
for the choice of arbitrary kernels, support
boundary mirroring of the data and allow for large (millions) of data samples:
- :class:
~zfit.pdf.KDE1DimExactfor the normal density estimation - :class:
~zfit.pdf.KDE1DimGridusing a binning - :class:
~zfit.pdf.KDE1DimFFTusing a binning and FFT - :class:
~zfit.pdf.KDE1DimISJusing a binning and an algorithm (ISJ) to solve the optimal bandwidth
- :class:
For an introduction, see either :ref:sec-kernel-density-estimation or the tutorial :ref:sec-components-model
- add windows in CI
Breaking changes
- the numerical integration improved with more sensible values for tolerance. This means however that some fits will
greatly increase the runtime. To restore the old behavior globally, do
for each instance
pdf.update_integration_options(draws_per_dim=40_000, max_draws=40_000, tol=1)This will integrate regardless of the chosen precision and it may be non-optimal. However, the precision estimate in the integrator is also not perfect and maybe overestimates the error, so that the integration by default takes longer than necessary. Feel free to play around with the parameters and report back.
Bug fixes and small changes
- Double crystallball: move a minus sign down, vectorize the integral, fix wrong output shape of pdf
- add a minimal value in the loss to avoid NaNs when taking the log of 0
- improve feedback when taking the derivative with respect to a parameter that a function does not depend on or if the function is purely Python.
- make parameters deletable, especially it works now to create parameters in a function only and no NameAlreadyTakenError will be thrown.
Requirement changes
- add TensorFlow 2.6 support (now 2.5 and 2.6 are supported)
Thanks
- Marc Steiner for contributing many new KDE methods!
- Python
Published by jonas-eschle over 4 years ago
zfit - Python 3.9 and TF 2.5 support
Major Features and Improvements
- add Python 3.9 support
- upgrade to TensorFlow 2.5
Bug fixes and small changes
- Scipy minimizers with hessian arguments use now
BFGSas default
Requirement changes
- remove Python 3.6 support
- Python
Published by jonas-eschle over 4 years ago
zfit - minor dependency fix
Update ipyopt requirement < 0.12 to allow numpy compatible with TensorFlow
- Python
Published by jonas-eschle almost 5 years ago
zfit - small fix in signature and ipyopt dependency
- fix for wrong argument in exponential PDF
- removed requirement ipyopt, can be installed with
pip install zfit[ipyopt]or by manually installingpip install ipyopt
- Python
Published by jonas-eschle almost 5 years ago
zfit - Minor bug fixes
Minor fixes
- fix loss failed for large datasets
- catch hesse failing for iminuit
- Python
Published by jonas-eschle almost 5 years ago
zfit - Minor loss fixes
Minor small fixes.
Bug fixes and small changes
- add
lossto callback signature that gives full access to the model - add
create_newmethod to losses in order to re-instantiate a loss with new models and data preserving their current (and future) options and other arguments
- Python
Published by jonas-eschle almost 5 years ago
zfit - Cleaned up minimizer
Small release to clean up the minimizers and remove non-functioning ones.
- Python
Published by jonas-eschle almost 5 years ago
zfit - New minimizers, TF2.4 and uncertainties
Added many new minimizers from different libraries, all with uncertainty estimation available.
All changes are available in the changelog
Major Features and Improvements
- upgraded to TensorFlow 2.4
Added many new minimizers. A full list can be found in :ref:
minimize_user_api.- :class:
~zfit.minimize.IpyoptV1that wraps the powerful Ipopt large scale minimization library - Scipy minimizers now have their own, dedicated wrapper for each instance such as
~zfit.minimize.ScipyLBFGSBV1, :class:~zfit.minimize.ScipyTrustKrylovV1or :class:~zfit.minimize.ScipySLSQPV1 - NLopt library wrapper that contains many algorithms for local searches such as
:class:
~zfit.minimize.NLoptLBFGSV1, :class:~zfit.minimize.NLoptTruncNewtonV1or :class:~zfit.minimize.NLoptMMAV1but also includes more global minimizers such as :class:~zfit.minimize.NLoptMLSLV1and :class:~zfit.minimize.NLoptESCHV1.
- :class:
Completely new and overhauled minimizers design, including:
- minimizers can now be used with arbitrary Python functions and an initial array independent of zfit
- a minimization can be 'continued' by passing
inittominimize - more streamlined arguments for minimizers, harmonized names and behavior.
- Adding a flexible criterion (currently EDM) that will terminate the minimization.
- Making the minimizer fully stateless.
- Moving the loss evaluation and strategy into a LossEval that simplifies the handling of printing and NaNs.
- Callbacks are added to the strategy.
Major overhaul of the
FitResult, including:- improved
zfit_error(equivalent ofMINOS) minuit_hesseandminuit_minosare now available with all minimizers as well thanks to an great improvement in iminuit.- Added an
approxhesse that returns the approximate hessian (if available, otherwise empty)
- improved
upgrade to iminuit v2 changes the way it works and also the Minuit minimizer in zfit, including a new step size heuristic. Possible problems can be caused by iminuit itself, please report in case your fits don't converge anymore.
improved
compute_errorsin speed by caching values and the reliability by making the solution unique.increased stability for large datasets with a constant subtraction in the NLL
- Python
Published by jonas-eschle almost 5 years ago
zfit - TF 2.3, weighted errors and convolutions
Upgrade to TensorFlow 2.3 and support for weighted hessian error estimation.
Added a one dimensional Convolution PDF
Major Features and Improvements
- upgrad to TensorFlow 2.3
- new Poisson PDF
Bug fixes and small changes
- print parameter inside function context works now correctly
Experimental
- Computation of the covariance matrix and hessian errors with weighted data
- Convolution PDF (FFT in 1Dim) added (experimental, feedback welcome!)
Requirement changes
- TensorFlow==2.3 (before 2.2)
- tensorflow_probability==0.11
- tensorflow-addons # spline interpolation in convolution
- Python
Published by jonas-eschle over 5 years ago
zfit - New docs and small improvements
New Docs and improvements
Major Features and Improvements
- completely new doc design
Breaking changes
- Minuit uses its own, internal gradient by default. To change this back, use
use_minuit_grad=False minimize(params=...)now filters correctly non-floating parameters.z.loghas been moved toz.math.log(following TF)
Depreceations
Bug fixes and small changes
- ncalls is not correctly using the internal heuristc or the ncalls explicitly
minimize(params=...)automatically extracts independent parameters.- fix copy issue of KDEV1 and change name to 'adaptive' (instead of 'adaptiveV1')
- change exp name of
lambda_to lam (in init) - add
set_yieldto BasePDF to allow setting the yield in place - Fix possible bug in SumPDF with extended pdfs (automatically)
Experimental
Requirement changes
- upgrade to iminuit>=1.4
- remove cloudpickle hack fix
Thanks
Johannes for the docs re-design
- Python
Published by jonas-eschle over 5 years ago
zfit - Gaussian KDE, BreitWigner and correlation
Add Kernel density estimation for 1 dimension.
Major Features and Improvements
- add correlation method to FitResult
- Gaussian (Truncated) Kernel Density Estimation in one dimension
zfit.pdf.GaussianKDE1DimV1implementation with fixed and adaptive bandwidth added as V1. This is a feature that needs to be improved and feedback is welcome - Non-relativistic Breit-Wigner PDF, called Cauchy, implementation added.
Breaking changes
- change human-readable name of
Gauss,UniformandTruncatedGaussto remove the'_tfp'at the end of the name
Bug fixes and small changes
- fix color wrong in printout of results, params
- packaging: moved to pyproject.toml and a setup.cfg mainly, development requirements can
be installed with the
devextra as (e.g.)pip install zfit[dev] - Fix shape issue in TFP distributions for partial integration
- change zfit internal algorithm (
zfit_error) to compute error/intervals from the profile likelihood, which is 2-3 times faster than previous algorithm. - add
from_minuitconstructor toFitResultallowing to create it when using directly iminuit - fix possible bias with sampling using accept-reject
Requirement changes
- pin down cloudpickle version (upstream bug with pip install) and TF, TFP versions
- Python
Published by jonas-eschle over 5 years ago
zfit - Python 3.8, TF2.2 and simpler debugging
Support for Python 3.8 with TensorFlow 2.2 version. Minor bugfixes.
Major Features and Improvements
- Python 3.8 and TF 2.2 support
- easier debugging with
set_graph_modethat can also be used temporarily with a context manager. False will make everything execute Numpy-like.
Bug fixes and small changes
- added
get_paramsto loss - fix a bug with the
fixed_paramswhen creating a sampler - improve exponential PDF stability and shift when normalized
- improve accept reject sampling to account for low statistics
Requirement changes
- TensorFlow >= 2.2
- Python
Published by jonas-eschle almost 6 years ago
zfit - Technical release
Changed dependency to be conda-forge compatible
- Python
Published by jonas-eschle almost 6 years ago
zfit - Arbitrary spaces, more stability and better function tracing.
Complete refactoring of Spaces to allow arbitrary function. New, more consistent behavior with extended PDFs. SumPDF refactoring, more explicit handling of fracs and yields. Improved graph building allowing for more fine-grained control of tracing. Stabilized minimization including a push-back for NaNs.
Major Features and Improvements
- Arbitrary limits as well as vectorization (experimental)
are now fully supported. The new
Spacehas an additional argument for a function that tests if a vector x is inside.
To test if a value is inside a space, Space.inside can be used. To filter values, Space.filter.
The limits returned are now by default numpy arrays with the shape (1, nobs). This corresponds well
to the old layout and can, using `z.unstackx(lower)be treated likeData. This has also some
consequences for the output format ofrect_area`: this is now a vector.
Due to the ambiguity of the name limits, area etc (since they do only reflect the rectangular case)
method with leading rect_* have been added (rect_limits, rect_area etc.) and are encouraged to be used.
Extending a PDF is more straightforward and removes any "magic". The philosophy is: a PDF can be extended or not. But it does not change the fundamental behavior of functions.
SumPDF has been refactored and behaves now as follows: Giving in pdfs (extended or not or mixed) and fracs (either length pdfs or one less) will create a non-extended SumPDF using the fracs. The fact that the pdfs are maybe extended is ignored. This will lead to highly consistent behavior. If the number of fracs given equals the number of pdfs, it is up to the user (currently) to take care of the normalization. Only if all pdfs are extended and no fracs are given, the sumpdf will be using the yields as normalized fracs and be extended.
Improved graph building and
z.function- the
z.functioncan now, as withtf.function, be used either as a decorator without arguments or as a decorator with arguments. They are the same as intf.function, except of a few additional ones. zfit.run.set_modeallows to set the policy for whether everything is run in eager mode (graph=False), everything in graph, or most of it (graph=True) or an optimized variant, doing graph building only with losses but not just models (e.g.pdfwon't trigger a graph build,loss.value()will) withgraph='auto'.- The graph cache can be cleaned manually using
zfit.run.clear_graph_cache()in order to prevent slowness in repeated tasks.
- the
Switch for numerical gradients has been added as well in
zfit.run.set_mode(autograd=True/False).Resetting to the default can be done with
zfit.run.set_mode_default()Improved stability of minimizer by adding penalty (currently in
Minuit) as default. To have a better behavior with toys (e.g. never fail on NaNs but return an invalidFitResult), use theDefaultToyStrategyinzfit.mnimize.Exceptions are now publicly available in
zfit.exceptionAdded nice printout for
FitResultandFitResult.params.get_paramsis now more meaningful, returning by default all independent parameters of the pdf, including yields. Arguments (floating,is_yield) allow for more fine-grained control.
Breaking changes
- Multiple limits are now handled by a MultiSpace class. Each Space has only "one limit"
and no complicated layout has to be remembered. If you want to have a space that is
defined in disconnected regions, use the
+operator or functionallyzfit.dimension.add_spaces
To extract limits from multiple limits, MultiSpace and Space are both iterables, returning
the containing spaces respectively itself (for the Space case).
- SumPDF changed in the behavior. Read above in the Major Features and Improvement.
- Integrals of extended PDFs are not extended anymore, but ext_integrate now returns the
integral multiplied by the yield.
Depreceations
ComposedParametertakes nowparamsinstead ofdependentsas argument, it acts now as the arguments to thevalue_fn. To stay future compatible, create e.g.def value_fn(p1, pa2)and usingparams = ['param1, param2],value_fnwill then be called asvalue_fn(param1, parma2).value_fnwithout arguments will probably break in the future.FitResult.errorhas been renamed toerrorsto better reflect that multiple errors, the lower and upper are returned.
Bug fixes and small changes
- fix a (nasty, rounding) bug in sampling with multiple limits
- fix bug in numerical calculation
- fix bug in SimplePDF
- fix wrong caching signature may lead to graph not being rebuild
- add
zfit.param.set_valuesmethod that allows to set the values of multiple parameters with one command. Can, as theset_valuemethod be used with a context manager. - wrong size of weights when applying cuts in a dataset
with_coordsdid drop axes/obs- Fix function not traced when an error was raised during first trace
- MultipleLimits support for analytic integrals
zfit.param.set_values(..)now also can use aFitResultasvaluesargument to set the values from.
Experimental
- added a new error method, 'zfiterror' that is equivalent to 'minuitminos', but not fully stable. It can be used with other minimizers as well, not only Minuit.
Requirement changes
- remove the outdated typing module
- add tableformatter, colored, colorama for colored table printout
Thanks
- Johannes Lade for code review and discussions.
- Hans Dembinski for useful inputs to the uncertainties.
- Python
Published by jonas-eschle almost 6 years ago
zfit - Small fixes
Fix a bug in np_hesse, last release before 0.5.0
Has some known bugs though, especially in the caching and performance.
- Python
Published by jonas-eschle almost 6 years ago
zfit - Constraints, fitting convergence
Constraints have been reworked and measures to improve the fitting convergence have been added.
Major Features and Improvements
- Refactoring of the Constraints, dividing into
ProbabilityConstraintthat can be sampled from and more general constraints (e.g. for parameter boundaries) that can not be sampled from. - Doc improvements in the constraints.
- Add
hesseerror method ('hesse_np') available to all minimizers (not just Minuit).
Behavioral changes
- Changed default step size to an adaptive scheme, a fraction (1e-4) of the range between the lower and upper limits.
Bug fixes and small changes
- Add
use_minuit_gradoption to Minuit optimizer to use the internal gradient, often for more stable fits - added experimental flag
zfit.experimental_loss_penalty_nan, which adds a penalty to the loss in case the value is nan. Can help with the optimisation. Feedback welcome!
- Python
Published by jonas-eschle almost 6 years ago
zfit - Release for TF 2.1
0.4.1 (12.1.20)
Release to keep up with TensorFlow 2.1
Major Features and Improvements
- Fixed the comparison in caching the graph (implementation detail) that leads to an error.
- Python
Published by jonas-eschle about 6 years ago
zfit - TensorFlow 2.x switch
0.4.0 (7.1.2020)
This release switched to TensorFlow 2.0 eager mode. In case this breaks things for you and you need urgently a running version, install a version < 0.4.1. It is highly recommended to upgrade and make the small changes required.
Please read the upgrade guide <docs/project/upgrade_guide.rst> on a more detailed explanation how to upgrade.
TensorFlow 2.0 is eager executing and uses functions to abstract the performance critical parts away.
Major Features and Improvements
- Dependents (currently, and probably also in the future) need more manual tracking. This has mostly
an effect on CompositeParameters and SimpleLoss, which now require to specify the dependents by giving
the objects it depends (indirectly) on. For example, it is sufficient to give a
ComplexParameter(which itself is not independent but has dependents) to aSimpleLossas dependents (assuming the loss function depends on it). ComposedParameterdoes no longer allow to give a Tensor but requires a function that, when evaluated, returns the value. It depends on thedependentsthat are now required.- Added numerical differentiation, which allows now to wrap any function with
z.py_function(zfit.z). This can be switched on withzfit.settings.options['numerical_grad'] = True - Added gradient and hessian calculation options to the loss. Support numerical calculation as well.
- Add caching system for graph to prevent recursive graph building
changed backend name to
zand can be used aszfit.zor imported from it. Added:functiondecorator that can be used to trace a function. Respects dependencies of inputs and automatically caches/invalidates the graph and recreates.py_function, same astf.py_function, but checks and may extends in the futuremathmodule that contains autodiff and numerical differentiation methods, both working with tensors.
Behavioral changes
- EDM goal of the minuit minimizer has been reduced by a factor of 10 to 10E-3 in agreement with the goal in RooFits Minuit minimizer. This can be varied by specifying the tolerance.
- known issue: the
projection_pdfhas troubles with the newest TF version and may not work properly (runs out of memory)
Bug fixes and small changes
Requirement changes
- added numdifftools (for numerical differentiation)
- Python
Published by jonas-eschle about 6 years ago
zfit - Last TF 1 compatible release
This is a legacy release to add some fixes, next release is TF 2 eager mode only release.
Major Features and Improvements
- mostly TF 2.0 compatibility in graph mode, tests against 1.x and 2.x
Behavioral changes
Bug fixes and small changes
get_depententsreturns now an OrderedSet- errordef is now a (hidden) attribute and can be changed
- fix bug in polynomials
Requirement changes
- added ordered-set
- Python
Published by jonas-eschle about 6 years ago
zfit - Dependency required update
Special release for conda deployment and version fix (TF 2.0 is out)
This is the last release before breaking changes occur
zfit is still in beta stage
Major Features and Improvements
- added ConstantParameter and
zfit.paramnamespace - Available on conda-forge
Behavioral changes
- an implicitly created parameter with a Python numerical (e.g. when instantiating a model) will be converted to a ConstantParameter instead of a fixed Parameter and therefore cannot be set to floating later on.
Bug fixes and small changes
- added native support TFP distributions for analytic sampling
fix Gaussian (TFP Distribution) Constraint with mixed up order of parameters
from_numpyautomatically converts to default float regardless the original numpy dtype,dtypehas to be used as an explicit argument
- Python
Published by jonas-eschle over 6 years ago
zfit - Add Constraints and Polynomials
Major Features and Improvements
- create
Constraintclass which allows for more fine grained control and information on the applied constraints. - Added Polynomial models
- Improved and fixed sampling (can still be slightly biased)
Behavioral changes
None
Bug fixes and other changes
- fixed various small bugs note: This is the last release before breaking changes occur
Thanks
for the contribution of the Constraints to Matthieu Marinangeli matthieu.marinangeli@cern.ch
- Python
Published by jonas-eschle over 6 years ago
zfit - Partial numeric integration
Bugfixes mostly, a few major fixes. Partial numeric integration works now.
Bugfixes
- data_range cuts are now applied correctly, also in several dimensions when a subset is selected (which happens internally of some Functors, e.g. ProductPDF). Before, only the selected obs was respected for cuts.
- parital integration had a wrong take on checking limits (now uses
supports).
- Python
Published by jonas-eschle almost 7 years ago
zfit - Bug fixes and speed improvements
With 0.3.2, bugfixes and three changes in the API/behavior
Breaking changes
- tfp distributions wrapping is now different with dist_kwargs allowing for non-Parameter arguments (like other dists)
- sampling allows now for importance sampling (sampler in Model specified differently)
model.samplenow also returns a tensor, being consistent withpdfandintegrate
Bugfixes
- shape handling of tfp dists was "wrong" (though not producing wrong results!), fixed. TFP distributions now get a tensor with shape (nevents, nobs) instead of a list of tensors with (nevents,)
Improvements
- refactor the sampling for more flexibility and performance (less graph constructed)
- allow to use more sophisticated importance sampling (e.g. phasespace)
- on-the-fly normalization (experimentally) implemented with correct gradient
- Python
Published by jonas-eschle almost 7 years ago
zfit - Minor updates
Minor improvements and bugfixes including:
- improved importance sampling allowing to preinstantiate objects before it's called inside the while loop
- fixing a problem with
ztf.sqrt
- Python
Published by jonas-eschle almost 7 years ago
zfit - First Beta release
This is the first beta release of the zfit package.
- Python
Published by jonas-eschle almost 7 years ago