- Add utility functions for hypothesis learning based on the [arXiv:2112.06649](https://arxiv.org/abs/2112.06649) paper.
Now the exploration phase of the hypothesis learning can be implemented as follows:
python3
Lists with physical models and probabilistic priors over their parameters
models = [model1, model2, model3]
model_priors = [model1_priors, model2_priors, model3_priors]
Initialize the reward and predictive uncertainty records
record = np.zeros((len(models), 2))
obj_history = []
def compute_reward(obj_history):
"""Simple reward function"""
r = 1 if obj_history[-1] < obj_history[-2] else -1
return r
Run active hypothesis learning for 15 steps
for e in range(15):
Sample model according to softmax or epsilon-greedy selection policy
idx = gpax.hypo.sample_next(
rewards=record[:, 1], method="softmax", temperature=1.2)
Derive fully Bayesian predictive uncertainty with the selected model
obj, _ = gpax.hypo.step(
models[idx], model_priors[idx],
X_measured, y_measured, X_unmeasured,
gp_wrap=True, gp_kernel='Matern' wrap the sampled model into a Gaussian process
)
Update predictive uncertainty records
obj_history.append(jnp.nanmedian(obj).item())
if e < 1:
continue
Compute reward and update reward records
r = compute_reward(obj_history)
record = gpax.hypo.update_record(record, idx, r)
Evaluate function in the suggested point
next_point_idx = obj.argmax()
measured_point = measure(next_point_idx) your actual measurement function goes here
Update arrays with measured and unmeasured data
X_measured, y_measured, X_unmeasured = update_datapoints(X_measured, y_measured, X_unmeasured)
- Minor bug fixes
- Documentation updates
- Test updates