Bayes Error (Local averaging of the posterior)
Installation
To install this small tool from source code
pip install git+https://github.com/cat-claws/bayes-error-local-averaging
How to use
import bayeslap
import numpy as np
import torch
from sklearn.datasets import make_moons
# Set random seeds for reproducibility
np.random.seed(42)
torch.manual_seed(42)
# === Example 1: 2D Moons Dataset ===
def create_moons_data(n_samples=2000, noise=0.2):
X_np, y_np = make_moons(n_samples=n_samples, noise=noise)
X_torch = torch.tensor(X_np, dtype=torch.float32)
y_torch = torch.tensor(y_np, dtype=torch.long)
return X_np, y_np, X_torch, y_torch
moons_np, moons_labels_np, moons_torch, moons_labels_torch = create_moons_data()
error = bayeslap.BayesErrorRBF.apply(moons_torch, moons_labels_torch, 0.3, 10, 32)
# Alternatively
# error = bayeslap.BayesErrorLogistic.apply(moons_torch, moons_labels_torch, 10, 32)
print("Bayes error:", error.item()) # Show first few estimates
error.backward() # Now X.grad will have the gradient of the error
print("Shape of Torch gradient:", moons_torch.grad.shape)
print("First 3 gradients (Torch):")
print(moons_torch.grad[:3])
Metadata
Release files for bayeslap 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| bayeslap-0.0.1.tar.gz | 8.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bayeslap-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 25.2 kB
Release files / bayeslap-0.0.1.tar.gz
| Download URL | bayeslap-0.0.1.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
316e79e0ffd632854f7121ff0644cfa194348c34bfa25a6bbb565d52f45c5328
|
|
BLAKE2b-256 checksum How to use checksums |
308ab1c68850bf7e0d7f820185c02f462d2c46620628f276c78b47da58927f3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / bayeslap-0.0.1-py3-none-any.whl
| Download URL | bayeslap-0.0.1-py3-none-any.whl |
|---|---|
| Size | 16.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
130e9d06ce3bc1a91104dcee234582654abeccfeb5a8966a6c82141b63301b74
|
|
BLAKE2b-256 checksum How to use checksums |
f9cfed22d3b8a08e0bfd87f3992e75f02acc253a64742af379a80858d355443b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Security for bayeslap 0.0.1
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.