Skip to main content

PyHolo

Build & Test License: MIT

Python bindings for flexible interpolation library featuring Radial Basis Function (RBF) written in rust. It features:

  • RBF interpolation with many kernels to choose from.
  • Flexible Data Types: Supports input and output datasets of type float, list[float], ndarray.

Installation

pip install pyholo

For optimal performance, it's recommended to use a virtual environment.

Quick Start

1D Interpolation of a target function

import numpy as np
import pyholo as holo

def target_function(pts):
    return 10.0 + np.sum(
        np.power(pts, 2) + 10.0 * np.cos(2.0 * np.pi * pts)
    )

# Get or set input/output data
x_train = np.linspace(-5.0, 5.0, 50)
y_train = np.array([target_function(x) for x in x_train])

# Get predictions from each model
pyholo_pred = holo.Rbf(x_train, y_train, "gaussian", 1.0)

# Points to predict at
x_new = np.linspace(-5.0, 5.0, 500)

# Make predictions
y_pred = pyholo_pred.predict(x_new)

Plotting against other Rbf implementations (scipy, numpy) and the expected values:

3D interpolation of data

import numpy as np
import pyholo as holo

# Training data
x_train = np.array([
    0.000, 512.000, 1182.490, 1911.273, 2788.547, 
    4227.750, 6481.706, 9609.367, 11773.210, 
    13188.649, 14400.000
])

y_train = np.array([
    [6950.000, 0.000, 0.000],
    [5930.999, 4386.866, 974.859],
    [2498.780, 8537.536, 1897.230],
    [-1993.234, 10819.437, 2404.319],
    [-7051.251, 11465.688, 2547.931],
    [-13549.361, 9748.529, 2166.340],
    [-19093.612, 3887.659, 863.924],
    [-18104.032, -5716.279, -1270.284],
    [-11425.229, -10664.783, -2369.952],
    [-4206.775, -11312.308, -2513.846],
    [3167.219, -7987.115, -1774.914],
])

# Create and fit RBF model
rbf = holo.Rbf(x_train, y_train, kernel='thin_plate_spline', epsilon=1.0)

# Predict on test points
x_test = np.linspace(x_train.min(), x_train.max(), 200)
y_pred = rbf.predict(x_test)

Plotting against the training data and expected values:

Comparison with other Rbf implementations

Using the hologram linear solver only, as haven't quite figured out how to configure Openblas or Mkl with Pyo3. Help here is appreciated. Simple 1d problem from before benchmarks quite well.

Build python from source

These instructions assume that Python3 and Cargo are installed on your system. To set up this project, follow these steps:

  1. Clone the repository:
    git clone https://github.com/alexlovric/gmac.git
    cd gmac/gmac_py
    
  2. Create a virtual environment and install build system:
    python3 -m venv .venv
    source .venv/bin/activate # In windows /Scripts/activate
    python3 -m pip install -r requirements.txt
    
  3. Build the release binary:
    maturin develop --release
    
  4. Build the python wheel:
    maturin build --release
    
  5. Running benchmarks/examples:
    python3 -m pip install <path to wheel (target/wheels/*.whl)>
    cd benches
    python3 -m pip install -r requirements.txt
    

License

MIT License - See LICENSE for details.

Metadata

Release files for pyholo 0.1.8

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

Built distributions (wheels)

Table of built distributions (wheels) for pyholo 0.1.8
File Interpreter ABI Platform
pyholo-0.1.8-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details
pyholo-0.1.8-cp38-abi3-manylinux_2_34_x86_64.whl CPython 3.8 abi3 Linux glibc 2.34+ x86-64 Details
pyholo-0.1.8-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details

Total release size: 765.2 kB

Release files / pyholo-0.1.8-cp38-abi3-win_amd64.whl

Download URL pyholo-0.1.8-cp38-abi3-win_amd64.whl
Size 200.5 kB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
d03736c62c843a66143afa9eff0e9ac62913542c1a4ef8f19c1eefeaa88fe2b1
BLAKE2b-256 checksum
How to use checksums
49ea1e2ec099416f41769f2ff63b3cf29eb6f9f6c3cbcd518b22a621ba53f4c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.9.0

Release files / pyholo-0.1.8-cp38-abi3-manylinux_2_34_x86_64.whl

Download URL pyholo-0.1.8-cp38-abi3-manylinux_2_34_x86_64.whl
Size 305.0 kB
Tags CPython 3.8 Linux glibc 2.34+ x86-64 abi3
SHA-256 checksum
How to use checksums
460f72609ed90de8e3ceb864ba4ea2b1f93ef1ea43a1bbd53c47125a8755587c
BLAKE2b-256 checksum
How to use checksums
ad21b88c63d19b80f4cc5f433babc97cbf1488247620220f0b1626b19d88360e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.9.0

Release files / pyholo-0.1.8-cp38-abi3-macosx_11_0_arm64.whl

Download URL pyholo-0.1.8-cp38-abi3-macosx_11_0_arm64.whl
Size 259.6 kB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8313f977f0b91ef151cf30b91867cd7cc193ae1144606058c7566dc61ce18deb
BLAKE2b-256 checksum
How to use checksums
5a7c0a38dda8c2d206f890e7f5fc7fd606fda57b72fc4d3fd2c2b1ffff5ea251
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.9.0

Release history Release notifications | RSS feed

This release

0.1.8 This release

3 release files

0.1.7

3 release files

0.1.6

3 release files

0.1.5

3 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