Skip to main content

akerbp.mlpet

Preprocessing tools for Petrophysics ML projects at Eureka

Installation

Install the package by running the following (requires Python 3.9 or later)

    pip install akerbp-mlpet

Quick start

For a short example of how to use the mlpet Dataset class for pre-processing data see below. Please refer to the tests folder of this repository for more examples as well as some examples of the settings.yaml file:

    import os
    from akerbp.mlpet import Dataset
    from akerbp.mlpet import utilities

    # Instantiate an empty dataset object using the example settings and mappings provided
    ds = Dataset(
            settings=os.path.abspath("settings.yaml"), # Absolute file paths are required
            folder_path=os.path.abspath(r"./"), # Absolute file paths are required
    )

    # Populate the dataset with data from a file (support for multiple file formats and direct cdf data collection exists)
    ds.load_from_pickle(r"data.pkl") # Absolute file paths are preferred

    # The original data will be kept in ds.df_original and will remain unchanged
    print(ds.df_original.head())

    # Split the data into train-validation sets
    df_train, df_test = utilities.train_test_split(
            df=ds.df_original,
            target_column=ds.label_column,
            id_column=ds.id_column,
            test_size=0.3,
    )

    # Preprocess the data for training according to default workflow
    # print(ds.default_preprocessing_workflow) <- Uncomment to see what the workflow does
    df_preprocessed = ds.preprocess(df_train)

The procedure will be exactly the same for any other dataset class. The only difference will be in the "settings". For a full list of possible settings keys see either the built documentation or the akerbp.mlpet.Dataset class docstring. Make sure that the curve names are consistent with those in the dataset.

The loaded data is NOT mapped at load time but rather at preprocessing time (i.e. when preprocess is called).

Due to the operations performed by certain preprocessing methods in akerbp.mlpet, the order in which the different preprocessing steps can sometimes be important for achieving the desired results. Below is a simple guide that should be followed for most use cases:

  1. Misrepresented missing data should always be handled first (using set_as_nan)
  2. This should then be followed by data cleaning methods (e.g. remove_outliers, remove_noise, remove_small_negative_values)
  3. Depending on your use case, once the data is clean you can then impute missing values (see imputers.py). Note however that some features depend on the presence of missing values to provide better estimates (e.g. calculate_VSH)
  4. Add new features (using methods from feature_engineering.py) or using process_wells from preprocessors.py if the features should be well specific.
  5. Fill missing values if any still exist or were created during step 4. (using fillna_with_fillers)
  6. Scale whichever features you want (using scale_curves from preprocessors.py). In some use cases this step could also come before step 5.
  7. Encode the GROUP & FORMATION column if you want to use it for training. (using encode_columns from preprocessors.py)
  8. Select or drop the specific features you want to keep for model training. (using select_columns or drop_columns from preprocessors.py)

NOTE: The dataset class drops all input columns that are not explicitly named in your settings.yaml or settings dictionary passed to the Dataset class at instantiation. This is to ensure that the data is not polluted with features that are not used. Therefore, if you have features that are being loaded into the Dataset class but are not being preprocessed, these need to be explicitly defined in your settings.yaml or settings dictionary under the keyword argument keep_columns.

API Documentation

Full API documentation of the package can be found under the docs folder once you have run the make html command.

For developers

This repository uses uv for dependency management.

  • create or update the local environment with all optional groups:

      uv sync --all-groups
    
  • run checks in the uv environment:

      uv run pytest
      uv run ruff check .
      uv run ruff format .
      uv run mypy --config-file pyproject.toml
    
  • to make the API documentation, from the root directory of the project run:

      cd docs/
      uv run make html
    
  • requirements.txt is generated from the lockfile; update it with:

      uv export --all-groups --no-hashes --no-editable --no-annotate --format requirements-txt --output-file requirements.txt
    
  • to install mlpet in editable mode in another environment, use:

      uv pip install -e /path/to/expres-ml-mlpet
      # or: pip install -e .
    

License

akerbp.mlpet Copyright 2021 AkerBP ASA

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Metadata

Release files for akerbp-mlpet 6.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for akerbp-mlpet 6.1.3
File Size Uploaded
akerbp_mlpet-6.1.3.tar.gz 64.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for akerbp-mlpet 6.1.3
File Interpreter ABI Platform
akerbp_mlpet-6.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 135.9 kB

Release files / akerbp_mlpet-6.1.3.tar.gz

Download URL akerbp_mlpet-6.1.3.tar.gz
Size 64.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8bf9d6a956fe64ddf0e5305622114bdec853b2bad1940135a24b9cb95c86ef97
BLAKE2b-256 checksum
How to use checksums
29ba4abbb698c4142e7f755de26d898cc5444450492ee3113e8e16198f59fec4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / akerbp_mlpet-6.1.3-py3-none-any.whl

Download URL akerbp_mlpet-6.1.3-py3-none-any.whl
Size 71.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
63cdcc948c3ef40310cedb0ea12c2d24581b14b8de087cfee286fbf47c0d6efc
BLAKE2b-256 checksum
How to use checksums
780064ee9eaa51b3b4928c84f11878be665d0eb4ef7848a169727e591fa5c059
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

6.1.3 This release

2 release files

6.1.2

2 release files

6.1.1

2 release files

6.1.0

2 release files

6.0.4

2 release files

6.0.3

2 release files

6.0.2

2 release files

6.0.1

2 release files

6.0.0

2 release files

5.1.0

2 release files

5.0.0

2 release files

4.1.0

2 release files

4.0.0

2 release files

3.5.4

2 release files

3.5.3

2 release files

3.5.2

2 release files

3.5.1

2 release files

3.5.0

2 release files

3.4.0

2 release files

3.3.5

2 release files

3.3.4

2 release files

3.3.3

3 release files

3.3.2

2 release files

3.3.1

2 release files

3.3.0

2 release files

3.2.2

2 release files

3.2.1

2 release files

3.2.0

2 release files

3.1.0

2 release files

3.0.0

2 release files

2.0.5

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page