omnixai.explainers.ranking.agnostic package

validity

Ranking Explainer for tabular data.

permutation

Feature Permutation Ranking Explainer for tabular data.

omnixai.explainers.ranking.agnostic.validity module

Ranking Explainer for tabular data.

class omnixai.explainers.ranking.agnostic.validity.ValidityRankingExplainer(training_data, predict_function, ignored_features=None, **kwargs)

Bases: ExplainerBase

Ranking Explainer for Tabular Data. If using this explainer, please cite the paper Extracting per Query Valid Explanations for Blackbox Learning-to-Rank Models, https://dl.acm.org/doi/10.1145/3471158.3472241.

Parameters
  • training_data (Tabular) – The data used to initialize a Ranking explainer. training_data can be the training dataset for training the machine learning model.

  • predict_function (Callable) – The prediction function corresponding to the model to explain. the outputs of the predict_function are the ranking scores. The output must be a numpy array.

  • ignored_features (Optional[List]) – The features ignored by the valid per-query algorithm.

explanation_type = 'local'
alias = ['validity']
explain(X, k=3, n_items=None, mask='median', weighted=False, epsilon=-1.0, query_id=None, verbose=False, **kwargs)

Generates the valid per-query feature-importance explanations for the input instances.

Parameters
  • X (Tabular) – A set of input items for a query.

  • k (int) – The maximum number of features to be accounted as explanation

  • n_items (Optional[int]) – The number of items to be considered for the explanation

  • mask (str) – The type of feature masking to be performed (median, mode, None) default=median

  • weighted (bool) – Flag for calculating weighted propensity

  • epsilon (float) – The epsilon value for the greedy-cover procedure. Negative epsilon will replace greedy-cover with simple greedy

  • query_id (Optional[str]) – The feature column representing the query_id if present

  • verbose (bool) – Flag for verbosity of print statements

Return type

ValidityRankingExplanation

Returns

The valid per-query feature-importance explanations for the given items.

omnixai.explainers.ranking.agnostic.permutation module

Feature Permutation Ranking Explainer for tabular data.

class omnixai.explainers.ranking.agnostic.permutation.PermutationRankingExplainer(training_data, predict_function, ignored_features=None, random_state=None, **kwargs)

Bases: ExplainerBase

Feature Permutation Ranking Explainer for Tabular Data.

Parameters
  • training_data (Tabular) – The data used to initialize a Ranking explainer. training_data can be the training dataset for training the machine learning model.

  • predict_function (Callable) – The prediction function corresponding to the model to explain. the outputs of the predict_function are the ranking scores. The output must be a numpy array.

  • ignored_features (Optional[List]) – The features ignored by the permutation per-query algorithm.

explanation_type = 'local'
alias = ['permutation']
explain(X, n_items=None, weighted=False, quotient=False, query_id=None, n_iter=100, verbose=False, **kwargs)

Generates the permutation based per-query feature-importance explanations for the input instances.

Parameters
  • X (Tabular) – A set of input items for a query.

  • n_items (Optional[int]) – The number of items to be considered for the explanation

  • weighted (bool) – Flag for calculating weighted propensity

  • quotient (bool) – Flag for propensity normalization

  • query_id (Optional[str]) – The feature column representing the query_id if present

  • n_iter (int) – The number of iterations to run for each feature permutation. Higher is more stable.

  • verbose (bool) – Flag for verbosity of print statements

Return type

GlobalFeatureImportance

Returns

The per-query feature-importance explanations for the given items.