trustyai.model.Model

class trustyai.model.Model(fn, pandas=False, arrow=False)

Wrap any Python predictive model. TrustyAI uses the Model class to allow any Python predictive model to interface with the TrustyAI Java library.

__init__(fn, **kwargs)

Wrap the model as a TrustyAI PredictionProvider Java 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.predict functions of sklearn-style models meet this requirement.

Keyword Arguments:
  • dataframe_input: bool

    (default= False) Whether predict_fun expects a pandas.DataFrame as 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.

Methods

__init__(fn, **kwargs)

Wrap the model as a TrustyAI PredictionProvider Java class.

equals

hashCode

predictAsync(inputs)

Python implementation of the predictAsync() function with the TrustyAI PredictionProvider interface.

toString

Attributes

dataframe_input

Get dataframe_input kwarg value

disable_arrow

Get disable_arrow kwarg value

feature_names

Get feature_names kwarg value

output_names

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 TrustyAI PredictionProvider interface.

Parameters:
inputsList[PredictionInput]

A list of inputs.

Returns:
CompletableFuture

A Java CompletableFuture containing the model outputs.