In the machine-learning section of my 2024 paper I fitted glucose concentration to a photocurrent feature four ways: a first-order polynomial and a second-order polynomial, each solved with the normal equation and with gradient descent. The paper reports a final loss of 2.6463 for the first-order gradient-descent fit and 0.00069203 for the second-order one. This post is about what decides those numbers, and it comes with a piece of arithmetic that I did not do when I wrote the paper: how fast gradient descent can be expected to converge on a polynomial problem, and what that implies for how I would set up the next regression.
The setup in two paragraphs
The model is a polynomial in a single normalized feature derived from the photocurrent. For n = 1 it is a straight line, and for n = 2 it adds a squared term. The cost is the mean squared error, scaled by one half, and the theory section also writes down an L2 penalty. The features are normalized to the interval from 0 to 1 by subtracting the minimum and dividing by the range. The normal equation solves for the coefficients in one step, as Θ = (Xáµ€X)â»Â¹Xáµ€Y. Gradient descent reaches the same place by repeated small steps downhill, here with a learning rate of 0.04.
The test set has three concentrations, 108, 360 and 900 mg/dL. The plots use mmol/L, in which they sit at 6, 20 and 50. The axis label says normalized eigenvalues, which I read as the single normalized feature.
What the four fits show

All four fits follow the data at two of the three test concentrations. The point that separates the methods is the lowest one, at 108 mg/dL, where the fitted values deviate most from the target, and the paper discusses that deviation. I treat it as the most informative of the three, for a structural reason. The feature runs against concentration, so the largest normalized feature value, 1.0 by construction, belongs to the smallest concentration. The lowest test point sits at the edge of the feature range, and a glucose measurement is least forgiving exactly at the low end.
A polynomial is least constrained at the ends of its range, and a squared term bends the curve most sharply there. That is a property of the model class and not of any one data set, and it is the reason I now prefer a model that can be constrained at the edges. A monotonic constraint, or a bound on the output, restricts a model to the physically possible range, and I describe both in the post on gradient boosting.
How fast should gradient descent converge here?
The cost of a linear least-squares fit is a quadratic bowl. For that shape, gradient descent with step size α shrinks the error along each eigen-direction of the Hessian by a factor of (1 − α λ) per step, where λ is the corresponding eigenvalue. The direction with the smallest eigenvalue is the slowest. Whether a fixed budget of steps reaches the minimum depends on that smallest eigenvalue, and for polynomial features it can be very small.
Here is an illustrative calculation with stated assumptions. Suppose the normalized feature values are spread evenly over 0 to 1, and the cost is the mean squared error with the one-half convention, so that the Hessian is XᵀX divided by the number of points. For a first-order fit the columns are 1 and x. The two eigenvalues of that matrix are about 1.27 and 0.066, a ratio of 19. For a second-order fit with columns 1, x and x², the eigenvalues are about 1.41, 0.122 and 0.0027, a ratio of 524. That matrix is the 3 × 3 Hilbert matrix, a standard example of a badly conditioned problem.
Put in a learning rate of 0.04. In the first-order problem the slowest direction shrinks by a factor of 1 − 0.04 × 0.066 = 0.9974 per step, so about 1,750 steps cut the remaining error along it by a factor of 100. In the second-order problem the slowest direction shrinks by 1 − 0.04 × 0.0027 = 0.99989 per step, and cutting the error by a factor of 100 takes about 43,000 steps. After a budget of 2,000 steps, the slow direction would still retain about 80% of its initial error. My real feature values are not evenly spread, so the true numbers will differ, but the ratio of eigenvalues is a robust warning: a second-order gradient-descent fit with a modest step budget is likely to be stopped before it reaches the exact solution that the normal equation gives directly.
Stopping early is not simply a failure. Components along the small-eigenvalue directions are the ones that early stopping leaves near their starting values, so an unfinished fit behaves like a fit with a ridge penalty, which shrinks exactly those components. That is one reason two methods that solve the same convex problem can return different predictions at the edge of the range. It also means that the final loss of a gradient-descent run is a joint statement about the model, the learning rate and the number of steps. Comparing 2.6463 with 0.00069203 compares n = 1 and n = 2, and it compares two different degrees of convergence too.
Two changes would remove most of this effect. The first is to centre and rescale the feature to run from −1 to 1. That alone lowers the second-order ratio from 524 to about 14. The second is to use an orthogonal polynomial basis, such as Legendre polynomials, for which the Hessian of an evenly spread feature is diagonal with entries 1, 1/3 and 1/5, a ratio of 5. With a ratio of 5, a learning rate near 1 reaches the minimum in a few dozen steps, and the question of whether the optimizer finished goes away.
What three test points can and cannot compare
With three test concentrations, one point carries a third of the evidence. The choice between n = 1 and n = 2 is therefore a statement about three numbers, and the paper’s observation that the second-order fit improved the higher test point while the deviation at the lowest point grew is the right thing to report. What it cannot do is rank the two models with confidence. The training loss does not help either. A drop in loss by a factor of about 3,800, from adding one coefficient, tells you that the model can reproduce its own training data far better, and it says nothing about the point it has not seen.
The design I would use next is leave-one-concentration-out validation. With a small number of distinct concentrations, hold each one out in turn, fit on the rest and report every held-out error in mg/dL. That uses all the data, shows which concentrations are hard, and replaces one split by a complete picture. A related detail is the normalization. If the minimum and the range come from the whole data set, information from the held-out points leaks into the training step, so the normalization should be computed from the training concentrations only and then applied to the held-out ones.
Calibrating in the direction the physics runs
The paper shows the fitted angle rising linearly with concentration, and I measured that out to 1080 mg/dL. The physics runs from concentration to signal, so the statistically natural model fits the signal as a function of concentration and then inverts the line. That is classical calibration. Regressing concentration directly on a noisy measured feature, which is the inverse calibration I used, shrinks the slope toward zero when the feature is noisy, because the noise sits in the variable on the right-hand side. Prepared solutions have concentrations known far more accurately than any photocurrent feature, which is the situation in which classical calibration is the cleaner choice. The two approaches differ most at the edges of the range, so comparing them is a diagnostic in its own right, and it is cheap, because both can be computed from the same data.
A short recipe for the next round
Report errors in the unit that matters. A loss of 0.00069203 means little to someone who wants to know how many mg/dL the prediction is off by, and the paper’s plots in mmol/L are easy to convert, since 1 mmol/L is about 18 mg/dL. For a model with two or three coefficients, the normal equation is exact and instant, and it removes the learning rate and the stopping point from the comparison. If gradient descent is used, it should be on a well-conditioned basis, with the step budget and the final gradient norm reported. For a bounded quantity like concentration, the model’s output should be checked against the physical range, and a prediction outside it should be treated as a signal to constrain the model.
Where this went
The 2026 paper replaces polynomial regression with gradient boosting, and I wrote about how to read its error numbers in a companion post. What carried over from the 2024 regression is the attention to validation: how the data are split decides what a result means. The other lesson is that a falling loss curve tells you the optimizer is working, which is a different question from whether the model works.
All of this concerns glucose solutions in a laboratory setup. I draw no conclusions here about anything beyond that.
Sources and links
- Paper: Kopp, M. B. (2024). Flexible nanomaterial sensors for non-invasive health monitoring. Applied and Computational Engineering, 72(1), 45–58. doi.org/10.54254/2755-2721/72/20240981 (open access, CC BY 4.0).
- Google Scholar and GitHub; project repository gese-glucose-biosensor.
- Related posts: gradient boosting on a glucose photocurrent signal, building a GeSe photodetector on PET, polarizer-free polarimetry versus bench instruments.