Subsurface Syntax

Subsurface Syntax

k-Nearest Neighbors for Lithology Classification from Well Logs Using Python

Subdividing the Subsurface Based on Well Log Measurements

Andy McDonald's avatar
Andy McDonald
Nov 29, 2022
∙ Paid

Subdividing the Subsurface Based on Well Log Measurements

Photo by Johnson Wang on Unsplash

k-Nearest Neighbors (kNN) is a popular non-parametric supervised machine learning algorithm that can be applied to both classification and regression-based problems. It is easy to implement in Python and easy to understand which makes it a great algorithm to start learning about when you start your machine-learning journey.

Within this article, we will cover how the kNN algorithm works and how to apply it to well log data using Python’s Scikit-Learn library.

How does the kNN Algorithm Work?

Classifying data is one of the main applications of machine learning. As a result, there are numerous algorithms available. The kNN algorithm is just one of these.

The idea behind kNN is pretty simple. Points that are near each other are assumed to be similar.

When a new data point is introduced to a trained dataset the following steps occur

  1. Determine a value for k — the number of points to be used to classify new d…

Keep reading with a 7-day free trial

Subscribe to Subsurface Syntax to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2026 Andy McDonald · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture