KMeans Clustering

This application lets users cluster data stored on Geoscience ANALYST objects using the Scikit-Learn.KMeans clustering algorithm. Leveraging Plotly visualization tools, users are able to assess the clustering results using histogram, box, scatter, inertia and cross-correlation plots.

New user? Visit the Getting Started page.

59f6230797c348aa8380e5ae86c171a1

Project Selection

Select and connect to an existing geoh5 or ui.json project file containing data.

af445853207e4c33bdd00ce76ef2b79d

See the Project Panel page for more details.

Object and Data Selection

The Object dropdown contains a list of objects available from the target geoh5 project. Only the data selected in the Data subset dropdown are used in the clustering routine.

84f304b86d5d4c55b6804e73626a87a9

10b8d921a220461c983d10738be840b3

Downsampling

Reduce the points displayed on the clustering plots to a percentage of the original amount, with a maximum of 5000 points.

f166a3eb07d244aea6503b46d67a5674

Clustering

Select the number of clusters (groups) desired.

c8f2d213f4624ccbb4b373698eaddd98

By default, the application will run KMeans for 2, 4, 8, 16 and 32 groups in order to draw a meaningful Inertia Curve

Clusters Color

Check the Select cluster color checkbox to display a colorpicker that can be used to assign a specific color to a given cluster group.

8bee8ad14a7f4adeb4758b1c74bdf2e9

Analytics

Plotting options to analyze the selected data and KMeans clusters. The default displayed plots are the Crossplot and Inertia Plot. Use the Show Analytics & Normalization checkbox to display the Histogram, Boxplot, Statistics, and Confusion Matrix.

Crossplot

See the Scatter Plot documentation for details.

[1]:
import plotly.io as io
import plotly.graph_objects as go

go.FigureWidget(io.read_json("./images/cluster/cluster_scatter.json"))

By default, the color values displayed correspond to the cluster groups.

Statistics

Display statistics for the chosen data channels using pandas.DataFrame.describe.

53c336eca06143da8d73e8f12e319ee8

Confusion Matrix

Display the confusion matrix for the chosen data channels.

[2]:
import plotly.io as io
import plotly.graph_objects as go

go.FigureWidget(io.read_json("./images/cluster/cluster_matrix.json"))

Histograms

Display histograms for each data field.

[3]:
import plotly.io as io
import plotly.graph_objects as go

go.FigureWidget(io.read_json("./images/cluster/cluster_hist.json"))

By default, all fields are normalized between [0, 1].

Scale

Option to increase the weight of a specific data field.

5307d2e61e7c444c92c0a0001b48c8fb

Upper Bound

Upper bound (maximum) value used for the KMeans clustering.

3eadca936a79421585773c7c316abe9e

Lower Bound

Lower bound (minimum) value used for the KMeans clustering.

0d2510c9ea304645baf8ed3e10e558eb

Inertia

Display the cluster’s inertia, or sum squares of distances between each sample to the center of its cluster group. The optimal number of clusters is generally thought to be at the point of maximum curvature.

[4]:
import plotly.io as io
import plotly.graph_objects as go

go.FigureWidget(io.read_json("./images/cluster/cluster_inertia.json"))

Boxplot

Display boxplots describing the range of values within each cluster for a chosen data field.

[5]:
from IPython.display import IFrame
IFrame(src='./images/cluster/cluster_boxplot.html', width=700, height=650)
import plotly.io as io
import plotly.graph_objects as go

go.FigureWidget(io.read_json("./images/cluster/cluster_boxplot.json"))

Output panel

Clusters can be exported directly to the target object by clicking on the Export button. This can yield two possible outcomes:

  • If cluster data with the same name exists on the object, a new data field is created.

  • If a data field with the same name is found on the target object, values are replaced. This allows users to quickly experiment with different numbers of clusters without having to delete previous trials.

e7ca14d3f13c4c619f2605f0c37719d8