Link Search Menu Expand Document
PyXAI
Papers Video GitHub In-the-Loop EXPEKCTATION Release Notes About

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:

Parameters

lower_bound : float

The lower bound used for explanations.

upper_bound : float

The upper bound used for explanations.

Raises

ValueError:

If the instance is not set.

RuntimeError:

If the lower or upper bound are not set.

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).

Returns

(float,float) :

A tuple (min_value, max_value) corresponding to the extremum range.

    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.

Returns

(float,float) :

A tuple (min_value, max_value) corresponding to the extremum range.

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.

Parameters

lower_bound : float

The lower bound of the interval

upper_bound : float

The upper bound of the interval


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.

Returns

list[int] :

The tree specific reason.

None :

If computed reasons contain excluded features.

Raises

ValueError

If no instance has been set.

RuntimeError

If lower or upper bound are not specified.

See also

Symbols