Feature Engineering and Encoding for Geoscience Variables

Chapter 9, Engineering Features from Geoscience Data

Learning objectives

  • Explain why a feature's units are its weight in a distance, and standardize each feature on the training wells alone
  • Explain why resistivity is given to a model in log10, and which models gain from it
  • Explain why a tree makes the same calls on raw RT and on log10 RT
  • Read what depth adds to the logs when every well is held out in turn

What a Model Is Given

A model sees only the numbers it is given. A distance adds the features' squared differences, so their units are its weights: standardize each feature on the training wells alone and each gets one vote. Then the transform decides what that vote sees. Held out one well at a time, kNN calls 0.873 of the nine wells' 10809 samples right from the porosity logs, 0.932 with raw resistivity and 0.976 with log10 RT: resistivity in decades separates oil from brine, where ohm.m spends its range on the differences between one oil sand and another. A tree makes the same calls on either form, 0.975, because a split only orders the samples.

Scaling And TransformsInteractive figure, enable JavaScript to interact.

The Data

Every score in this section is from the book's own learning set, synthetic by construction: Ogbon-1, the Petrophysics book's well, and Ogbon-2 to Ogbon-9, the book's own hypothetical appraisal wells, 1201 samples each, logged by the book's own tool model, with pay by the Petrophysics book's net-pay rule on the generator's truth. Each well is called by a model fitted on the other eight, and the calls are pooled; calling every sample its larger class would score 0.524. The four feature sets are the book's: A, the porosity logs (gamma ray, density, neutron and sonic); A + RT, those and raw resistivity in ohm.m; B, those and log10 RT; and B + depth.

Units Are Weights

kNN calls a sample by the samples nearest to it, and its distance is d2=∑j(xj−xj′)2d^2 = \sum_j (x_j - x'_j)^2. Between two samples drawn at random its expected value is twice the sum of the features' variances, so a feature weighs in by its variance, which is set by its unit. On the eight wells that train the fold holding out Ogbon-8, depth in feet carries 0.946 of a distance, gamma ray in API 0.049, sonic 0.004, and density, neutron and log10 RT under 0.001 between them: kNN on raw units is nearly kNN on depth. What that gives is an accident of the units. The book's kernel gives, unscaled and every well held out, 0.932 with log10 RT (its decades weigh nothing beside gamma ray's API), 0.971 with raw RT (its ohm.m happen to weigh about as much as gamma ray) and 0.992 with depth, the best score in the chapter, because in this field one level oil-water contact makes depth say which side of it a sample is on, and gamma ray which rock. None of these weights was chosen.

Standardize on the Training Wells

A standardized feature is zj=(xj−μj)/σjz_j = (x_j - \mu_j)/\sigma_j, unitless, its mean and standard deviation taken from the training wells and applied unchanged to the held-out well. Every feature then carries one share of a distance, a choice made on purpose, and the weights can be changed on purpose too. The scaler must not see the held-out well. With Ogbon-8 held out the eight training wells' mean depth is 5987.1 ft, against 6053.5 ft on all nine, and their mean log10 RT 0.967 against 0.876: Ogbon-8, deep and wet, would pull both. Here the leak is small: the book's kernel gives the same 10545 samples right with log10 RT when the scaler is fitted on all nine wells, two calls changed. The rule is not about this set. A well that differs more, or a transform that reads the labels, leaks more, and a score is only honest when nothing of the held-out well reaches the model before it is scored.

Resistivity in Decades

Raw resistivity is skewed: its skewness over the nine wells is 2.35, against 0.35 in log10. The median pay sample reads 21.8 ohm.m and the median of the other rock 2.12 ohm.m, a factor of ten, yet standardized raw their medians lie only 0.46 standard deviations apart, while a pay sample at 200 ohm.m sits several standard deviations from pay at 20. In log10 the same medians lie 1.56 standard deviations apart: a decade is what changes from brine to oil, and log10 makes a decade one step. Held out one well at a time, log10 RT buys kNN 0.043 (10075 samples right to 10545), logistic regression 0.109 (0.877 to 0.986) and Gaussian naive Bayes 0.080 (0.857 to 0.937). Logistic regression adds weighted features, so its boundary between pay and the rest is flat in what it is given; naive Bayes fits a bell curve to each class, which raw RT is not.

What a Tree Ignores

A tree of depth 6, the table's best on set B, calls 0.975 right with raw RT and 0.975 with log10 RT: the same 10539 samples. A split asks only whether a value is above a threshold, and log10 keeps the samples in order, so every split on raw RT has a twin on log10 RT that sends the same samples each way. Any transform that keeps the order, and any scaling, leaves a tree's calls where they were. A tree is the model to reach for when the features' units and shapes are not to be trusted; its price is the step it draws at every split.

Depth

Standardized beside the porosity logs and log10 RT, depth adds almost nothing held out: kNN 0.976 with and without it, logistic regression 0.986, a tree 0.978 against 0.975; naive Bayes gains most, 0.937 to 0.958. With the logs present, depth repeats what they already say. Alone it is another matter: Section 9.2 learns pay from depth on Ogbon-1 and asks the other eight wells.

Encoding a Category

A category, such as a sample's lithology, enters a model as one column per class, a 1 in its own and 0 in the others (one-hot encoding): a sandstone sample of the three lithologies is (0, 1, 0). Numbering the classes 0, 1 and 2 instead would tell a distance or a weighted sum that limestone is twice as far from shale as sandstone is, an order the rocks do not have. In this book lithology is a label to learn, not a feature, so no figure here encodes one.

What These Scores Are

The scores in (c) are on wells the model never saw, read from the book's cross-validation table. Chapter 9 keeps to that one split, every well held out in turn; Chapter 10 compares the ways of splitting the samples and measures how much a split that keeps neighbouring samples on both sides flatters.

This page is prerendered for SEO and accessibility. The interactive widgets above hydrate on JavaScript load.