trustyai.model.Model
- class trustyai.model.Model(fn, pandas=False, arrow=False)
Wrap any Python predictive model. TrustyAI uses the
Modelclass to allow any Python predictive model to interface with the TrustyAI Java library.- __init__(fn, **kwargs)
Wrap the model as a TrustyAI
PredictionProviderJava class.- Parameters:
- fnCallable[
pandas.DataFrame] or Callable[numpy.array] A function that takes in a Numpy array or Pandas DataFrame as input and outputs a Pandas DataFrame or Numpy array. In general, the
model.predictfunctions of sklearn-style models meet this requirement.- Keyword Arguments:
- dataframe_input: bool
(default=
False) Whether predict_fun expects apandas.DataFrameas input.
- feature_namesList[String]:
(default= ``None`) If the model receives a non-pandas input, you can specify the names of the model input features here, with the ith element of the list corresponding to the name of the ith feature.
- output_namesList[String]:
(default= ``None`) If the model outputs a non-pandas object, you can specify the names of the model outputs here, with the ith element of the list corresponding to the name of the ith output.
- disable_arrow: bool
(default= ``False`) If true, Apache Arrow will not be used to accelerate data transfer between Java and Python. If false, Arrow will be automatically used in situations where it is advantageous to do so.
- fnCallable[
Methods
__init__(fn, **kwargs)Wrap the model as a TrustyAI
PredictionProviderJava class.equalshashCodepredictAsync(inputs)Python implementation of the
predictAsync()function with the TrustyAIPredictionProviderinterface.toStringAttributes
Get dataframe_input kwarg value
Get disable_arrow kwarg value
Get feature_names kwarg value
Get output_names kwarg value
- class ArrowTransmission(model, paradigm_input: int | float | integer | inexact | ndarray | DataFrame | Series | List[Feature] | PredictionInput)
Context class to ensure all predictAsync calls within the context use arrow.
- Parameters:
- model: The TrustyAI :obj:`Model` or PredictionProvider
- paradigm_input: A single :obj:`PredictionInput` by which to establish the arrow schema.
All subsequent :obj:`PredictionInput`s communicated must have this schema.
- class NonArrowTransmission(model)
Context class to ensure all predictAsync calls within the context DO NOT use arrow.
- property dataframe_input
Get dataframe_input kwarg value
- property disable_arrow
Get disable_arrow kwarg value
- property feature_names
Get feature_names kwarg value
- property output_names
Get output_names kwarg value
- predictAsync(inputs: List[PredictionInput]) CompletableFuture
Python implementation of the
predictAsync()function with the TrustyAIPredictionProviderinterface.- Parameters:
- inputsList[
PredictionInput] A list of inputs.
- inputsList[
- Returns:
CompletableFutureA Java
CompletableFuturecontaining the model outputs.