Struct treerite::Predictor [−][src]
pub struct Predictor { /* fields omitted */ }
Expand description
Loader for compiled shared libraries.
There should be at most only one thread calling predict_batch
at the same time.
As the result, Predictor is Send but not Sync.
Implementations
Load the compiled shared libraries from a filesystem location.
Parameters
-
library_path: location of dynamic shared library (.dll/.so/.dylib)
-
num_worker_thread: number of worker threads to use; if unspecified, use maximum number of hardware threads.
Example
use treerite::Predictor;
let model = Predictor::load("examples/iris.so", 1).unwrap();
Perform batch prediction with a 2D sparse data matrix. Worker threads will internally divide up work for batch prediction.
Example
use treerite::{Predictor, DMatrix};
use ndarray::Array2;
let model = Predictor::load("examples/iris.so", 1).unwrap();
let feat: Vec<f64> = vec![7.7, 2.8, 6.7, 2.];
let pred: Array2<f64> = model.predict_batch(&DMatrix::from_slice(&feat).unwrap(), false, false).unwrap();
Note
The output array should be explicitly typed, i.e. f64 or f32.
Get the output type of the leaves.
Get how many classes this model output
Get the output result size (num instances x num classes) given a DMatrix
Get the number of features this model required
Get the global bias of the model
Get the sigmoid alpha of the model