Open-source workbench for ingredient-replacement experiments, benchmarked against BayBE. Criticism wanted

I maintain Reformulation Assurance, an open-source workbench for ingredient replacement projects in formulated products (coatings, cosmetics, food). It imports a lab’s trial history, fits GP and random-forest models per specification, ranks fresh candidates from a bounded mixture generator by the joint probability of meeting every spec, and then runs the qualification side: replicate checks, approvals tied to a hash of the evidence, and a dossier export.

The benchmark

The part this forum might have views on is the ranking. I benchmarked the app’s ranker against BayBE 0.15 on the 88-lot cosmetics history that ships with the app, with a random-forest oracle standing in for the lab.

  • BayBE with a desirability objective: top-2% candidate in round one, all five seeds
  • the app’s ranker: one or two rounds
  • a scalarized single target: about twenty
  • random: about thirty
  • with an MLP oracle instead: the app’s ranker median 4 rounds, BayBE 6

Script and results are in the repo (backtest_ranker_vs_baybe.py, backtest_results.csv), with the limitations in the docstring, including that the oracle is itself a model.

Where I would value a push

The candidate generation is model-ranked random search over the simplex, not Bayesian optimization, and the app says so. Is there a standard way people here handle the sparse-history case, 15 to 40 lots, where pure exploitation should stop working? And if anyone has a formulation history they could share, even anonymised, I would like to see where the ranker breaks.

Demo (shared sandbox, nothing real please): https://reformulation-assurance-demo.streamlit.app/
Code: GitHub - TM289012/reformulation-assurance · GitHub

Benchmarking against BayBE on mixture/formulation replacement is a great testbed because standard Gaussian Process kernels struggle with the simplex constraint (\sum_i x_i = 1, x_i \ge 0) and zero-inflated categorical-continuous interaction terms when swapping one ingredient out for a candidate substitute.

Two methodological checks that strengthen formulation BO benchmarks:
Compositional Aitchison / Isometric Log-Ratio (ILR) Warping: Check whether the surrogate kernel operates on raw mass fractions or applies an additive/isometric log-ratio transform with a dedicated boundary kernel for exact x_i = 0 ingredient drop-out.
Chemical Descriptor Priors on Cold-Start Substitutes: When evaluating unseen replacement ingredients, encoding the candidate’s physicochemical descriptors (Hansen solubility parameters \delta_D, \delta_P, \delta_H, molecular weight, or Mordred/Morgan fingerprints) rather than one-hot categorical indices lets the GP transfer response-surface curvature on iteration 1.

Thanks for the response! On the first, the honest answer is that the surrogate sees raw mass fractions. It is a Matérn 5/2 with per-variable length scales on the mixture columns plus the standardized process columns, categoricals are one-hot, and the simplex is handled by construction in the candidate generator (candidates are sampled on the bounded simplex with the legacy ingredient locked at zero) rather than in the kernel. So no ILR warp and no boundary kernel for exact zeros, and the zero-inflation point lands, since the substitute columns are zero in most of the history by definition. I have not tried an ILR transform. With 50 to 90 lots, would you expect the warp itself to matter more, or the boundary handling? On the second, that is the direction of the next version. The spike models the substitute slot as a BayBE SubstanceParameter encoded from real structures with Mordred descriptors instead of one-hot. Hansen parameters had not occurred to me for the emulsifier slot and are a much more compact encoding for that kind of behaviour, so thank you for that one.

At 50 to 90 lots with structural zeros across the substitute columns, boundary handling matters much more than an ILR warp.

Because your candidate generator already enforces the bounded simplex by construction, Matérn 5/2 on raw mass fractions behaves well in the interior. Standard ILR is undefined at x_i = 0 and requires multiplicative pseudocounts that distort gradients right at the 0 -> x_i > 0 switch-on boundary where replacement decisions happen.

With sparse substitute rows, a single ARD lengthscale gets pulled trying to fit both the discrete jump of introducing the substitute and its continuous dosage curve. Factoring the slot into a presence indicator I(x_i > 0) plus active dosage x_i (paired with compact (\delta_D, \delta_P, \delta_H) Hansen or HLB emulsifier coordinates instead of high-dimensional Mordred vectors) isolates the swap step from dosage curvature cleanly.

On the ILR versus boundary question at 50 to 90 lots: I’d expect the boundary handling to dominate and the warp to be secondary. With that many lots the sparse zero-inflation on substitute columns carries more risk than simplex geometry, since a Matérn 5/2 on raw fractions is mostly suffering from treating structural zeros as real distances. Applying ILR alone without a boundary kernel would still pull exact drop-outs toward the interior. A boundary-aware treatment plus ILR is the combination I’d test first, run as an ablation against your current kernel rather than as a full swap, so the backtest stays interpretable.

1 Like

Thanks for the feedback! I ran it the way you described, as an ablation against the current kernel and not a swap. It is in v0.12.9 of Reformulation Assurance.

There are two new encodings, both built from the same columns. The first adds a 0/1 presence indicator for every ingredient that is absent from some lots (here the legacy emulsifier and the glucoside) and keeps the raw fraction as the dosage. The second keeps the indicators and swaps the raw fractions for ilr coordinates of the whole composition, with multiplicative zero replacement and a sequential binary partition that puts the reformulation slot first. The app itself still fits on raw fractions.

I used the same benchmark as before, same oracles, pools and seeds, with the shipped ranker as the control, and also ran it from a 30-lot subsample where I expected the encoding to matter more. The table is rounds to a top-2% candidate, median (min to max) over 5 seeds.

History Oracle Control Presence Presence + ilr
88 lots rf 2 (1 to 2) 2 (1 to 2) 1 (1 to 4)
88 lots mlp 4 (1 to 5) 4 (1 to 7) 3 (1 to 16)
30 lots rf 2 (1 to 8) 4 (1 to 5) 2 (1 to 3)
30 lots mlp 2 (1 to 19) 7 (2 to 10) 4 (1 to 15)

So it came out flat. The medians are within a few rounds of each other, every arm has a slow run somewhere, and at five seeds I would not read more into it than that.

A cross-validated predictive check says the same thing from the other side, trade-offs and no overall gain. This one is RMSE over sd, lower is better.

Response Raw Presence Presence + ilr
Viscosity 0.31 0.35 0.31
Stability 0.74 0.69 0.91
Spreadability 0.73 0.74 0.62

The part I found most useful was the transfer test. When I train only on lots that still contain the legacy emulsifier and predict the lots without it, the legacy indicator is constant in training and drops out, so it has nothing to learn from. That is the cold-start case, where the history cannot say anything about a new substitute, and it is why HLB and Hansen descriptors are the next arm.

One caveat. The history is synthetic, so its generator decides whether a response follows log-ratios or raw fractions, and these numbers measure that as much as the encodings. If either of you knows an open formulation dataset with real zeros in it, I would like to rerun this on it.

The full write-up is in the modeling notes and the encodings are in composition_features.py.

1 Like