Blog

First principles and machine learning are not rivals

I once watched a chemical engineer and a data scientist argue for an hour about an evaporator. Each was certain the other's method was a waste of time. Both were about half right.

Date

Two ways of knowing an evaporator

The engineer's case went like this. An evaporator is not a mystery. Steam goes in one side of a tube, liquid boils on the other, and the rate at which heat crosses is given by an equation every student meets in the second year. What goes in must come out, as vapor or as concentrate. Energy is conserved, whatever anybody would prefer. Why would you throw all that away and ask a computer to guess?

The data scientist's case was just as good. The equation has a number in it, the heat transfer coefficient, and on a real evaporator that number will not sit still. It falls as deposit builds on the tubes. It depends on the viscosity of the liquor, which depends on what the feed happened to be that week. It differs from one effect to the next for reasons that have to do with how the liquid spreads over the tubes, and no two textbooks agree about that. The equation is beautiful and it gives the wrong answer by Thursday. Whereas the plant has ten years of data showing what the evaporator really did.

You can see how this goes. The engineer says the model knows no physics and will one day predict that water flows uphill. The data scientist says the physics knows nothing about this evaporator. They are describing the weak point of each other's method quite accurately, and each has overlooked that his own strong point covers it.

Let each do the part it is good at

Think about what each kind of knowledge is like.

First principles are true everywhere. A mass balance holds at half load and double load, in conditions the plant has never seen, on the day after a revamp. That is what you cannot get from data, because data only covers where the plant has been. But first principles are incomplete. They come with gaps, coefficients and factors that have to be filled in from somewhere, and that is where the trouble lives.

A model learned from data is the other way round. Inside the range of its experience it captures all the untidy particulars: the fouling, the odd behavior of the third effect, the difference the feed makes. Step outside that range and it has nothing to hold on to. It will extend whatever curve it found, straight through the laws of thermodynamics if they happen to be in the way.

So you do not have to choose, and it would be a strange thing to do. The equations go in for everything that is certain: the balances, the conservation of energy, the general form of the heat transfer. That is the skeleton. The learning is then pointed at the gaps. The model is not asked "what will the evaporator do?", which is a large question, but "what is the heat transfer coefficient right now, given the feed and the hours since the last wash?", which is a small one. The data can answer the small one well, and a wrong answer to it cannot break the balance.

Several good things follow, and I will say them plainly since they are the reason for the whole business. The combined model needs less data, because it is not spending data to rediscover that energy is conserved. It behaves sensibly in conditions it has not met, since the skeleton holds even where the learned part is guessing. Its inner quantities mean something: a learned coefficient that has dropped by a fifth is a fouled tube bundle, and an engineer can do something about that. And it can be discussed with the plant's own engineers in their language, which matters more than any of the rest.

There is a second way to combine them that is simpler still. Let the equations make their prediction, note how far it misses the plant, and train a model on the misses. The physics does most of the work and the learning mops up what physics left out. It is not elegant. It works surprisingly often.

It suits best the equipment where the chemistry is understood and the day-to-day condition is not: the evaporators and dryers of a dairy plant, for one, which foul by the hour and are washed every day.

I should add that the arrangement asks something of the people as well. The data scientist has to learn enough chemical engineering to respect a balance. The engineer has to accept that a coefficient may be better estimated from last month's data than from a correlation published before he was born. Neither finds this easy. But I notice that the projects where the two of them share an office go better than the ones where they exchange files.

My two debaters, I am glad to say, ended the hour by drawing on the same whiteboard. The engineer wrote the balance. The data scientist circled the coefficient. They went on arguing after that, but about smaller things.