Linear and Logistic Models for Continuous and Discrete Targets
Learning objectives
- Fit a linear model to predict porosity from well logs by least squares, by the normal equations and by gradient descent, and read its error as an RMSE and an R-squared
- Explain why Ogbon-1's four porosity logs together predict porosity far better than density alone
- Fit a logistic model for the probability of pay, read the sign of each weight, and turn the probability into a call with a threshold
- Explain why pay needs resistivity: gamma ray finds clean sand but not its oil
Two Models from One Sum
A linear model predicts a number as a weighted sum of the inputs; a logistic model passes the same kind of sum through the sigmoid to give a probability, and a threshold turns that probability into a call. On Ogbon-1 the four porosity logs predict porosity to 0.016 v/v, an of 0.950, where density alone manages 0.403. Pay from gamma ray and log10 RT is called right at 0.990 of the well's samples at a threshold of 0.50, and its weights say what a petrophysicist reads by eye: pay falls with gamma ray and rises with resistivity. On gamma ray alone it is called right at only 0.779, because gamma ray finds clean sand and cannot tell its oil from its water.
The Data
Every model in this section is fitted to Ogbon-1, the Petrophysics book's well, as the book's own learning set holds it: 1201 samples from 5800 ft to 6400 ft, every 0.5 ft, its logs recorded by the book's own tool model, which averages a few feet of rock and adds a stated noise. The whole set is synthetic, and that is why it can be checked: porosity is the generator's truth, and pay is the Petrophysics book's net-pay rule applied to that truth, shale volume at most 0.40, porosity at least 0.08 and water saturation at most 0.50. Ogbon-1 holds 277.0 ft of pay. Both models are fitted on standardized logs (each log less its mean, over its standard deviation), and their weights are then written back in the logs' own units.
Linear Regression: Porosity from the Logs
A linear model predicts . Least squares chooses the intercept and the weights that make the mean squared error smallest. Setting its gradient to zero gives the normal equations, , with the logs and a column of ones: one solve, no iterations. Its error is read as the root mean squared error (RMSE), in the target's own unit, and as , the share of the target's variance the model explains.
On density alone the fitted line is β0.441 v/v per g/cc, and its error is 0.056 v/v, an of 0.403. One straight line from density to porosity assumes one grain density, and Ogbon-1 has three rocks: the limestone is denser grain for grain than the sand, and the shale's density says little about its porosity. Gamma ray, density, neutron and sonic together tell the model which rock it is in, and the error falls to 0.016 v/v, an of 0.950.
Gradient descent reaches the same answer step by step, , from zero weights. The figure takes half the rate at which it would diverge, 0.166 for the four logs: the error is 0.181 v/v before the first step and 0.0164 v/v after 100 epochs, against the normal equations' 0.0163 v/v. It never goes below that number, which is the least squares minimum. On density alone, a single standardized log, the same rule gives a rate of 0.500 and the first step lands on the answer.
Logistic Regression: the Probability of Pay
A logistic model gives the probability of the class, , through the sigmoid , which takes any score to a number between 0 and 1. It is fitted by minimising the mean log loss, , here by Newton's method, with a small ridge of 0.0001 on the weights so that a nearly separable well cannot drive them to infinity.
On Ogbon-1, from gamma ray and log10 RT, the standardized weights are β5.13 on gamma ray and +8.75 on log10 RT; written in the logs' units they are β0.120 per API and +11.940 per decade of resistivity. The signs are the geology. Clean rock reads low gamma ray, so pay falls with it; oil is resistive and brine conducts, so pay rises with resistivity. Resistivity is worked in log10 because it spans decades and a decade is what changes from water to oil.
The Threshold
A probability is not yet a call. A sample is called pay when its probability is at least a threshold , which is where its score passes , the logit of : a straight line on the crossplot of gamma ray against log10 RT, its slope set by the weights and its place by the threshold. At 0.50 the model calls 0.990 of the samples right, missing 2.0 ft of pay and calling 4.0 ft pay that is not. Its mistakes sit where the truth itself changes: at the base of the main sand's pay, where the water saturation crosses the cutoff, and at the edges of beds, where the tool averages two rocks. At 0.10 it calls pay freely, 0.0 ft missed and 11.5 ft false; at 0.90 it calls pay rarely, 13.0 ft missed and 0.0 ft false. Which mistake costs more, a missed zone or a completion in wet rock, is the geologist's to say, not the model's.
Why Pay Needs Resistivity
On gamma ray alone the line is upright, at 45 API, and the model calls 108.0 ft of Ogbon-1 pay that is not, all of it wet sand: the lower main sand, as clean as the oil sand above it and too wet to be pay. Only 0.779 of the samples are called right. Gamma ray measures clay, not fluid, so the oil sand and the wet sand beneath it read the same. Resistivity sees the oil, and with it the model separates the two sands. The figure's exercises walk each of these cases.
What These Scores Are
Every score in this section is on the samples the model was fitted to, on one well. That flatters a model: a fair score asks it about rock it has not seen, and the book's later chapters score its models on the field's other wells, one well held out at a time.