'Which parameters must be saved by a Kernel Density Estimation to reload it later?
I trained a kde with sklearn and now I want to save the parameters. Which parameters are needed to fully describe a kde? I don't want to save the kde as such, only the parameters.
Thanks a lot!
Solution 1:[1]
You have to train your KDE on your dataset again.
There is, as far as I know, no way to save a trained sklearn KDE model without saving the corresponding training dataset. Looking at the documentation of the fit() method for sklearn KernelDensity, you can see that "fitting" the model only assigns the training dataset to the KDE instance. Documentation and source code here: https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.KernelDensity.html#sklearn.neighbors.KernelDensity.fit
For reproducibility, the hyperparameters you may want to save are the type of kernel, the bandwidth or the distance metric to use. That said, the fit() method will still require the whole training dataset to sample new instances or compute the log-likelihood of a given sample.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Florian Lalande |
