Hologram
A flexible interpolation library written in Rust, featuring Radial Basis Function (RBF) interpolation with support for multi-dimensional data.
Features
- RBF interpolation with many kernels to choose from.
- Normalisation/standardisation tools if necessary.
- Input and output datasets can be of type
Vec<X>andVec<Y>whereXandYcan be:f64[f64; 3]Vec<f64>- Your type if you implement
Numerictrait
- Dependency free unless handling larger datasets (use
openblasorintel-mklfeature) - Lagrangian interpolation with support for Chebyshev nodes (X:
Vec<f64>and Y:Vec<[f64; 3]>only)
Add to your project
Add the following to your Cargo.toml (remove features for lightweight option):
[]
= { = "0.1.0", = ["openblas"]} # or "intel-mkl"
Examples in Rust
Interpolating 1D data
Using the Hologram library to interpolate can be done as follows:
use ;
use PI;
Plotting against other Rbf implementations (scipy, numpy) and the expected values:
Interpolating 3D data
use ;
Plotting against the training data and expected values:
Implementing normalisation
Using the 3d problem from before we can normalise with z-score normalisation in two ways, explicitly:
// Normalise the data [Not necessary here, but demonstrating]
let = normalise_data;
let = normalise_data;
// Create RBF interpolator using thin-plate kernel
let rbf = new?;
// Normalise test input
let x_test_normalised = normalise_data_with;
// Predict
let y_pred_normalised = rbf.predict?;
// Denormalise output
let y_pred = denormalise_data;
Or implicitly with RbfNorm (Rbf wrapped in normalisation, for API convenience):
// Create RBF interpolator using thin-plate kernel
let rbf = new?;
// Predict
let y_pred = rbf.predict?;
Python implementation
The python implementation is available in the pyholo crate (see Github)
=
=
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.
License
MIT License - See LICENSE for details.