Skip to main content

Python bindings to the TrustyAI explainability library.

Project description

version Tests

python-trustyai

Python bindings to TrustyAI's explainability library.

Setup

PyPi

Install from PyPi with

pip install trustyai

Local

The minimum dependencies can be installed with

pip install -r requirements.txt

If running the examples or developing, also install the development dependencies:

pip install -r requirements-dev.txt

Docker

Alternatively create a container image and run it using

$ docker build -f Dockerfile -t ruivieira/python-trustyai:latest .
$ docker run --rm -it -p 8888:8888 ruivieira/python-trustyai:latest

The Jupyter server will be available at localhost:8888.

Binder

You can also run the example Jupyter notebooks using mybinder.org: Binder

Documentation

Check out the ReadTheDocs page for API references and examples.

Getting started

To initialise, import the module and initialise it. For instance,

import trustyai

trustyai.init()

If the dependencies are not in the default dep sub-directory, or you want to use a custom classpath you can specify it with:

import trustyai

trustyai.init(path="/foo/bar/explainability-core-2.0.0-SNAPSHOT.jar")

In order to get all the project's dependencies, the script deps.sh can be run and dependencies will be stored locally under ./dep.

This needs to be the very first call, before any other call to TrustyAI methods. After this, we can call all other methods, as shown in the examples.

Writing your model in Python

To code a model in Python you need to write it a function with takes a Python list of PredictionInput and returns a ( Python) list of PredictionOutput.

This function will then be passed as an argument to the Python PredictionProvider which will take care of wrapping it in a Java CompletableFuture for you. For instance,

from trustyai.model import Model


def myModelFunction(inputs):
    # do something with the inputs
    output = [predictionOutput1, predictionOutput2]
    return output


model = Model(myModelFunction)

inputs = [predictionInput1, predictionInput2]

prediction = model.predictAsync(inputs).get()

You can see the sumSkipModel in the LIME tests.

Examples

You can look at the tests for working examples.

There are also Jupyter notebooks available.

Contributing

To install trustyai for local development, use:

$ cd scripts
$ ./build.sh

This will compile the necessary Java libraries and install the TrustyAI Python package, locally.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trustyai-0.2.9.tar.gz (18.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trustyai-0.2.9-py3-none-any.whl (18.5 MB view details)

Uploaded Python 3

File details

Details for the file trustyai-0.2.9.tar.gz.

File metadata

  • Download URL: trustyai-0.2.9.tar.gz
  • Upload date:
  • Size: 18.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.2

File hashes

Hashes for trustyai-0.2.9.tar.gz
Algorithm Hash digest
SHA256 112553ad1d3a3d86fc631443b11ac5118c0828129b47cbe120012dbbc549405e
MD5 b7a3be5a838dc107f0db8be62437fc7c
BLAKE2b-256 6fddbd7cb07d6d2a931f250695ee0aab41ba719b7b6a531dd6811b15d29c900c

See more details on using hashes here.

File details

Details for the file trustyai-0.2.9-py3-none-any.whl.

File metadata

  • Download URL: trustyai-0.2.9-py3-none-any.whl
  • Upload date:
  • Size: 18.5 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.2

File hashes

Hashes for trustyai-0.2.9-py3-none-any.whl
Algorithm Hash digest
SHA256 64917f61c275fb257add6269eb0ea05187c2d92d7f92bbb0a1d9298029785a69
MD5 87aea49172fc1a0216a8e3c3677ededd
BLAKE2b-256 f6100dea9d012c474ab6de32987677399834a4594a415f5d40e3705a6bdb9b2a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page