API Reference

TreemapGenerator

class monad.ui.interpretability.TreemapGenerator

Defines data to generate treemap visualizations.

from pathlib import Path
from monad.ui.interpretability import TreemapGenerator

tg_from_files = TreemapGenerator(
  interpretability_files_path="<path/where/interpret/results/were/saved>"  # the same as output_path passed to interpret function
)
tg_from_files.plot_treemap(
  output_file_path="<path/to/html/treemap/file/to/save.html>"),  # .html file
)

Methods

TreemapGenerator.__init__(self, interpretability_files_path=None, hierarchy=None)

Inits TreemapGenerator object.

from pathlib import Path
from monad.ui.interpretability import TreemapGenerator

tg_from_files = TreemapGenerator(
  interpretability_files_path="<path/where/interpret/results/were/saved>"  # the same as output_path passed to interpret function
)
Parameters

interpretability_files_path: pathlib.Path

Path to interpretability attributions generated with interpret function. If provided, treemap based only on training data will be generated. Treemap levels will be as follows: data sources, features, feature values.


hierarchy: TreemapHierarchy
Custom definition of a Treemap hierarchy. If provided, Treemap based on defined hierarchy will be generated.

TreemapGenerator.plot_treemap(self, output_file_path, n_largest_per_feature=1500, n_largest=None, exclude_positive_attributions=False, exclude_negative_attributions=False, max_depth=3)

Evaluates scenario model.

from pathlib import Path
from monad.ui.interpretability import TreemapGenerator

tg_from_files = TreemapGenerator(
  interpretability_files_path="<path/where/interpret/results/were/saved>"  # the same as output_path passed to interpret function
)
tg_from_files.plot_treemap(
  output_file_path="<path/to/html/treemap/file/to/save.html>"),  # .html file
)
Parameters

output_file_path: pathlib.Path
Path to an output HTML file where Treemap should be saved.


n_largest_per_feature: Optional[int]
Default: 1500
Maximum number of the largest attribution values per feature to include on the plot. Rest of the feature values will be summed up and displayed as one element named rest_of_feature_values. If None all attribute values will be shown.


n_largest: Optional[int]
Default: None
Maximum number of largest attribution values to include on the plot. Rest of the feature values won't be on the plot. If None all attribute values will be shown.


exclude_positive_attributions: bool
Default: False
If positive attributions should be excluded from the plot.


exclude_negative_attributions: bool
Default: False
If negative attributions should be excluded from the plot.


max_depth: int
Default: 3
Defines the number of levels rendered at one time on a Treemap. If set to -1 will render all the hierarchy levels. Defaults to 3.

Returns

Saves treemap as HTML file under output_path.