Easy-to-use unsupervised spatial segmentation in Python.
A Python library for unsupervised clustering of n-dimensional datasets, designed for the segmentation of one-, two- and three-dimensional data in the field of geological modeling and geophysics. The library is based on the algorithm developed by Wang et al., 2017 and combines Hidden Markov Random Fields with Gaussian Mixture Models in a Bayesian inference framework. It currently supports one physical dimension and is in an early development stage, but we are working tirelessly on increasing its efficiency, ease of use and expanding the implementation to two and three physical dimensions.
(Above well log data used from machine learning contest of Hall, 2016)
You can try out how BaySeg segments 2D data sets by using an interactive Jupyter Notebook in your own web browser, enabled by Binder:
As the library is still in early development, the current way to install it is to clone this repository and then import it manually to your projects. We plan to provide convenient installation using PyPi in the future.
BaySeg depends on several genius components of the Python eco-system:
numpy
for efficient numerical implementationscikit-learn
for mixture modelsscipy
for its statistical functionalitymatplotlib
for plottingtqdm
provides convenient progress meters
First clone the repository using the command (or by manually downloading the zip file from the GitHub page)
git clone https://github.com/cgre-aachen/bayseg.git
then append the path to the repository:
import sys
sys.path.append("path/to/cloned/repository/bayseg")
to import the module:
import bayseg
Instantiate the classifier with the n-dimensional array storing the data and the number of labels:
clf = bayseg.BaySeg(data_ndarray, n_labels)
Then use the fit() method to classify your data with your desired number of iterations:
clf.fit(n_iter)
- Wang, H., Wellmann, J. F., Li, Z., Wang, X., & Liang, R. Y. (2017). A Segmentation Approach for Stochastic Geological Modeling Using Hidden Markov Random Fields. Mathematical Geosciences, 49(2), 145-177.
- Hall, B. (2016). Facies classification using machine learning. The Leading Edge, 35(10), 906-909.
The library is being developed by Alexander Schaaf and Hui Wang from the LuF Computational Geoscience and Reservoir Engineering (CGRE) and the Aachen Institute for Advanced Study in Computational Engineering Science (AICES) at RWTH Aachen University.