Class ExplainerRegressionBT (extends Explainer)
The Boosted Trees Regression explainer.
This class adapts the generic Explainer to a BoostedTreesRegression model. It provides methods to:
- set an instance and derive its Boolean (literal-based) representation,
- compute different families of explanations (direct, contrastive, tree_specific),
Some functions come from the parent class Explainer, their documentation is available in the dedicated page:
- Main Methods:
set_instance,set_features_type,get_model,predict,activate_theory,deactivate_theory,set_excluded_features,unset_excluded_features; - Human-Readable Explanation Methods:
to_features,get_feature_names,get_feature_names_from_literal,reason_contains_features; - Explanation verification methods:
is_implicant,is_reason,is_sufficient_reason,is_contrastive_reason.
Parameters
lower_bound : float
The lower bound used for explanations.
upper_bound : float
The upper bound used for explanations.
Raises
ValueError:
RuntimeError:
Except for the direct reason, one has to provide an interval, for which the prediction is acceptable for the user.
def __init__(self, boosted_trees, instance=None): Highlight
Initialize an explainer for a Boosted Tree model.
Parameters
boosted_trees : BoostedTreesRegression
The BoostedTrees model to explain.
instance : list[int] (optional, default: None)
The instance for which explanations will be computed.
If None, you must call set_instance before requesting explanations.
Main Methods
def extremum_range(self): Highlight
The extremum range for predictions for the model.
The extremum range is computed in polynomial time, but the real extremum range can be smaller. Use range_for_partial_instance(self, [None for _ in range(explainer.instance]) to extract the real one (can be time consuming).
def range_for_partial_instance(self, partial_instance, *, time_limit=None): Highlight
Extract the range for all possible extension of the partial instance.
Given a partial instance, extract the range for all possible extension of the partial instance. The partial instance is defined with None value on undefined values.
Parameters
partial_instance : list[float] (optional, default: 50)
An instance.
time_limit : float (optional, default=None)
Time limit (seconds) for the whole enumeration. If reached, elapsed_time is set to Explaining.TIMEOUT.
This function can be time consuming.
def set_interval(self, lower_bound, upper_bound): Highlight
Set the interval.
For the regression case, one has to provide an interval, for which the prediction is acceptable for the user. Set the interval for the reason. The larger the interval is, the smaller the reason is.
Methods for Calculating Explanations
def tree_specific_reason(self, *, n_iterations=50, time_limit=None, seed=0): Highlight
Compute a tree specific reason for the current instance.
Informally, a tree specific reason for classifying is a prime implicant t of a majority of decision trees in f that covers the instance.
Parameters
n_iterations : int (optional, default: 50)
Number of randomized iterations used to extract the smallest one.
time_limit : float (optional, default=None)
Time limit (seconds) for the whole enumeration. If reached, elapsed_time is set to Explaining.TIMEOUT.
seed : int (optional, default: 0)
A seed to change the reason.
Raises
ValueError
RuntimeError