Skip to main content

Library for evaluating and deploying human readable machine learning explanations.

Project description

“DAI-Lab” An open source project from Data to AI Lab at MIT.

PyPI Shield PyPI - Python Version PyPI - Downloads Build Action Status Static Badge

Pyreal

An easier approach to understanding your model's predictions.

Important Links
:book: Documentation Quickstarts and user guides
:memo: API Reference Full library API
:apple: Tutorials Notebooks with example usage
:scroll: License This repository is published under the MIT License
:computer: Project Homepage Check out the Sibyl project website for more information

Overview

Pyreal gives you easy-to-understand explanations of your machine learning models in a low-code manner. Pyreal wraps full ML pipelines in a RealApp object that makes it easy to use, understand, and interact with your ML model — regardless of your ML expertise.

See our tutorial series for an example of using Pyreal for house-price prediction:

Install

Requirements

Pyreal has been developed and tested on Python 3.9, 3.10, and 3.11 The library uses Poetry for package management.

Install from PyPI

We recommend using pip in order to install Pyreal:

pip install pyreal

This will pull and install the latest stable release from PyPI.

Install from source

If you do not have poetry installed, please head to poetry installation guide and install poetry according to the instructions.
Run the following command to make sure poetry is activated. You may need to close and reopen the terminal.

poetry --version

Finally, you can clone this repository and install it from source by running poetry install, with the optional examples extras if you'd like to run our tutorial scripts.

git clone https://github.com/sibyl-dev/pyreal.git
cd pyreal
poetry install

Install for Development

If you want to contribute to the project, a few more steps are required to make the project ready for development.

Please head to the Contributing Guide for more details about this process.

Quickstart

In this short tutorial we will guide you through some steps to get your started with Pyreal. We will use a RealApp object to get predictions and explanations on whether a passenger on the Titanic would have survived.

For a more detailed version of this tutorial, see our documentation.

Load in the demo data and application

import pyreal.sample_applications.titanic as titanic

real_app = titanic.load_app()
sample_data = titanic.load_data(n_rows=300)

Predict and produce explanation

predictions = real_app.predict(sample_data)

explanation = real_app.produce_feature_contributions(sample_data)

Visualize explanation for one passenger

passenger_id = 1
feature_bar_plot(explanation[passenger_id], prediction=predictions[passenger_id], show=False)

The output will be a bar plot showing the most contributing features, by absolute value.

Quickstart

We can see here that the input passenger's predicted chance of survival was greatly reduced because of their sex (male) and ticket class (3rd class).

Migrating your application to Pyreal

To create a RealApp object for your own application, see our migration tutorial.

For basic applications built on sklearn pipelines, you may be able to simply use:

from pyreal import RealApp

pipeline = # YOUR SKLEARN PIPELINE
X_train, y_train = # YOUR TRAINING DATA

real_app = RealApp.from_sklearn(pipeline, X_train=X_train, y_train=y_train)

Next Steps

For more information on using Pyreal for your use case, head over to the full documentation site.

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

pyreal-0.4.10.tar.gz (984.3 kB view details)

Uploaded Source

Built Distribution

pyreal-0.4.10-py3-none-any.whl (1.1 MB view details)

Uploaded Python 3

File details

Details for the file pyreal-0.4.10.tar.gz.

File metadata

  • Download URL: pyreal-0.4.10.tar.gz
  • Upload date:
  • Size: 984.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for pyreal-0.4.10.tar.gz
Algorithm Hash digest
SHA256 e1f5d60ed29467bbb34391248c37df038fd35ba033e38e85fb4e19744290a6a8
MD5 44791f4a9c28988b7761ed31c996eff6
BLAKE2b-256 cdddb6ffcd3034d4e902af8335e5d862f80b992b4ffcb7d6c3367df9de5cf045

See more details on using hashes here.

File details

Details for the file pyreal-0.4.10-py3-none-any.whl.

File metadata

  • Download URL: pyreal-0.4.10-py3-none-any.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for pyreal-0.4.10-py3-none-any.whl
Algorithm Hash digest
SHA256 4205a6d129be3ba3528b8023e72566bc13de0c57fb24fc25b4e77fc12123011e
MD5 e101e4b428e8bedc9afc4a074187db93
BLAKE2b-256 fb89c00be3aa7b9d11257c39ab7f66e656597f95776826e608e63faf74aa8d99

See more details on using hashes here.

Supported by

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