Library for evaluating and deploying human readable machine learning explanations.
Project description
An open source project from Data to AI Lab at MIT.
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.
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.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pyreal-0.4.9.tar.gz
.
File metadata
- Download URL: pyreal-0.4.9.tar.gz
- Upload date:
- Size: 979.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | de03f24dbe1848b083af72ae45c2befce39bb0717187a74c94855c3c042776da |
|
MD5 | fe2593165f93291552d36a6457d13782 |
|
BLAKE2b-256 | 29e4d3ffbadfcd52afdf6efc83a263aaa2ba64e8a1dfe572cfe8ca2cb07783b7 |
File details
Details for the file pyreal-0.4.9-py3-none-any.whl
.
File metadata
- Download URL: pyreal-0.4.9-py3-none-any.whl
- Upload date:
- Size: 1.1 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 549a2a0bbca4277af224344f3ac8b95f0d8222fdf534f1701d42fe758616c9b2 |
|
MD5 | 3d5242f76e11be367613c7ba78de5b33 |
|
BLAKE2b-256 | b9c3b4b488041d1a6fb48c3c8596a2d40babd47f0688d8e517d29339f3e54b7c |