Skip to main content

Calibrated Bayesian optimization with composable conformal prediction (Weighted + Localized + Adaptive) on top of bayesian-gp-cvloss.

Project description

calibrated-bo

Calibrated Bayesian optimization with composable conformal prediction, built on top of bayesian-gp-cvloss.

Phase 1 (this release) — core single-objective stack:

  • CompositeConformalCalibrator with three orthogonal switches:
    • localized=True — pick only x*'s k-NN from the calibration set
    • weighted=True — RBF weights against x* on the surviving subset
    • adaptive=True — ACI controller updates α from rolling coverage
  • CalibratedUCB, CalibratedEI — drop-in calibrated acquisitions
  • CalibratedBOLoop — single-objective loop (suggest() / observe())
  • Platform adapter (create_bo_session(config))

All three calibrator switches are independent: turn them all off and the calibrator is numerically equivalent to standard split CP.

Phase 2 (planned) — multi-objective EHVI, q-batch with fantasies, diagnostics dashboard, native gp-cv platform integration.

Install

pip install -e D:/mypackage/calibrated-bo

Requires bayesian-gp-cvloss>=0.3.1.

Quickstart

import numpy as np
from calibrated_bo import CalibratedBOLoop

# 2D toy: minimise (x-0.3)^2 + (y-0.7)^2
def f(x):
    return np.sum((x - np.array([0.3, 0.7]))**2)

bo = CalibratedBOLoop(
    bounds=[(0.0, 1.0), (0.0, 1.0)],
    objective="minimize",
    calibrator_config={
        "alpha": 0.1,
        "localized": True, "k": 20,
        "weighted": True,
        "adaptive": True, "gamma": 0.05,
    },
    acquisition="cUCB",
    acquisition_kwargs={"beta": 2.0},
    batch_size=1,
    initial_random=5,
    gp_max_evals=30,
)

for step in range(20):
    X_next = bo.suggest()
    y_next = np.array([f(x) for x in X_next])
    bo.observe(X_next, y_next)

print("best so far:", bo.best)
print("diagnostics:", bo.diagnostics())

Calibrator-only usage

If you only want the calibrator (no BO loop), drop it on top of any fitted GPCrossValidatedOptimizer:

from bayesian_gp_cvloss import GPCrossValidatedOptimizer
from calibrated_bo import CompositeConformalCalibrator

opt = GPCrossValidatedOptimizer(X_train, y_train, scoring="cv_rmse")
opt.optimize(max_evals=50)

cal = CompositeConformalCalibrator(
    alpha=0.1, localized=True, weighted=True, adaptive=False
).fit_cv(opt)

mean, lower, upper = cal.predict_interval(X_new)

Design

See the project spec (calibrated-bo design doc) for the math behind Localized + Weighted + Adaptive coordination and the joint half-width formula.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

calibrated_bo-0.2.0.tar.gz (32.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

calibrated_bo-0.2.0-py3-none-any.whl (34.3 kB view details)

Uploaded Python 3

File details

Details for the file calibrated_bo-0.2.0.tar.gz.

File metadata

  • Download URL: calibrated_bo-0.2.0.tar.gz
  • Upload date:
  • Size: 32.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.8

File hashes

Hashes for calibrated_bo-0.2.0.tar.gz
Algorithm Hash digest
SHA256 eb5b26fe0b317f65921962eed0a7e9de60de14f59d4a366300dfccd5c1f6a23a
MD5 3494c85669bc45b40f8fc72c81d67c59
BLAKE2b-256 1e1091e487a591bcec1ac3fbc9c41b1319cacaee5bfae1958bc6e0ef380e687a

See more details on using hashes here.

File details

Details for the file calibrated_bo-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: calibrated_bo-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 34.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.8

File hashes

Hashes for calibrated_bo-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d4f2c341b208a1bc2cc91e68c146e69208cd96f4ff0a8c6ecc34bd6c08b0b0ca
MD5 a11ad87c482de38a00788ab46035da1e
BLAKE2b-256 90a55bbeaf28581f803c9ba50b478fdc2dafc196d715d5c452c5476bee18fdc1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page