Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Broken KDE fits? #649

@acampove

Description

@acampove

Current Behaviour

When I use padding in my fits, I got one that looks really bad.
I would expect a much better fit

import json
import zfit
import matplotlib.pyplot as plt
import pandas            as pnd
from dmu.stats.zfit_plotter import ZFitPlotter

with open('data.json') as ifile:
    data  = json.load(ifile)

df    = pnd.DataFrame(data, columns=['mass'])
array = df['mass'].to_numpy()

obs = zfit.Space('x', limits=(5000, 6000))
data= zfit.data.from_numpy(array=array, obs=obs)

#pdf = zfit.pdf.KDE1DimISJ(data=array, obs=obs, padding={'lowermirror' : 0.8, 'uppermirror' : 0.8})
#pdf = zfit.pdf.KDE1DimISJ(data=array, obs=obs, padding={'lowermirror' : 0.1, 'uppermirror' : 0.1})
pdf = zfit.pdf.KDE1DimISJ(data=array, obs=obs, padding={'lowermirror' : 0.1})
#pdf = zfit.pdf.KDE1DimISJ(data=array, obs=obs)

ptr = ZFitPlotter(data=array, model=pdf)
ptr.plot()

plt.show()

data.json

When the lines with padding are used I see:

Image

In order to reproduce this you will need the file with data I attached.

Expected Behaviour

Without the padding I see:

Image

from the documentation, the default padding is 0.1. Even with 0.1 I see bad fits.

Context (Environment)

  • zfit version: 0.26.0, but also with older versions
  • Python version: 3.12
  • Are you using conda, pipenv, etc? : Micromamba
  • Operating System: AlmaLinux9
  • Tensorflow version: 2.16.2

Possible Solution/Implementation

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions