Releases: zfit/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_gradient
andgradient
. 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
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.
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.dill
to dump and load objects with dill (a more powerful pickle). This way, any zfit object can be saved and loaded, such asFitResult
that 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.
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! See here for an interactive guide
Major Features and Improvements
- Parameter behavior has changed, multiple parameters with the same name can now coexist!
TheNameAlreadyTakenError
has 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>
_). Space
and 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
Sampler
to the public namespace underzfit.data.Sampler
: this object is returned in thecreate_sampler
method and allows to resample from a function without recreating the compiled function, i.e. loss. It has an additional methodupdate_data
to 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
GeneralizedCB
PDF which is similar to theDoubleCB
PDF but with different standard deviations for the left and right side. - Added functor for PDF caching
CachedPDF
:pdf
,integrate
PDF methods can be cacheable now - add
faddeeva_humlicek
function under thezfit.z.numpy
namespace. This is an implementation of the Faddeeva function, combining Humlicek's rational approximations according to Humlicek (JQSRT, 1979) and Humlicek (JQSRT, 1982). - add
Voigt
profile PDF which is a convolution of a Gaussian and a Cauchy distribution. - add
TruncatedPDF
that allows to truncate in one or multiple ranges (replaces "MultipleLimits" and "MultiSpace") - add
LogNormal
PDF, a log-normal distribution, which is a normal distribution of the logarithm of the variable. - add
ChiSquared
PDF, the standard chi2 distribution, taken fromtensorflow-probability implementation <https://www.tensorflow.org/probability/api_docs/python/tfp/distributions/Chi2>
_. - add
StudentT
PDF, the standard Student's t distribution, taken fromtensorflow-probability implementation <https://www.tensorflow.org/probability/api_docs/python/tfp/distributions/StudentT>
_. - add
GaussExpTail
andGeneralizedGaussExpTail
PDFs, 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
QGauss
PDF, a distribution that arises from the maximization of the Tsallis entropy under appropriate constraints, seehere <https://en.wikipedia.org/wiki/Q-Gaussian_distribution>
_. - add ``BifurGauss` PDF, a Gaussian distribution with different sigmas on each side of the mean.
- add
Bernstein
PDF, which is a PDF defined by a linear combination of Bernstein polynomials given their coefficients. - add
Gamma
PDF, the Gamma distribution. Data
has now awith_weights
method that returns a new data object with different weights and an improvedwith_obs
that allows to set obs with new limits. These replace theset_weights
andset_data_range
methods for a more functional approach.- add
label
to 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.Space
has one label for each observable if the space is a product of spaces.Space.label
is a string and only possible for one-dimensional spaces, whileSpace.labels
is 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_truncated
method 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. Data
andPDF
that takeobs
in the initialization can now also take binned observables, i.e. azfit.Space
withbinning=...
and will return a binned version of the object (zfit.data.BinnedData
orzfit.pdf.BinnedFromUnbinned
, where the latter is a generic wrapper). This is equivalent of callingto_binned
on the objects)zfit.Data
can be instantiated directly with most data types, such as numpy arrays, pandas DataFrames etc insead of using the dedicated constructorsfrom_numpy
,from_pandas
etc.
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 usingzfit.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 argumentsbranches
andbranch_aliases
have been removed. Useobs
andobs_aliases
instead.NameAlreadyTakenError
was 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.Variable
was 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 argumentn
to theresample
method, as was possible since a long time. create_sampler
has 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 calledparams
and behaves as expected: the sampler will remember the parameters at the time of creation,
possibly updated withparams
and will not change anymore. To sample from a different set of parameters,
the params have to be passed to theresample
method explicitly.- the default names for
hesse
anderrors
have now been changed tohesse
anderrors
, 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_hessse
orminuit_minos
not found, just replace it withhesse
anderrors
.
Deprecations
result.fminfull
is deprecated and will be removed in the future. Useresult.fmin
instead.Data.set_data_range
is deprecated and will be removed in the future. Usewith_range
instead.Space
has many deprecated methods, such asrect_limits
and quite a few more. The full discussion can be foundhere <https://github.com/zfit/zfit/discussions/533>
_.fixed_params
increate_sampler
is deprecated and will be removed in the future. Useparams
instead.fixed_params
attribute of theSampler
is deprecated and will be removed in the future. Useparams
instead.uncertainties
inGaussianConstraint
is deprecated and will be removed in the future. Use either explicitlysigma
orcov
.- the
ComposedParameter
andComplexParameter
argumentvalue_fn
is 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.Session
times 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.
FitResult
can now be used as a context manager, which will automatically set the values of the parameters to the best fit values and reset th...
Add missing dep
Hotfix release to add missing deps attrs
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
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
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_values
for 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
0.16.0 Minor fixes and improvements
0.16.0 (26 July 2023)
Major Features and Improvements
- add
full
option 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
FitResult
to print both loss values, the unoptimized (full) and optimized (internal)
Bug fixes and small changes
- bandwidth preprocessing was ignored in KDE
unstack_x
with anobs
as 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
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