Finding the best settings with fewer runs

Today let's look at how to find the best setting for something you can tune, without testing every combination it could take.

Elena roasts coffee for a living. Two things on her roaster decide how a batch turns out: the roast temperature, somewhere between 200 and 220 degrees Celsius, and the roast time, somewhere between 10 and 14 minutes. After every batch, a coffee quality panel tastes it and scores it on the 100-point cupping scale panels actually use. Elena wants the temperature and time that score the highest.

Just for this lesson, we're going to fix where the real best setting sits: temperature 210, time 12, a cupping score of 86. Elena never gets to see this number. It's an answer key, there only so that we can grade how close each of her searches actually gets.

She starts simple. Four roasts at the corners of her two ranges, crossing 200 or 220 degrees with 10 or 14 minutes, plus her usual setting of 210 and 12, repeated three times to see how much one roast's score wobbles on its own.

Here's where those seven roasts sit, before we look at how any of them scored.

Four roasts sit in the corners of her two ranges, and three sit stacked right in the middle. That's the shape every design in this lesson will start from.

What a full grid of settings would actually cost

Before we get to Elena's seven roasts, let's see what the obvious approach would have cost her.

The obvious way to find the best setting is to just try everything: lay a grid over both ranges and taste a roast at every combination. Let's see how big that grid gets using just 9 settings for each factor, temperature and time.

RInteractive R
# Build a 9 by 9 grid over the roast temperature and time ranges, and count the roasts it needs grid9 <- expand.grid(Temp = seq(200, 220, length.out = 9), Time = seq(10, 14, length.out = 9)) nrow(grid9) #> [1] 81

  

That's eighty-one roasts, just to cover two factors at nine settings each. Coffee is forgiving compared to a lot of real experiments: a batch costs Elena a bag of beans and twenty minutes. In a clinical trial, a factory line, or a chemical process, a single run can cost real money or take days, and eighty-one of them is not a plan, it's a wall of work.

A response surface takes a different approach. Instead of tasting every combination, it fits a smooth model to a handful of roasts placed on purpose, and lets that model do the searching from there. Elena's seven roasts are exactly that handful.