bridge-gate
BRIDGE decides whether a candidate model may replace the current model. It uses labeled rows that neither model saw during training (POOL) and the predicted labels of both models on those rows. The number of classes is read from the labels.
Install
pip install bridge-gate
From a local checkout:
pip install ./pkg
Python 3.10 or later is required. NumPy, SciPy, pandas and scikit-learn are installed automatically.
Command line
bridge-gate --dataset your.csv --target label
Without --candidates and --auto, the program runs the reference procedure
from the paper: HGB as the current model, threshold and ensemble candidates,
32 bags, and the frozen gate settings. For the same data and seed it returns
the same decision as the reference trial code.
bridge-gate --dataset you.csv --target label --reference held_out.csv
--reference checks the decision on labeled rows that the procedure never saw.
Custom candidates are available with --candidates or --auto. These runs are
outside the reference procedure and the output says so.
bridge-gate --dataset iris --current rf --auto
bridge-gate --dataset iris --current rf --auto combined
bridge-gate --dataset mango.csv --target grade --current rf \
--candidates tuned_hgb,fs50_hgb,thr0.35,ens_hgb+logreg
Run bridge-gate --help for all options. The full user manual is in
MANUAL.md.
Python API
import bridge_gate as bridge
search, pool = bridge.split(y) # fit and tune on SEARCH; judge on POOL
# fit the current and candidate models on X[search], y[search]
d = bridge.gate(y[pool], current.predict(X[pool]), candidate.predict(X[pool]))
print(d.accept, d.lower_bound, d.gain_pool, d.warnings)
For several candidates, pass all of them and let the gate choose with cross-fitting:
d = bridge.gate_select(
y[pool],
current.predict(X[pool]),
{"threshold 0.35": p1, "ensemble": p2},
)
print(d.chosen)
Frozen settings: margin 0.005, lower bootstrap quantile 5%, 20,000 bootstrap replicates, 3 cross-fitting folds.
Metrics: weighted-F1 ("wF1") for any number of classes. For two classes the
package also supports accuracy ("acc"), balanced accuracy ("bacc"),
macro-F1 ("macroF1"), net benefit at 0.1 or 0.2 ("nb10", "nb20") and F2
("F2").
Before using the gate
- Fit, tune and select on SEARCH only. Never use POOL for any of these steps.
- Fix the candidates before looking at POOL. For several candidates, use
gate_selectinstead of picking the best one yourself. - Keep POOL and deployment data from the same population. Distribution shift has not been tested.
- Make sure every class is present in POOL.
bridge.checkreports this. - For imbalanced two-class data, prefer balanced accuracy or macro-F1.
License
MIT. See LICENSE.
Metadata
Release files for bridge-gate 1.0.0
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 | |
|---|---|---|---|---|
| bridge_gate-1.0.0.tar.gz | 32.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bridge_gate-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 60.7 kB
Release files / bridge_gate-1.0.0.tar.gz
| Download URL | bridge_gate-1.0.0.tar.gz |
|---|---|
| Size | 32.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f3c9f7ae1277ebd40eb78f4e10a20179f980ab61dbb6b2d67ceb6867ff1fb500
|
|
BLAKE2b-256 checksum How to use checksums |
868b75719bcea4fb6a5b8225081aa759451e9e813a356b7df117fe584782d827
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.2
|
Release files / bridge_gate-1.0.0-py3-none-any.whl
| Download URL | bridge_gate-1.0.0-py3-none-any.whl |
|---|---|
| Size | 28.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
23d8e758831262484b5984f7ac6252f2698279d9aaebbcf37b133e1bc4536424
|
|
BLAKE2b-256 checksum How to use checksums |
fa644b8787d7a2b5ea65985b3b5f53c86107e06b13a56dbe56592305b86a8eda
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.2
|
Security for bridge-gate 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.