eli5.base — ELI5 0.15.0 documentation (original) (raw)

class DocWeightedSpans(document: str, spans: Sequence[tuple[str | list | FormattedFeatureName, list[tuple[int, int]], float]], preserve_density: bool | None = None, with_probabilities: bool | None = None, vec_name: str | None = None)[source]

Features highlighted in text. :document: is a pre-processed document before applying the analyzer. :weighted_spans: holds a list of spans for features found in text (span indices correspond to :document:). :preserve_density: determines how features are colored when doing formatting - it is better set to True for char features and to False for word features. :with_probabilities: would interpret weights as probabilities from 0 to 1, using a more suitable color scheme.

class Explanation(estimator: str, description: str | None = None, error: str | None = None, method: str | None = None, is_regression: bool = False, targets: list[TargetExplanation] | None = None, feature_importances: FeatureImportances | None = None, decision_tree: TreeInfo | None = None, highlight_spaces: bool | None = None, transition_features: TransitionFeatureWeights | None = None, image=None)[source]

An explanation for classifier or regressor, it can either explain weights or a single prediction.

class FeatureImportances(importances, remaining)[source]

Feature importances with number of remaining non-zero features.

class FeatureWeights(pos: list[FeatureWeight], neg: list[FeatureWeight], pos_remaining: int = 0, neg_remaining: int = 0)[source]

Weights for top features, :pos: for positive and :neg: for negative, sorted by descending absolute value. Number of remaining positive and negative features are stored in :pos_remaining: and :neg_remaining: attributes.

class NodeInfo(id: int, is_leaf: bool, value, value_ratio, impurity: float, samples: int, sample_ratio: float, feature_name: str | None = None, feature_id: int | None = None, threshold: float | None = None, left: NodeInfo | None = None, right: NodeInfo | None = None)[source]

A node in a binary tree. Pointers to left and right children are in :left: and :right: attributes.

class TargetExplanation(target: str | int, feature_weights: FeatureWeights | None = None, proba: float | None = None, score: float | None = None, weighted_spans: WeightedSpans | None = None, heatmap: ndarray | None = None)[source]

Explanation for a single target or class. Feature weights are stored in the :feature_weights: attribute, and features highlighted in text in the :weighted_spans: attribute.

Spatial values are stored in the :heatmap: attribute.

class TransitionFeatureWeights(class_names: list[str], coef)[source]

Weights matrix for transition features.

class TreeInfo(criterion: str, tree: NodeInfo, graphviz: str, is_classification: bool)[source]

Information about the decision tree. :criterion: is the name of the function to measure the quality of a split, :tree: holds all nodes of the tree, and :graphviz: is the tree rendered in graphviz .dot format.

class WeightedSpans(docs_weighted_spans: list[DocWeightedSpans], other: FeatureWeights | None = None)[source]

Holds highlighted spans for parts of document - a DocWeightedSpans object for each vectorizer, and other features not highlighted anywhere.