Max Kopp Tech

Gradient Boosting on a Glucose Photocurrent Signal

Contact Max Kopp
Share Post :

Gradient Boosting on a Glucose Photocurrent Signal

The 2026 paper reports that gradient-boosting regression, applied to the polarization-photocurrent data from my GeSe detectors, improved prediction accuracy by more than 20% and reached a mean absolute error (MAE) of 8.6 mg/dL and a root-mean-square error (RMSE) of 11.2 mg/dL. The measurements are in vitro, on glucose solutions between 50 and 300 mg/dL. I want to spend this post on how to read those two error numbers, because a lot can be inferred from them, and on where a tree-based model is likely to mislead.

Two names that sound alike

In my 2024 paper I used gradient descent, which is an optimizer. It adjusted the coefficients of a polynomial regression until the squared error stopped falling. Gradient boosting is a different thing with a similar name. It builds an ensemble of shallow decision trees one after another, and each new tree is fitted to the errors left by the trees before it (Friedman, 2001, doi:10.1214/aos/1013203451). The first is a way of finding the best line or curve. The second is a way of building a flexible curve with no preset shape. I describe the 2024 regression, with its limits, in a separate post. The jump from one to the other is the story of this paper’s modeling step.

What the two error numbers say

Take the numbers at face value. The calibration range is 50 to 300 mg/dL, a span of 250 mg/dL, so an MAE of 8.6 mg/dL is about 3.4% of the span. That is a statement about the model on prepared solutions, and nothing else.

The more informative comparison is between the two metrics. MAE averages the size of the errors. RMSE squares them first, so large misses count for more. If every error had exactly the same magnitude the ratio RMSE/MAE would be 1. For errors that follow a normal distribution it is about 1.25. Here it is 11.2 / 8.6, or 1.30. That is close to the normal-distribution value, and it tells me the error budget is not dominated by a few large outliers. A model that was usually good but occasionally wrong by 40 mg/dL would show a much larger ratio. It is a small piece of evidence, but it is the kind that is available from two numbers in an abstract, and it points in the right direction.

The detection limit of about 12 mg/dL in the same abstract answers a different question. It describes how small a concentration change the raw phase signal can distinguish from noise. The MAE describes how far the model’s predictions land from the prepared concentration. One does not have to be smaller than the other. They come from different calculations, and the 8.6 should not be read as a better detection limit.

Why a tree model for this kind of data

A table of photocurrent features and a reference concentration is small, tabular and noisy. Boosted trees are a reasonable first choice for that. They make no assumption that the response is linear. They cope with interactions, for instance between an offset that depends on the individual flake and the signal that depends on the solution. They need little feature scaling. In the 2024 work I min-max normalized the features and chose a polynomial order by hand, and that order is a modeling choice that moves the answer. A tree model has no such knob.

Trees have a cost, and it is built into how they predict. A tree outputs a constant inside each leaf, so a boosted model’s predictions form a staircase rather than a smooth curve. More importantly, a tree cannot extrapolate. Outside the range of its training data it simply repeats the nearest value. Within the range there is a milder version of the same problem: predictions at the lowest and highest concentrations are pulled toward the middle, because the leaves at the edges average over neighbours that sit on only one side. An MAE averaged over the whole range can hide a model that is slightly too high at 50 mg/dL and slightly too low at 300 mg/dL. What reveals it is a plot of residual against reference concentration, and that is the first figure I plan to add in the next round.

A polynomial, like the one in my 2024 work, has the opposite weakness. It extrapolates freely, and near the edge of the feature range it can drift to a physically impossible value such as a negative concentration. So neither kind of model is automatically safe at the edges, for opposite reasons, and the edges are where a glucose sensor matters most. That is one reason I like the monotonic constraints described below.

Which measurements are independent?

Percent improvement and error numbers depend on the validation behind them, and the design question that matters most with laboratory calibration data is replication. If I prepare a solution, scan it several times and then split the individual scans at random into training and test sets, the test scans have siblings in the training set. The model can learn the quirks of that particular solution and that particular day, such as a small drift in laser power or a slight misalignment, and then be rewarded for recognizing them.

Two grids of colored squares. In the left grid, held-out readings are scattered randomly across all rows. In the right grid, entire rows are held out.
Why validation should split by prepared solution rather than by individual reading. Illustrative layout drawn by the author; each row is one solution, each square one repeated reading. No data shown.

The natural unit of independence is the solution, and beyond that the device and the day. Holding out whole solutions is the design I prefer. A stronger test holds out a whole device, because each exfoliated GeSe flake has its own thickness, contact quality and crystal orientation. The research question there is whether a calibration made on one flake transfers to another, and I treat that as something to measure, not assume. I describe how a device is made, and why they differ, in the fabrication post.

The percentage figure has a related caveat. “More than 20%” is a ratio against a baseline, and it also depends on which metric it was computed on. The baseline and the metric are defined in the paper, and I always quote them together with the 20%, since the number means little on its own.

What I would do in the next round

I would design the validation before taking any data, rather than choosing a split afterward. These are the specific changes I would make.

First, a nested, grouped cross-validation, where the groups are solutions and, in a separate run, devices. The outer loop gives the error estimate and the inner loop tunes the hyperparameters, so that the tuning never sees the test solutions.

Second, a plain regularized linear model on the same features, as a yardstick. If ridge regression gets within a few percent of the boosted model, the extra flexibility is not buying much, and the simpler model is easier to defend and to port to a small microcontroller.

Third, monotonic constraints. Boosted-tree libraries, including scikit-learn’s HistGradientBoostingRegressor through its monotonic_cst option, let you require that the prediction never decreases as a chosen feature increases. If the physics says concentration and fitted phase move together, I would rather the model were forbidden from drawing a dip between two neighbouring solutions. It trades a little flexibility for predictions that cannot be physically absurd.

Fourth, prediction intervals. A model that returns 134 mg/dL is much less useful than one that returns 134 with a range. Quantile loss in gradient boosting gives lower and upper predictions directly, and the width of the interval, plotted against concentration, would show at a glance where the model is unsure.

Fifth, a learning curve, with error plotted against the number of training solutions. If the curve is still falling steeply at the largest training set, the limit is data. If it has flattened, the limit is the signal or the model, and more solutions will not help.

Scope

Everything above concerns solutions in a cuvette. I draw no conclusion here about skin or blood, where scattering and depolarization add problems that a clear solution does not have. The accurate summary is that a boosted-tree model calibrated the polarization-photocurrent signal of a GeSe detector against prepared glucose solutions with an MAE of 8.6 mg/dL. The next round of experiments extends that to new solutions and new devices, using the validation design outlined above. VitaSensor remains laboratory research, at the stage of a third-generation prototype.

Sources and links

Scroll to Top