🥾 Boots 👢 - A Tiny Bootstrapping Library
This is a tiny library for doing bootstrap sampling and estimating. It pulls together various tricks to make the process as fast and painless as possible. The tricks included are:
- Parallel execution with
joblib - The Bayesian bootstrap with two-level sampling.
- The Vose method for fast weighted sampling with replacement
Install
pip install boots
For development:
pip install git+https://github.com/pmbaumgartner/boots
Example
from boots import bootstrap
import numpy as np
x = np.random.pareto(2, 100)
samples = bootstrap(
data=x,
statistic=np.median,
n_iterations=1000,
seed=1234,
n_jobs=-1
)
# bayesian two-level w/ 4 parallel jobs
samples = bootstrap(
data=x,
statistic=np.median,
n_iterations=1000,
seed=1234,
n_jobs=4,
bayesian=True
)
# do something with it
import pandas as pd
posterior = pd.Series(samples)
posterior.describe(percentiles=[0.025, 0.5, 0.975])
Paired Statistics
from boots import bootstrap
import numpy as np
# generate some fake correlated data by sorting two arrays and adding some noise
a = np.sort(np.random.normal(0, 1, 100)) + np.random.normal(0, 1, 100)
b = np.sort(np.random.normal(0, 1, 100)) + np.random.normal(0, 1, 100)
pairs = list(zip(a, b))
# for paired (or row-wise) metrics you might need to
# create a wrapper function that unpacks
# each row's values into array arguments for your metric function
def corr_unwrap(pairs):
a1, a2 = zip(*pairs)
corr = np.corrcoef(a1, a2)[0, 1]
return corr
samples = bootstrap(
data=pairs,
statistic=corr_unwrap,
n_iterations=1000,
seed=1234,
n_jobs=-1,
bayesian=True
)
import pandas as pd
posterior = pd.Series(samples)
posterior.describe(percentiles=[0.025, 0.5, 0.975])
Metadata
Release files for boots 0.1.2
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 | Actions |
|---|---|---|---|---|
| boots-0.1.2.tar.gz | 3.2 kB | Without provenance | Details for boots-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| boots-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for boots-0.1.2-py3-none-any.whl |
Total release size: 6.3 kB
Release files / boots-0.1.2.tar.gz
| Download URL | boots-0.1.2.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d69fd38f91296a689ece8f6a4452191b69dfe713775a8ef11848d0bd6ed5f576
|
|
BLAKE2b-256 checksum How to use checksums |
1c182a708fed7be51773a188c8608186973ccffe127100c6097e2c28ffe167e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.2 CPython/3.8.13 Darwin/21.5.0
|
Release files / boots-0.1.2-py3-none-any.whl
| Download URL | boots-0.1.2-py3-none-any.whl |
|---|---|
| Size | 3.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4885817505c3d814fa2d484e0e1f28ed3e13d979e85cdb74694657bca50d9bec
|
|
BLAKE2b-256 checksum How to use checksums |
81dec41ca8a99e97c86ee3f9cd17bf459e18da69bdfe8d980521a679e6b77472
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.2 CPython/3.8.13 Darwin/21.5.0
|
Security for boots 0.1.2
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.