Search code examples
pythonpandaskernel-densityprobability-density

Applying other kernel functions in pandas plot


I would like to know what function are used for kde plot in pandas. I also want to know how to change kde's kernel function in pandas.

df.plot.kde();

I'm still studying this feature, but the default looks like a Gaussian function.


Solution

  • You can change the kernel in this way:

     kde = KernelDensity(kernel='gaussian', bandwidth=0.2).fit(X)
    

    where kernel can be: 'gaussian', 'tophat', 'epanechnikov', 'exponential', 'linear' and 'cosine'. Take a better look here: http://scikit-learn.org/stable/modules/density.html