Visualization

You can use Pyreal's `visualize` module to quickly get explanation graphs

The full code for this and all other user guides can be found in our user guide tutorial.

Pyreal's visualize module includes several functions that take in RealApp output directly to generate explanation plots.

All visualization functions take in many customization parameters. See the API reference for more information.

Feature Bar Plot

The feature bar plot can visualize general feature importance scores...

from pyreal.visualize import feature_bar_plot

feature_bar_plot(importance_scores)

feature_bar_plot(contributions_scores["House 101"])

... or contribution scores for a single input

feature_bar_plot(contribution_scores["House 101"])

Strip Plot

Strip plots are an effective way to visualize feature contributions for multiple inputs at a time, to understand the general trends of how the ML model uses features.

To increase the amount of information displayed in these plots, you can generate feature contributions for the full training set.

from pyreal.visualize import strip_plot

training_set_contributions = realapp.produce_feature_contributions(x_train)
strip_plot(training_set_contributions)

Feature Scatter Plot

Scatter plots allow you to investigate how the model uses a specific feature, across the full range of that feature's values:

from pyreal.visualize import feature_scatter_plot

# Optionally pass in predictions to color the plot by prediction
predictions = realapp.predict(x_train, format=False)

feature_scatter_plot(training_set_contributions, 
                     "Total above ground living area in square feet", 
                     predictions=predictions)

Example Table

To get a clean table comparing the feature values of a input data to those of similar examples, you can use the example_table function:

from pyreal.visualize import example_table

example_table(similar_houses["House 101"])

This will give you a table like:

Last updated

Logo