{"id":21290197,"url":"https://github.com/miskcoo/kscore","last_synced_at":"2025-07-11T14:32:11.711Z","repository":{"id":81680913,"uuid":"255101792","full_name":"miskcoo/kscore","owner":"miskcoo","description":"Nonparametric Score Estimators, ICML 2020","archived":false,"fork":false,"pushed_at":"2021-06-25T21:59:20.000Z","size":208,"stargazers_count":36,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-06T04:41:21.248Z","etag":null,"topics":["density-estimation","gradient-estimator","machine-learning","statistics"],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/2005.10099","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/miskcoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-12T14:37:05.000Z","updated_at":"2024-10-12T15:21:32.000Z","dependencies_parsed_at":"2023-03-30T02:50:03.077Z","dependency_job_id":null,"html_url":"https://github.com/miskcoo/kscore","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/miskcoo/kscore","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miskcoo%2Fkscore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miskcoo%2Fkscore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miskcoo%2Fkscore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miskcoo%2Fkscore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/miskcoo","download_url":"https://codeload.github.com/miskcoo/kscore/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miskcoo%2Fkscore/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264833280,"owners_count":23670617,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["density-estimation","gradient-estimator","machine-learning","statistics"],"created_at":"2024-11-21T12:45:46.294Z","updated_at":"2025-07-11T14:32:11.695Z","avatar_url":"https://github.com/miskcoo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nonparametric Score Estimators\n\nYuhao Zhou, Jiaxin Shi, Jun Zhu. https://arxiv.org/abs/2005.10099\n\n## Toy Example\n\n```\npython -m examples.spiral --lam=1.0e-5 --kernel=curlfree_imq --estimator=nu\n```\n\n\u003cimg src=\"spiral-gradient.png\" width=300 height=300 /\u003e\u003cimg src=\"spiral-density.png\" width=300 height=300 /\u003e\n\n## Dependencies\n\n```\nTensorflow \u003e= 1.14.0\n```\n\n## Usage\n\n* Create a score estimator\n\n  ```python\n  from kscore.estimators import *\n  from kscore.kernels import *\n\n  # Tikhonov regularization (Theorem 3.1), equivalent to KEF (Example 3.5)\n  kef_estimator = Tikhonov(lam=0.0001, use_cg=False, kernel=CurlFreeIMQ())\n  \n  # Tikhonov regularization + Conjugate Gradient (KEF-CG, Example 3.8)\n  kefcg_estimator = Tikhonov(lam=0.0001, use_cg=True, kernel=CurlFreeIMQ())\n  \n  # Tikhonov regularization + Nystrom approximation (Appendix C.1), \n  # equivalent to NKEF (Example C.1) using 60% samples\n  nkef_estimator = Tikhonov(lam=0.0001, use_cg=False, subsample_rate=0.6, kernel=CurlFreeIMQ())\n  \n  # Tikhonov regularization + Nystrom approximation + Conjugate Gradient\n  nkefcg_estimator = Tikhonov(lam=0.0001, use_cg=True, subsample_rate=0.6, kernel=CurlFreeIMQ())\n  \n  # Landweber iteration (Theorem 3.4)\n  landweber_estimator = Landweber(lam=0.00001, kernel=CurlFreeIMQ())\n  landweber_estimator = Landweber(iternum=100, kernel=CurlFreeIMQ())\n  \n  # nu-method (Example C.4)\n  nu_estimator = NuMethod(lam=0.00001, kernel=CurlFreeIMQ())\n  nu_estimator = NuMethod(iternum=100, kernel=CurlFreeIMQ())\n  \n  # Spectral cut-off regularization (Theorem 3.2), \n  # equivalent to SSGE (Example 3.6) using 90% eigenvalues\n  ssge_estimator = SpectralCutoff(keep_rate=0.9, kernel=DiagonalIMQ())\n  \n  # Original Stein estimator\n  stein_estimator = Stein(lam=0.001)\n  ```\n\n* Fit the score estimator using samples\n\n  ```python\n  # manually specify the hyperparameter\n  estimator.fit(samples, kernel_hyperparams=kernel_width)\n\n  # automatically choose the hyperparameter (using the median trick)\n  estimator.fit(samples)\n  ```\n\n* Predict the score\n\n  ```python\n  gradient = estimator.compute_gradients(x)\n  ```\n\n* Predict the energy (unnormalized log-density)\n\n  ```python\n  log_p = estimator.compute_energy(x)   # only for curl-free kernels\n  ```\n\n* Construct other curl-free kernels (see `kscore/kernels/curlfree_gaussian.py`)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiskcoo%2Fkscore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmiskcoo%2Fkscore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiskcoo%2Fkscore/lists"}