Runtime API of treelite Python package.
Runtime API provides the minimum necessary tools to deploy tree prediction modules in the wild.
treelite.runtime.
Predictor
(libpath, nthread=None, verbose=False, include_master_thread=True)¶Predictor class: loader for compiled shared libraries
Parameters: |
|
---|
predict
(batch, verbose=False, pred_margin=False)¶Make prediction using a batch of data rows (synchronously). This will internally split workload among worker threads.
Parameters: |
---|
treelite.runtime.
Batch
¶Batch of rows to be used for prediction
from_csr
(csr, rbegin=None, rend=None)¶Get a sparse batch from a subset of rows in a CSR (Compressed Sparse Row)
matrix. The subset is given by the range [rbegin, rend)
.
Parameters: |
|
---|---|
Returns: | sparse_batch – a sparse batch consisting of rows |
Return type: |
from_npy2d
(mat, rbegin=0, rend=None, missing=None)¶Get a dense batch from a 2D numpy matrix.
If mat
does not have order='C'
(also known as row-major) or is not
contiguous, a temporary copy will be made.
If mat
does not have dtype=numpy.float32
, a temporary copy will be
made also.
Thus, as many as two temporary copies of data can be made. One should set
input layout and type judiciously to conserve memory.
Parameters: |
|
---|---|
Returns: | dense_batch – a dense batch consisting of rows |
Return type: |