Skip to main content

Non-parametric score estimation

Welcome to the non_param_score_est Python package (GitHub repository, PyPi library).

Usage

Initial setup

To install the package, you are required to have a Python 3.10 or newer environment. Then, simply run:

pip install non_param_score_est

Choosing the estimator

The following estimators are available (and the corresponding import names):

Estimator Import Name
Tikhonov regularization Tikhonov
NKEF (with rate 0.75) Tikhonov(subsample_rate=0.75)
Kernel density estimator KDE
Landweber iteration Landweber
Nu-method NuMethod
Spectral Stein gradient estimator SSGE
Stein estimator Stein

Utilising the estimators

To use the estimators in your code, simply import the estimator and call the estimate_gradients_x_s or estimate_gradients_s function. For example, to utilise the Tikhonov estimator, you would write:

import numpy as np
from non_param_score_est.estimators import Tikhonov

samples = np.random.normal(1000)
est = Tikhonov(bandwidth=1., lam=1e-4)

#estimate the gradients of the generated samples
score_estimate = est.estimate_gradients_s(samples=samples)

#estimate the gradients of new query while fitting the score estimator to previously generated samples
new_query = np.random.normal(100)
new_estimate = est.estimate_gradients_s_x(queries=new_query, samples=samples)

Working with the estimators

A great way to further investigate how the estimators work is to check the plots.py file. It contains a script that generates plots of the estimators on a simple 1D and 2D examples. The plots are generated by running the following command:

from non_param_score_est.estimators import Tikhonov
from non_param_score_est.tests.plots import plotOneDim, plotTwoDim

# selecting Tikhonov regularization
est = Tikhonov(bandwidth=10., lam=1e-5)

# One-dimensional Gaussian distribution experiment
plotOneDim(estimator=est)

# Two-dimensional Gaussian distribution experiment
plotTwoDim(estimator=est)

These generate the following outputs:

One-dimensional experiment Two-dimensional experiment
One-dimensional experiment Two-dimensional experiment

Contributing

We welcome contributions! Please follow these guidelines if you'd like to contribute to the project:

  1. Fork our GitHub repository and clone it to your local machine.
  2. Create a new branch for your feature or bug fix.
  3. Make your changes and ensure that tests pass.
  4. Submit a pull request with a clear title and description.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

The code in JAX was inspired by the repository of the Nonparametric Score Estimators paper, by Yuhao Zhou, Jiaxin Shi, Jun Zhu.

Contact

Krunoslav Lehman Pavasovic Email: krunolp@gmail.com GitHub: krunolp

Metadata

Release files for non-param-score-est 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for non-param-score-est 1.0.0
File Size Uploaded Provenance Actions
non_param_score_est-1.0.0.tar.gz 18.6 kB Without provenance Details for non_param_score_est-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for non-param-score-est 1.0.0
File Interpreter ABI Platform Actions
non_param_score_est-1.0.0-py3-none-any.whl Python 3 none any Details for non_param_score_est-1.0.0-py3-none-any.whl

Total release size: 42.9 kB

Release files / non_param_score_est-1.0.0.tar.gz

Download URL non_param_score_est-1.0.0.tar.gz
Size 18.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0f0a9323d94c2c7f02d929048bdbf4f3374261a90b21d944f4d650f11d91bd0e
BLAKE2b-256 checksum
How to use checksums
b40c2fa422c9e1c81d8f105505b618f6305408993c43ec52d87541b494f09e9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release files / non_param_score_est-1.0.0-py3-none-any.whl

Download URL non_param_score_est-1.0.0-py3-none-any.whl
Size 24.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1fd019e68092bd6e9fc0a371ec40f1d5dfbd19a31fe7ba9c260d0b007ef679bc
BLAKE2b-256 checksum
How to use checksums
5a174cb42220e4431af77758f3609f1283f6580d89bd0bbdd5ad2161efb52eec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Security for non-param-score-est 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page