trustyai.utils.tyrus.Tyrus

class trustyai.utils.tyrus.Tyrus(model, inputs: int | float | integer | inexact | ndarray | DataFrame | Series | List[Feature] | PredictionInput, outputs: int | float | integer | inexact | ndarray | DataFrame | Series | List[Output] | PredictionOutput, background: ndarray | DataFrame | List[PredictionInput], **kwargs)

The TrustyAI Assistant and Dashboard.

Tyrus is an all-in-one interface to explain and visualize a particular prediction, producing a Bokeh dashboard displaying a LIME, SHAP, and various counterfactual explanations`.

__init__(model, inputs: int | float | integer | inexact | ndarray | DataFrame | Series | List[Feature] | PredictionInput, outputs: int | float | integer | inexact | ndarray | DataFrame | Series | List[Output] | PredictionOutput, background: ndarray | DataFrame | List[PredictionInput], **kwargs)

Initialize the Tyrus TrustyAI assistant and dashboard.

Parameters:
modelPredictionProvider

The TrustyAI PredictionProvider, as generated by Model.

inputsint, float, numpy.number, List[Union[int, float, numpy.number]], numpy.ndarray, pandas.DataFrame, pandas.Series, List[Feature], or PredictionInput

The input features to the model, as a:

  • If there’s only a single input feature, an int, float, or any of the Numpy equivalents can be used.

  • A list of int, float, or any of the Numpy equivalents.

  • Numpy array of shape [1, n_features] or [n_features]

  • Pandas DataFrame with 1 row and n_features columns

  • Pandas Series with n_features rows

  • A List of TrustyAI Feature, as created by the feature() function

  • A TrustyAI PredictionInput

outputsint, float, numpy.number, List[Union[int, float, numpy.number]], numpy.ndarray, pandas.DataFrame, pandas.Series, List[Output], or PredictionOutput

The corresponding model outputs for the provided features, that is, outputs = model(input_features). These can take the form of a:

  • If there’s only a single output, an int, float, or any of the Numpy equivalents can be used.

  • A list of int, float, or any of the Numpy equivalents.

  • Numpy array of shape [1, n_outputs] or [n_outputs]

  • Pandas DataFrame with 1 row and n_outputs columns

  • Pandas Series with n_outputs rows

  • A List of TrustyAI Output, as created by the output() function

  • A TrustyAI PredictionOutput

backgroundnumpy.ndarray, pandas.DataFrame, List[PredictionInput]]

The set of background datapoints as a:

  • Numpy array of shape [n_rows, n_features]

  • Pandas DataFrame with n_rows rows and n_features columns

  • A list of TrustyAI PredictionInput

Keyword Arguments:
  • fraction_counterfactuals_to_displayfloat

    (default=`0.1`) The fraction of found byproduct counterfactuals to display in the dashboard, as a float between 0 and 1. Choose a larger number to see more, but this will make plot rendering more expensive.

  • notebookbool

    (default=`False`) If true, Tyrus will launch the visualizations inline in a Jupyter notebook. If false, the visualizations will be saved as HTML and opened automatically in your default browser.

  • filepathstr

    (default=`None`) If notebook==False, the Tyrus HTML will be generated in a temporary directory, the path of which can be accessed by Tyrus.filepath. Note that this temporary directory will be deleted when the Tyrus object is deleted/ goes out of scope. Passing a value to filepath will manually specify the location which to generate the Tyrus HTML file, which will remain there after execution is finished.

Methods

__init__(model, inputs, outputs, background, ...)

Initialize the Tyrus TrustyAI assistant and dashboard.

run([display])

Launch Tyrus TrustyAI Assistant and launch the dashboard.

run(display=True)

Launch Tyrus TrustyAI Assistant and launch the dashboard. Depending on the setting of tyrus.notebook and display, this will either automatically open the Tyrus visualizations in a Jupyter notebook or browser window.

Parameters:
display = Trueboolean

Whether to automatically display the dashboard (true) or simply return it (false).