Skip to main content

“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
📖 Documentation Quickstarts and user guides
📝 API Reference Full library API
🍎 Tutorials Notebooks with example usage
📜 License This repository is published under the MIT License
💻 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.

Metadata

Release files for pyreal 0.4.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyreal 0.4.10
File Size Uploaded Provenance Actions
pyreal-0.4.10.tar.gz 984.3 kB Without provenance Details for pyreal-0.4.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyreal 0.4.10
File Interpreter ABI Platform Actions
pyreal-0.4.10-py3-none-any.whl Python 3 none any Details for pyreal-0.4.10-py3-none-any.whl

Total release size: 2.1 MB

Release files / pyreal-0.4.10.tar.gz

Download URL pyreal-0.4.10.tar.gz
Size 984.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e1f5d60ed29467bbb34391248c37df038fd35ba033e38e85fb4e19744290a6a8
BLAKE2b-256 checksum
How to use checksums
cdddb6ffcd3034d4e902af8335e5d862f80b992b4ffcb7d6c3367df9de5cf045
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / pyreal-0.4.10-py3-none-any.whl

Download URL pyreal-0.4.10-py3-none-any.whl
Size 1.1 MB
Tags Python 3
SHA-256 checksum
How to use checksums
4205a6d129be3ba3528b8023e72566bc13de0c57fb24fc25b4e77fc12123011e
BLAKE2b-256 checksum
How to use checksums
fb89c00be3aa7b9d11257c39ab7f66e656597f95776826e608e63faf74aa8d99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.4

Security for pyreal 0.4.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page