Skip to main content

Lightweight Gaussian Process regression library

Project description

gplite

A lightweight Gaussian Process regression library built on NumPy and SciPy, originally designed for delta machine learning in computational chemistry.

Features

  • Gaussian Process regression with automatic hyperparameter optimization
  • Multiple kernels: RBF, Matérn, Periodic, Constant (combinable via + and *)
  • Active learning with multiple selection strategies (uncertainty, MAE, expected improvement)
  • Model saving and loading with pickle
  • Anisotropic kernels (support for per-dimension hyperparameters)
  • String export for integration with external tools

Installation

pip install gplite

or for optional dependencies to run the example files

pip install "gplite[examples]"

Quick Start (more detailed examples can be found here)

Gaussian Process Regression

import numpy as np
from gplite import GaussianProcess, RBFKernel

X_train = np.linspace(0, 10, 20).reshape(-1, 1)
y_train = np.sin(X_train).ravel() + 0.1 * np.random.randn(20)

kernel = RBFKernel(length_scale=1.0)
gp = GaussianProcess(kernel)
gp.fit(X_train, y_train, optimize=True)

X_test = np.linspace(0, 10, 100).reshape(-1, 1)
y_mean, y_std = gp.predict(X_test, return_std=True)

Matérn Kernel

from gplite import MaternKernel

# Matérn 5/2 (twice differentiable, default)
kernel = MaternKernel(length_scale=1.0, nu=2.5)

# Matérn 3/2 (once differentiable, rougher functions)
kernel = MaternKernel(length_scale=1.0, nu=1.5)

Combining Kernels

from gplite import RBFKernel, PeriodicKernel, ConstantKernel
import numpy as np

# additive: smooth trend + periodic pattern
kernel = RBFKernel(length_scale=2.0) + PeriodicKernel(length_scale=1.0, period=2*np.pi)

# product: scaled periodic
kernel = ConstantKernel(constant=2.0) * PeriodicKernel(length_scale=1.0, period=2*np.pi)

Anisotropic Kernels

from gplite import RBFKernel

# separate length scale per input dimension
kernel = RBFKernel(length_scale=[1.0, 5.0, 0.5], isotropic=False)

Active Learning

from gplite import ActiveLearner, PeriodicKernel
import numpy as np

X_full = np.linspace(0, 2*np.pi, 100).reshape(-1, 1)
y_full = np.sin(X_full).ravel()

kernel = PeriodicKernel(length_scale=1.0, period=2*np.pi)
learner = ActiveLearner(
    kernel=kernel,
    x_full=X_full,
    y_full=y_full,
    rmse_threshold=0.1,
    max_points=50
)

learner.learn(learning_strategy="uncertainty")
y_pred = learner.gp.predict(X_full)

Save and Load

# save a fitted model
gp.save("model.pkl")

# load it back
from gplite import GaussianProcess
gp_loaded = GaussianProcess.load("model.pkl")
y_pred = gp_loaded.predict(X_test)

String Export

expression = gp.to_str(variable_names=["x"])

Modules

Requirements

  • Python >= 3.10
  • NumPy >= 2.2
  • SciPy >= 1.15

License

GPLv3

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gplite-2.1.3.tar.gz (68.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gplite-2.1.3-py3-none-any.whl (77.5 kB view details)

Uploaded Python 3

File details

Details for the file gplite-2.1.3.tar.gz.

File metadata

  • Download URL: gplite-2.1.3.tar.gz
  • Upload date:
  • Size: 68.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for gplite-2.1.3.tar.gz
Algorithm Hash digest
SHA256 c38d0d49726e672f42fa97b340a33c0a103721eb6a4c3fcc7c09fe5e0725749d
MD5 f2f0c2da4400e4b9d17dcd7d4b07ddf1
BLAKE2b-256 204f965cf564d507f7aeb76e81f7f5a5cbdb723239127758a719ccd3ed53a58d

See more details on using hashes here.

File details

Details for the file gplite-2.1.3-py3-none-any.whl.

File metadata

  • Download URL: gplite-2.1.3-py3-none-any.whl
  • Upload date:
  • Size: 77.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for gplite-2.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e8e26432e108863c262c5efa8b2bf50d6ed8e00e2d348b45a4ed3dd6726d4aa4
MD5 fb61178be3d3cbcf08b9957e88c3388d
BLAKE2b-256 9f2f8ad5ddcc9fc31c9de122fb007582bd3aa9867b55e896df80784fbd7b31ec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page