Algorithms for monitoring and explaining machine learning models

Overview

Alibi Logo

Build Status Documentation Status codecov Python version PyPI version GitHub Licence Slack channel

Alibi is an open source Python library aimed at machine learning model inspection and interpretation. The focus of the library is to provide high-quality implementations of black-box, white-box, local and global explanation methods for classification and regression models.

If you're interested in outlier detection, concept drift or adversarial instance detection, check out our sister project alibi-detect.


Anchor explanations for images


Integrated Gradients for text


Counterfactual examples


Accumulated Local Effects

Table of Contents

Installation and Usage

Alibi can be installed from PyPI:

pip install alibi

Alternatively, the development version can be installed:

pip install git+https://github.com/SeldonIO/alibi.git 

To take advantage of distributed computation of explanations, install alibi with ray:

pip install alibi[ray]

The alibi explanation API takes inspiration from scikit-learn, consisting of distinct initialize, fit and explain steps. We will use the AnchorTabular explainer to illustrate the API:

from alibi.explainers import AnchorTabular

# initialize and fit explainer by passing a prediction function and any other required arguments
explainer = AnchorTabular(predict_fn, feature_names=feature_names, category_map=category_map)
explainer.fit(X_train)

# explain an instance
explanation = explainer.explain(x)

The explanation returned is an Explanation object with attributes meta and data. meta is a dictionary containing the explainer metadata and any hyperparameters and data is a dictionary containing everything related to the computed explanation. For example, for the Anchor algorithm the explanation can be accessed via explanation.data['anchor'] (or explanation.anchor). The exact details of available fields varies from method to method so we encourage the reader to become familiar with the types of methods supported.

Supported Methods

The following tables summarize the possible use cases for each method.

Model Explanations

Method Models Explanations Classification Regression Tabular Text Images Categorical features Train set required Distributed
ALE BB global
Anchors BB local For Tabular
CEM BB* TF/Keras local Optional
Counterfactuals BB* TF/Keras local No
Prototype Counterfactuals BB* TF/Keras local Optional
Integrated Gradients TF/Keras local Optional
Kernel SHAP BB local

global
Tree SHAP WB local

global
Optional

Model Confidence

These algorithms provide instance-specific scores measuring the model confidence for making a particular prediction.

Method Models Classification Regression Tabular Text Images Categorical Features Train set required
Trust Scores BB (1) (2) Yes
Linearity Measure BB Optional

Key:

  • BB - black-box (only require a prediction function)
  • BB* - black-box but assume model is differentiable
  • WB - requires white-box model access. There may be limitations on models supported
  • TF/Keras - TensorFlow models via the Keras API
  • Local - instance specific explanation, why was this prediction made?
  • Global - explains the model with respect to a set of instances
  • (1) - depending on model
  • (2) - may require dimensionality reduction

References and Examples

Citations

If you use alibi in your research, please consider citing it.

BibTeX entry:

@software{alibi,
  title = {Alibi: Algorithms for monitoring and explaining machine learning models},
  author = {Klaise, Janis and Van Looveren, Arnaud and Vacanti, Giovanni and Coca, Alexandru},
  url = {https://github.com/SeldonIO/alibi},
  version = {0.5.6},
  date = {2021-02-18},
  year = {2019}
}
Comments
  • Tree SHAP

    Tree SHAP

    This PR adds Tree SHAP to alibi. The following artefacts are included:

    • a wrapper for shap.TreeExplainer object in alibi.explainers.shap_wrappers

    • two detailed examples showing how to use the wrapper and its various features

    • documentation outlining the usage for the wrapper as well as a theoretical overview of the method

    • tests for the wrapper code in test_shap_wrappers.py

    opened by alexcoca 49
  • ValueError: Quantiles array should be sorted! & Catgorical features

    ValueError: Quantiles array should be sorted! & Catgorical features

    Dear all,

    I am trying to use Anchor to interpret my Tabular data

    I would like to note that I got an error stating that the Quantiles array should be sorted, after I call explainer.fit on my dataset array. Any idea how to overcome this error?

    Moreover, for the categorical features, I actually preprocess my dataset so I process the categorical features and one hot encode them. Afterwards, I pass a pandas dataframe of this processed dataset to the explainer.fit. So, all of the features should be treated as continous features in such a case. May that cause any problem? Should I instead pass the initial dataset before processing and indicate the keys and categories of each features?

    Type: Question 
    opened by Dola47 33
  • Similarity explanations (`GradientSimilarity`) examples and documentation

    Similarity explanations (`GradientSimilarity`) examples and documentation

    • Added method notebook in docs for similarity explanations
    • Added similarity explanations MNIST example notebook
    • Added similarity explanations 20 news group example notebook
    opened by gipster 31
  • AnchorText- IndexError (dimension mismatch)

    AnchorText- IndexError (dimension mismatch)

    Hi, I'm getting this error IndexError: boolean index did not match indexed array along dimension 0; dimension is 100 but corresponding boolean dimension is 1

    Any help would be greatly appreciated!!

    Here's the full stack trace.

    ---------------------------------------------------------------------------
    IndexError                                Traceback (most recent call last)
    <ipython-input-64-b6e19739979d> in <module>
          1 np.random.seed(0)
    ----> 2 explanation = explainer.explain(text, threshold=0.95, use_unk=True)
    
    /usr/local/lib/python3.6/dist-packages/alibi/explainers/anchor_text.py in explain(self, text, use_unk, use_similarity_proba, sample_proba, top_n, temperature, threshold, delta, tau, batch_size, coverage_samples, beam_size, stop_on_first, max_anchor_size, min_samples_start, n_covered_ex, binary_cache_size, cache_margin, verbose, verbose_every, **kwargs)
        562             verbose=verbose,
        563             verbose_every=verbose_every,
    --> 564             **kwargs,
        565         )  # type: Any
        566         result['names'] = [self.words[x] for x in result['feature']]
    
    /usr/local/lib/python3.6/dist-packages/alibi/explainers/anchor_base.py in anchor_beam(self, delta, epsilon, desired_confidence, beam_size, epsilon_stop, min_samples_start, max_anchor_size, stop_on_first, batch_size, coverage_samples, verbose, verbose_every, **kwargs)
        666 
        667         # sample by default 1 or min_samples_start more random value(s)
    --> 668         (pos,), (total,) = self.draw_samples([()], min_samples_start)
        669 
        670         # mean = fraction of labels sampled data that equals the label of the instance to be explained, ...
    
    /usr/local/lib/python3.6/dist-packages/alibi/explainers/anchor_base.py in draw_samples(self, anchors, batch_size)
        355         sample_stats, pos, total = [], (), ()  # type: List, Tuple, Tuple
        356         samples_iter = [self.sample_fcn((i, tuple(self.state['t_order'][anchor])), num_samples=batch_size)
    --> 357                         for i, anchor in enumerate(anchors)]
        358         for samples, anchor in zip(samples_iter, anchors):
        359             covered_true, covered_false, labels, *additionals, _ = samples
    
    /usr/local/lib/python3.6/dist-packages/alibi/explainers/anchor_base.py in <listcomp>(.0)
        355         sample_stats, pos, total = [], (), ()  # type: List, Tuple, Tuple
        356         samples_iter = [self.sample_fcn((i, tuple(self.state['t_order'][anchor])), num_samples=batch_size)
    --> 357                         for i, anchor in enumerate(anchors)]
        358         for samples, anchor in zip(samples_iter, anchors):
        359             covered_true, covered_false, labels, *additionals, _ = samples
    
    /usr/local/lib/python3.6/dist-packages/alibi/explainers/anchor_text.py in sampler(self, anchor, num_samples, compute_labels)
        176         if compute_labels:
        177             labels = self.compare_labels(raw_data)
    --> 178             covered_true = raw_data[labels][:self.n_covered_ex]
        179             covered_false = raw_data[np.logical_not(labels)][:self.n_covered_ex]
        180             # coverage set to -1.0 as we can't compute 'true'coverage for this model
    
    IndexError: boolean index did not match indexed array along dimension 0; dimension is 100 but corresponding boolean dimension is 1```
    opened by ChristianFJung 24
  • Add a conda install option for `alibi`

    Add a conda install option for `alibi`

    A conda installation option could be very helpful. I have already started working on this, to add alibi to conda-forge.

    Conda-forge PR:

    • https://github.com/conda-forge/staged-recipes/pull/17582

    Once the conda-forge PR is merged, you will be able to install the library with conda as follows:

    conda install -c conda-forge alibi
    

    :bulb: I will push a PR to update the docs once the package is available on conda-forge.

    opened by sugatoray 17
  • Integrated Gradients target

    Integrated Gradients target

    Short version: wrong dimensionality doesn't crash Integrated Gradients explainer - this seems weird. Long version below:

    I am struggle to understand what target parameter means and how to use it According to https://docs.seldon.io/projects/alibi/en/latest/methods/IntegratedGradients.html target: Defines which element of the model output is considered to compute the gradients.

    My model is a multicategory images regression with last layer layers.Dense(3, activation=tf.nn.relu) , 3 because I have 3 differents regressed scores

    When I do

    import tensorflow as tf
    from alibi.explainers import IntegratedGradients
    
    
    ig  = IntegratedGradients(model_ours,
                              layer=None,
                              method="gausslegendre",
                              n_steps=50,
                              internal_batch_size=100)
    ig.explain(X, baselines=None, target=1)
    

    I will actually get some nicely looking explanations, but they don't seem meaningful. I can change target to 99999999, or -999, or np.array([[1,1,1]]) or in fact np.array([[1,1,1,1,1,1,1,1,1,1]]) to get different explanations, but I don't know what they mean in such case. The description from your manual seems to be wrong, target doesn't seem to say "which element of the model output is considered to compute the gradient", it rather seems to supply this element's value. However I don't understand dimensionality in such case.

    Let's say I make sure I am using the last layer with:

    print(X.shape,y)
    ig  = IntegratedGradients(model_ours,
                              layer = model_ours.layers[-1],
                              method="gausslegendre",
                              n_steps=50,
                              internal_batch_size=100)
    ig.explain(X, baselines=None, target=np.array([[5.5,1.0,4.5]])) #this is correct label for this picture
    

    Ok, got some explanations, I supplied numbers for 3 outputs, should be fine. However I can also do, ig.explain(X, baselines=None, target=np.array([[99]*99])) and I also get some explanations. I don't understand why didn't the code crash - I just provided a 99 values to 3 neurons, how were they distributed? Did only first [99,99,99] got feed to the network? Or maybe just the first value [99]?

    I have a second question, after I run the code above, I will get:

     'predictions': array([[3.5566006, 0.7617401, 3.6028929]], dtype=float32),
      'deltas': array([0.]),
      'target': [array([99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
           99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
           99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
           99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
           99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
           99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99])]}
    

    What are 'deltas'? Why only single scalar instead of ie input_width x input_height x channels OR vector of 3 values (because 3 neurons in my dense layer)? Is it the same as loss value (i.e MSE for my model if I used it for training)? It's usually 0.0, rarely something like 0.4 for me, and I cannot determine what changes it's value.

    There is a small secondary issue: [5.5,1.0,4.5] is feed as [5,1,4], which is a minor inconvenience.

    Btw great work with this repo in general, It's great that you maintain it with newer versions of Tensorflow 2.x! Thanks a lot! I couldn't get LIME or SHAP running well with new tf and regression at all.

    Type: Question 
    opened by Huxwell 16
  • Categorical data not working in Anchor Tabular

    Categorical data not working in Anchor Tabular

    In your example https://docs.seldon.io/projects/alibi/en/stable/examples/anchor_tabular_adult.html, you show how using a categorical map, you can use Anchors on categorical data. However, you pre-encoded the categorical data to numeric in your fetch data command, so in fact, you have a redundant pipeline when you are passing in only numeric data. When I tried to use the Adult dataset straight from Kaggle, for instance, I get some weird errors, such as ValueError: could not convert string to float: '?', when I ran everything the same, accept read in the raw data instead of your fetch command. Please advise

    Type: Question 
    opened by aclarkData 15
  • Partial dependence plots

    Partial dependence plots

    Implementation of the partial dependence (PD) and individual conditional expectation (ICE) leveragingsklearn implementation. Some functionalities that it includes

    • PD and ICE for numerical features
    • PD and ICE for categorical features
    • PD and ICE for combinations of numerical and/or categorical features
    • Plots for all the above cases
    • Custom grids
    • Usage of any black-box model (i.e. not only restricted to sklearn estimators)

    TODOs:

    • [x] Method description notebook
    • [x] Example usage notebook
    opened by RobertSamoilescu 14
  • Dev/reinstate strict optional mypy

    Dev/reinstate strict optional mypy

    This PR reinstates strict Optional type-checking with mypy because it's both a prerequisite of #511 and also a good idea (there were multiple genuine bugs caught by re-enabling strict behaviour).

    Specifically, setup.cfg now contains the following:

    [mypy]
    ignore_missing_imports = True
    no_implicit_optional = True
    

    Note that strict_optional = True is the default and disallows None as a valid type for functions that don't declare it explicitly as valid. Furthermore, no_implicit_optional now requires writing Optional[some_type] = None instead of some_type = None which is recommended behaviour.

    Most of the code is just type changes, but where genuine bugs were revealed some (minor) logic changes were needed also.

    I will post some comments on the PR shortly to ease reviewing.

    I have additionally taken the change to run isort on the affected modules for more pleasant import ordering.

    One particularly pernicious pattern I have decided to refactor is to do with initializing instance attributes as None and later setting them to their proper values. So instead of this (which would fail type-checking now):

    class Foo:
        def __init__(self):
            # to be set later
            self.attr = None # type: int
    

    we now declare the type of the non-initialized attribute in the class instead:

    class Foo:
        attr: int
    

    Now you may ask, why not just stick with the first variant and annotate with # type: Optional[int]? The answer is that None is (almost always) not a valid value as in the self.attr = None pattern is used as a placeholder to be initialized later on. But this can lead to a variety of bugs if we don't explicitly check for None every time we want to use the (hopefully initialized) attribute. Type checkers like mypy are also unlikely to know that when accessing self.attr after initialization there is no risk of it being None because of potentially complex runtime logic that determines self.attr can't be None which the type-checker cannot follow. Finally, we may fail to consider all cases of setting self.attr to it's not-None value and have a genuine bug where we believe self.attr isn't None anymore when it still is... Thus, it is better to declare but not instantiate to a generally invalid None value. In this scenario we can also check that if the value needs instantiating by calling hasattr(self, 'attr') instead of comparing to None as in the previous scenario.

    A final minor curiosity, because our numpy version is older and doesn't include numpy.typing advancements, anywhere arr: np.ndarray = None is declared doesn't actually result in a mypy error. However, we're good citizens and wrap it in Optional as well, this will future-proof when later versionf of numpy can be used.

    opened by jklaise 13
  • Intgrads subclassed models

    Intgrads subclassed models

    Support for tensorflow and keras models with no explicit inputs (subclassed models).

    In the present code base, tensor inputs are converted to lists at explain time in order to handle models with multiple inputs. If a model has a single input, the tensor input will be converted to a list with one element.

    List input are handled well by models with an explicit input layer (functional and sequential models). When no explicit input layer is present (in subclassed models), the input must be in the format expected by the the first layer.

    In order to support subclassed models, in this pull request

    • The attributions are calculate with two different functions _calculate_attributions_list_input and _calculate_attributions_tensor_input for list inputs and tensor inputs, respectively.
    • For subclassed models with no explicit input, the inputs types and the output shapes of the models, which are needed to calculate the attributions, are inferred at explain time with a single mock call of the model.
    Type: Method extension 
    opened by gipster 13
  • Issue with the shape input to ig.explain

    Issue with the shape input to ig.explain

    I am using the Integrated gradients for text classification on the IMDB dataset notebook, and on the ig.explain command, for my own model, I have submitted an object in the first argument that is TensorShape([128,512]). Because I am using a regression model, I have typed in None for baselines. However, I receive this error:

    ---------------------------------------------------------------------------
    TypeError                                 Traceback (most recent call last)
    <ipython-input-115-af7b05840e2d> in <module>
          1 explanation = ig.explain(onebatch[0],
          2                          baselines=None,
    ----> 3                          target=None)
          4 
          5 attributions = explanation.attributions
    
    /opt/conda/lib/python3.7/site-packages/alibi/explainers/integrated_gradients.py in explain(self, X, baselines, target)
        507             x, baseline = X[i], baselines[i]
        508             # format and check baselines
    --> 509             baseline = _format_input_baseline(x, baseline)
        510             baselines[i] = baseline
        511 
    
    /opt/conda/lib/python3.7/site-packages/alibi/explainers/integrated_gradients.py in _format_input_baseline(X, baselines)
        284     """
        285     if baselines is None:
    --> 286         bls = np.zeros(X.shape).astype(X.dtype)
        287     elif isinstance(baselines, int) or isinstance(baselines, float):
        288         bls = np.full(X.shape, baselines).astype(X.dtype)
    
    TypeError: data type not understood
    

    If, instead, I input baselines to be baselines=tf.zeros([128, 512], tf.int32), the error is

    ValueError: baselines must be `int`, `float`, `np.ndarray` or `None`. Found <class 'tensorflow.python.framework.ops.EagerTensor'>

    If I return baselines=None, and instead of sending in a TensorShape, I send in a np.array, I receive a different error:

    InvalidArgumentError                      Traceback (most recent call last)
    /opt/conda/lib/python3.7/site-packages/tensorflow_core/python/eager/context.py in execution_mode(mode)
       1896     ctx.executor = executor_new
    -> 1897     yield
       1898   finally:
    
    /opt/conda/lib/python3.7/site-packages/tensorflow_core/python/data/ops/iterator_ops.py in _next_internal(self)
        658             output_types=self._flat_output_types,
    --> 659             output_shapes=self._flat_output_shapes)
        660 
    
    /opt/conda/lib/python3.7/site-packages/tensorflow_core/python/ops/gen_dataset_ops.py in iterator_get_next_sync(iterator, output_types, output_shapes, name)
       2478     except _core._NotOkStatusException as e:
    -> 2479       _ops.raise_from_not_ok_status(e, name)
       2480   # Add nodes to the TensorFlow graph.
    
    /opt/conda/lib/python3.7/site-packages/tensorflow_core/python/framework/ops.py in raise_from_not_ok_status(e, name)
       6605   # pylint: disable=protected-access
    -> 6606   six.raise_from(core._status_to_exception(e.code, message), None)
       6607   # pylint: enable=protected-access
    
    /opt/conda/lib/python3.7/site-packages/six.py in raise_from(value, from_value)
    
    InvalidArgumentError: TypeError: `generator` yielded an element that did not match the expected structure. The expected structure was (tf.int32, tf.int32), but the yielded element was (3.908070761805162,).
    Traceback (most recent call last):
    
      File "/opt/conda/lib/python3.7/site-packages/tensorflow_core/python/data/ops/dataset_ops.py", line 795, in generator_py_func
        flattened_values = nest.flatten_up_to(output_types, values)
    
      File "/opt/conda/lib/python3.7/site-packages/tensorflow_core/python/data/util/nest.py", line 396, in flatten_up_to
        assert_shallow_structure(shallow_tree, input_tree)
    
      File "/opt/conda/lib/python3.7/site-packages/tensorflow_core/python/data/util/nest.py", line 311, in assert_shallow_structure
        % (len(input_tree), len(shallow_tree)))
    
    ValueError: The two structures don't have the same sequence length. Input structure has length 1, while shallow structure has length 2.
    
    
    During handling of the above exception, another exception occurred:
    
    
    Traceback (most recent call last):
    
      File "/opt/conda/lib/python3.7/site-packages/tensorflow_core/python/ops/script_ops.py", line 236, in __call__
        ret = func(*args)
    
      File "/opt/conda/lib/python3.7/site-packages/tensorflow_core/python/data/ops/dataset_ops.py", line 800, in generator_py_func
        "element was %s." % (output_types, values)), sys.exc_info()[2])
    
      File "/opt/conda/lib/python3.7/site-packages/six.py", line 702, in reraise
        raise value.with_traceback(tb)
    
      File "/opt/conda/lib/python3.7/site-packages/tensorflow_core/python/data/ops/dataset_ops.py", line 795, in generator_py_func
        flattened_values = nest.flatten_up_to(output_types, values)
    
      File "/opt/conda/lib/python3.7/site-packages/tensorflow_core/python/data/util/nest.py", line 396, in flatten_up_to
        assert_shallow_structure(shallow_tree, input_tree)
    
      File "/opt/conda/lib/python3.7/site-packages/tensorflow_core/python/data/util/nest.py", line 311, in assert_shallow_structure
        % (len(input_tree), len(shallow_tree)))
    
    TypeError: `generator` yielded an element that did not match the expected structure. The expected structure was (tf.int32, tf.int32), but the yielded element was (3.908070761805162,).
    
    
    	 [[{{node PyFunc}}]] [Op:IteratorGetNextSync]
    
    During handling of the above exception, another exception occurred:
    
    InvalidArgumentError                      Traceback (most recent call last)
    <ipython-input-118-072b867d5f3f> in <module>
          1 explanation = ig.explain(test_data_1_array,
          2                          baselines=None,
    ----> 3                          target=None)
          4 
          5 attributions = explanation.attributions
    
    /opt/conda/lib/python3.7/site-packages/alibi/explainers/integrated_gradients.py in explain(self, X, baselines, target)
        542         # calculate gradients for batches
        543         batches = []
    --> 544         for path in paths_ds:
        545 
        546             if target is not None:
    
    /opt/conda/lib/python3.7/site-packages/tensorflow_core/python/data/ops/iterator_ops.py in __next__(self)
        628 
        629   def __next__(self):  # For Python 3 compatibility
    --> 630     return self.next()
        631 
        632   def _next_internal(self):
    
    /opt/conda/lib/python3.7/site-packages/tensorflow_core/python/data/ops/iterator_ops.py in next(self)
        672     """Returns a nested structure of `Tensor`s containing the next element."""
        673     try:
    --> 674       return self._next_internal()
        675     except errors.OutOfRangeError:
        676       raise StopIteration
    
    /opt/conda/lib/python3.7/site-packages/tensorflow_core/python/data/ops/iterator_ops.py in _next_internal(self)
        663         return self._element_spec._from_compatible_tensor_list(ret)  # pylint: disable=protected-access
        664       except AttributeError:
    --> 665         return structure.from_compatible_tensor_list(self._element_spec, ret)
        666 
        667   @property
    
    /opt/conda/lib/python3.7/contextlib.py in __exit__(self, type, value, traceback)
        128                 value = type()
        129             try:
    --> 130                 self.gen.throw(type, value, traceback)
        131             except StopIteration as exc:
        132                 # Suppress StopIteration *unless* it's the same exception that
    
    /opt/conda/lib/python3.7/site-packages/tensorflow_core/python/eager/context.py in execution_mode(mode)
       1898   finally:
       1899     ctx.executor = executor_old
    -> 1900     executor_new.wait()
       1901 
       1902 
    
    /opt/conda/lib/python3.7/site-packages/tensorflow_core/python/eager/executor.py in wait(self)
         65   def wait(self):
         66     """Waits for ops dispatched in this executor to finish."""
    ---> 67     pywrap_tensorflow.TFE_ExecutorWaitForAllPendingNodes(self._handle)
         68 
         69   def clear_error(self):
    
    InvalidArgumentError: TypeError: `generator` yielded an element that did not match the expected structure. The expected structure was (tf.int32, tf.int32), but the yielded element was (3.908070761805162,).
    Traceback (most recent call last):
    
      File "/opt/conda/lib/python3.7/site-packages/tensorflow_core/python/data/ops/dataset_ops.py", line 795, in generator_py_func
        flattened_values = nest.flatten_up_to(output_types, values)
    
      File "/opt/conda/lib/python3.7/site-packages/tensorflow_core/python/data/util/nest.py", line 396, in flatten_up_to
        assert_shallow_structure(shallow_tree, input_tree)
    
      File "/opt/conda/lib/python3.7/site-packages/tensorflow_core/python/data/util/nest.py", line 311, in assert_shallow_structure
        % (len(input_tree), len(shallow_tree)))
    
    ValueError: The two structures don't have the same sequence length. Input structure has length 1, while shallow structure has length 2.
    
    
    During handling of the above exception, another exception occurred:
    
    
    Traceback (most recent call last):
    
      File "/opt/conda/lib/python3.7/site-packages/tensorflow_core/python/ops/script_ops.py", line 236, in __call__
        ret = func(*args)
    
      File "/opt/conda/lib/python3.7/site-packages/tensorflow_core/python/data/ops/dataset_ops.py", line 800, in generator_py_func
        "element was %s." % (output_types, values)), sys.exc_info()[2])
    
      File "/opt/conda/lib/python3.7/site-packages/six.py", line 702, in reraise
        raise value.with_traceback(tb)
    
      File "/opt/conda/lib/python3.7/site-packages/tensorflow_core/python/data/ops/dataset_ops.py", line 795, in generator_py_func
        flattened_values = nest.flatten_up_to(output_types, values)
    
      File "/opt/conda/lib/python3.7/site-packages/tensorflow_core/python/data/util/nest.py", line 396, in flatten_up_to
        assert_shallow_structure(shallow_tree, input_tree)
    
      File "/opt/conda/lib/python3.7/site-packages/tensorflow_core/python/data/util/nest.py", line 311, in assert_shallow_structure
        % (len(input_tree), len(shallow_tree)))
    
    TypeError: `generator` yielded an element that did not match the expected structure. The expected structure was (tf.int32, tf.int32), but the yielded element was (3.908070761805162,).
    
    
    	 [[{{node PyFunc}}]]
    
    
    opened by sbecon 11
  • Update sphinx requirement from <5.1.0,>=4.2.0 to >=4.2.0,<6.1.0

    Update sphinx requirement from <5.1.0,>=4.2.0 to >=4.2.0,<6.1.0

    Updates the requirements on sphinx to permit the latest version.

    Release notes

    Sourced from sphinx's releases.

    v6.0.0

    Changelog: https://www.sphinx-doc.org/en/master/changes.html

    Changelog

    Sourced from sphinx's changelog.

    Release 6.0.0 (released Dec 29, 2022)

    Dependencies

    • #10468: Drop Python 3.6 support
    • #10470: Drop Python 3.7, Docutils 0.14, Docutils 0.15, Docutils 0.16, and Docutils 0.17 support. Patch by Adam Turner

    Incompatible changes

    • #7405: Removed the jQuery and underscore.js JavaScript frameworks.

      These frameworks are no longer be automatically injected into themes from Sphinx 6.0. If you develop a theme or extension that uses the jQuery, $, or $u global objects, you need to update your JavaScript to modern standards, or use the mitigation below.

      The first option is to use the sphinxcontrib.jquery_ extension, which has been developed by the Sphinx team and contributors. To use this, add sphinxcontrib.jquery to the extensions list in conf.py, or call app.setup_extension("sphinxcontrib.jquery") if you develop a Sphinx theme or extension.

      The second option is to manually ensure that the frameworks are present. To re-add jQuery and underscore.js, you will need to copy jquery.js and underscore.js from the Sphinx repository_ to your static directory, and add the following to your layout.html:

      .. code-block:: html+jinja

      {%- block scripts %} {{ super() }} {%- endblock %}

      .. _sphinxcontrib.jquery: https://github.com/sphinx-contrib/jquery/

      Patch by Adam Turner.

    • #10471, #10565: Removed deprecated APIs scheduled for removal in Sphinx 6.0. See :ref:dev-deprecated-apis for details. Patch by Adam Turner.

    • #10901: C Domain: Remove support for parsing pre-v3 style type directives and roles. Also remove associated configuration variables c_allow_pre_v3 and c_warn_on_allowed_pre_v3. Patch by Adam Turner.

    Features added

    ... (truncated)

    Commits

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
  • `GradSim` Improvements

    `GradSim` Improvements

    I think the dash onsite demonstrated the GradSim method is slow for large models. This is because currently, pytorch and tensorflow don’t let you compute gradients per instance in a batch which gradient similarity requires. We can do this before time by storing the gradients but this becomes impossible for large models. Note that partial solutions include: a) using a subset of model weights, such as a final layer, to decrease memory overhead or b) reducing the dataset you're comparing against using something like ProtoSelect. Both of these are user-level interventions. I think our focus should be figuring out how to batch the gradient computations.

    Type: Enhancement 
    opened by mauicv 2
  • Documentation of ALE. How to set interval?

    Documentation of ALE. How to set interval?

    For ALE plot, the Christoph's book and R's ALE library documentation mentions a parameter called 'Interval'. Going through the documentation on docs.seldon.io, I cannot find any mention of this, although it is discussed in theory.

    Am I missing something or this has not be implemented yet?

    Type: Question 
    opened by snu11 1
  • Setting attributes to `None` before saving can leave explainers broken if saving fails

    Setting attributes to `None` before saving can leave explainers broken if saving fails

    E.g. https://github.com/SeldonIO/alibi/blob/91a2a8821851f393193157f9d01bf4d278af12da/alibi/saving.py#L111, if for some reason saving fails, the explainer is left without a predictor attribute and will not work anymore. We need to wrap saving in try/except and be careful to reset any changed attributes both on failure and success.

    Type: Bug 
    opened by jklaise 0
  • Embedding Layers error in Similarity `_TensorFlowBackend`

    Embedding Layers error in Similarity `_TensorFlowBackend`

    The following raises the error 'IndexedSlices' object has no attribute 'numpy':

    model = tf.keras.models.Sequential([
            tf.keras.layers.Embedding(10, 4, input_shape = (5,)),
            tf.keras.layers.Flatten(), 
            tf.keras.layers.Dense(1)
        ])
        X = tf.random.uniform(shape = (1, 5), minval = 0, maxval = 10, dtype = tf.float32)
        Y = tf.random.uniform(shape = (1, 1), minval = 0, maxval = 10, dtype = tf.float32)
        loss_fn = tf.keras.losses.MeanSquaredError()
        tf_grads = _TensorFlowBackend.get_grads(model, X, Y, loss_fn)
    

    This is because the gradient through an embedding layer is not computable. Instead, the gradients get returned as IndexedSlices. These raise an error in explainers.similarity.backends.tensorflow.base in the following code:

            with tf.device(_TensorFlowBackend.device):
                with tf.GradientTape() as tape:
                    output = model(X, training=False)
                    loss = loss_fn(Y, output)
    
                # compute gradients of the loss w.r.t the weights
                grad_X_train = tape.gradient(loss, model.trainable_weights)
                grad_X_train = np.concatenate([w.numpy().reshape(-1) for w in grad_X_train])
    

    because if w is an instance of IndexedSlices it has no numpy method.

    Type: Bug 
    opened by mauicv 0
Releases(v0.8.0)
  • v0.8.0(Sep 26, 2022)

    v0.8.0 (2022-09-26)

    Full Changelog

    Added

    • New feature PartialDependence and TreePartialDependence explainers implementing partial dependence (PD) global explanations. Also included is a plot_pd utility function for flexible plotting of the resulting PD plots (docs, #721).
    • New exceptions.NotFittedError exception which is raised whenever a compulsory call to a fit method has not been carried out. Specifically, this is now raised in AnchorTabular.explain when AnchorTabular.fit has been skipped (#732).
    • Various improvements to docs and examples (#695, #701, #698, #703, #717, #711, #750, #784).

    Fixed

    • Edge case in AnchorTabular where an error is raised during an explain call if the instance contains a categorical feature value not seen in the training data (#742).

    Changed

    • Improved handling of custom grid_points for the ALE explainer (#731).
    • Renamed our custom exception classes to remove the verbose Alibi* prefix and standardised the *Error suffix. Concretely:
      • exceptions.AlibiPredictorCallException is now exceptions.PredictorCallError
      • exceptions.AlibiPredictorReturnTypeError is now exceptions.PredictorReturnTypeError. Backwards compatibility has been maintained by subclassing the new exception classes by the old ones, but these will likely be removed in a future version (#733).
    • Warn users when TreeShap is used with more than 100 samples in the background dataset which is due to a limitation in the upstream shap package (#710).
    • Minimum version of scikit-learn bumped to 1.0.0 mainly due to upcoming deprecations (#776).
    • Minimum version of scikit-image bumped to 0.17.2 to fix a possible bug when using the slic segmentation function with AnchorImage (#753).
    • Maximum supported version of attrs bumped to 22.x (#727).
    • Maximum supported version of tensorflow bumped to 2.10.x (#745).
    • Maximum supported version of ray bumped to 2.x (#740).
    • Maximum supported version of numba bumped to 0.56.x (#724).
    • Maximum supported version of shap bumped to 0.41.x (#702).
    • Updated shap example notebooks to recommend installing matplotlib==3.5.3 due to failure of shap plotting functions with matplotlib==3.6.0 (#776).

    Development

    • Extend optional dependency checks to ensure the correct submodules are present (#714).
    • Introduce pytest-custom_exit_code to let notebook CI pass when no notebooks are selected for tests (#728).
    • Use UTF-8 encoding when loading README.md in setup.py to avoid a possible failure of installation for some users (#744).
    • Updated guidance for class docstrings (#743).
    • Reinstate ray tests (#756).
    • We now exclude test files from test coverage for a more accurate representation of coverage (#751). Note that this has led to a drop in code covered which will be addressed in due course (#760).
    • The Python 3.10.x version on CI has been pinned to 3.10.6 due to typechecking failures, pending a new release of mypy (#761).
    • The test_changed_notebooks workflow can now be triggered manually and is run on push/PR for any branch (#762).
    • Use codecov flags for more granular reporting of code coverage (#759).
    • Option to ssh into Github Actions runs for remote debugging of CI pipelines (#770).
    • Version of sphinx bumped to 5.x but capped at <5.1.0 to avoid CI failures (#722).
    • Version of myst-parser bumped to 0.18.x (#693).
    • Version of flake8 bumped to 5.x (#729).
    • Version of ipykernel bumped to 6.x (#431).
    • Version of ipython bumped to 8.x (#572).
    • Version of pytest bumped to 7.x (#591).
    • Version of sphinx-design bumped to 0.3.0 (#739).
    • Version of nbconvert bumped to 7.x (#738).
    Source code(tar.gz)
    Source code(zip)
  • v0.7.0(May 18, 2022)

    v0.7.0 (2022-05-18)

    Full Changelog

    This release introduces two new methods, a GradientSimilarity explainer and a ProtoSelect data summarisation algorithm.

    Added

    • New feature GradientSimilarity explainer for explaining predictions of gradient-based (PyTorch and TensorFlow) models by returning the most similar training data points from the point of view of the model (docs).
    • New feature We have introduced a new subpackage alibi.prototypes which contains the ProtoSelect algorithm for summarising datasets with a representative set of "prototypes" (docs).
    • ALE explainer now can take a custom grid-point per feature to evaluate the ALE on. This can help in certain situations when grid-points defined by quantiles might not be the best choice (docs).
    • Extended the IntegratedGradients method target selection to handle explaining any scalar dimension of tensors of any rank (previously only rank-1 and rank-2 were supported). See #635.
    • Python 3.10 support. Note that PyTorch at the time of writing doesn't support Python 3.10 on Windows.

    Fixed

    • Fixed a bug which incorrectly handled multi-dimensional scaling in CounterfactualProto (#646).
    • Fixed a bug in the example using CounterfactualRLTabular (#651).

    Changed

    • tensorflow is now an optional dependency. To use methods that require tensorflow you can install alibi using pip install alibi[tensorflow] which will pull in a supported version. For full instructions for the recommended way of installing optional dependencies please refer to Installation docs.
    • Updated sklearn version bounds to scikit-learn>=0.22.0, <2.0.0.
    • Updated tensorflow maximum allowed version to 2.9.x.

    Development

    • This release introduces a way to manage the absence of optional dependencies. In short, the design is such that if an optional dependency is required for an algorithm but missing, at import time the corresponding public (or private in the case of the optional dependency being required for a subset of the functionality of a private class) algorithm class will be replaced by a MissingDependency object. For full details on developing alibi with optional dependencies see Contributing: Optional Dependencies.
    • The CONTRIBUTING.md has been updated with further instructions for managing optional dependencies (see point above) and more conventions around docstrings.
    • We have split the Explainer base class into Base and Explainer to facilitate reusability and better class hierarchy semantics with introducing methods that are not explainers (#649).
    • mypy has been updated to ~=0.900 which requires additional development dependencies for type stubs, currently only types-requests has been necessary to add to requirements/dev.txt.
    • Fron this release onwards we exclude the directories doc/ and examples/ from the source distribution (by adding prune directives in MANIFEST.in). This results in considerably smaller file sizes for the source distribution.
    Source code(tar.gz)
    Source code(zip)
  • v0.6.5(Mar 18, 2022)

    v0.6.5 (2022-03-18)

    Full Changelog

    This is a patch release to correct a regression in CounterfactualProto introduced in v0.6.3.

    Added

    Fixed

    • Fix a bug introduced in v0.6.3 which prevented CounterfactualProto working with categorical features (#612).
    • Fix an issue with the LanguageModelSampler where it would sometimes sample punctuation (#585).

    Development

    • The maximum tensorflow version has been bumped from 2.7 to 2.8 (#588).
    Source code(tar.gz)
    Source code(zip)
  • v0.6.4(Jan 28, 2022)

    v0.6.4 (2022-01-28)

    Full Changelog

    This is a patch release to correct a regression in AnchorImage introduced in v0.6.3.

    Fixed

    • Fix a bug introduced in v0.6.3 where AnchorImage would ignore user segmentation_kwargs (#581).

    Development

    • The maximum versions of Pillow and scikit-image have been bumped to 9.x and 0.19.x respectively.
    Source code(tar.gz)
    Source code(zip)
  • v0.6.3(Jan 18, 2022)

    v0.6.3 (2022-01-18)

    Full Changelog

    Added

    • New feature A callback can now be passed to IntegratedGradients via the target_fn argument, in order to calculate the scalar target dimension from the model output. This is to bypass the requirement of passing target directly to explain when the target of interest may depend on the prediction output. See the example in the docs. (#523).
    • A new comprehensive Introduction to explainability added to the documentation (#510).

    Changed

    • Python 3.6 has been deprecated from the supported versions as it has reached end-of-life.

    Fixed

    • Fix a bug with passing background images to AnchorImage leading to an error (#542).
    • Fix a bug with rounding errors being introduced in CounterfactualRLTabular (#550).

    Development

    • Docstrings have been updated and consolidated (#548). For developers, docstring conventions have been documented in CONTRIBUTING.md.
    • numpy typing has been updated to be compatible with numpy 1.22 (#543). This is a prerequisite for upgrading to tensorflow 2.7.
    • To further improve reliability, strict Optional type-checking with mypy has been reinstated (#541).
    • The Alibi CI tests now include Windows and MacOS platforms (#575).
    • The maximum tensorflow version has been bumped from 2.6 to 2.7 (#377).
    Source code(tar.gz)
    Source code(zip)
  • v0.6.2(Nov 18, 2021)

    v0.6.2 (2021-11-18)

    Full Changelog

    Added

    • Documentation on using black-box and white-box models in the context of alibi, see here.
    • AnchorTabular, AnchorImage and AnchorText now expose an additional dtype keyword argument with a default value of np.float32. This is to ensure that whenever a user predictor is called internally with dummy data a correct data type can be ensured (#506).
    • Custom exceptions. A new public module alibi.exceptions defining the alibi exception hierarchy. This introduces two exceptions, AlibiPredictorCallException and AlibiPredictorReturnTypeError. See #520 for more details.

    Changed

    • For AnchorImage, coerce image_shape argument into a tuple to implicitly allow passing a list input which eases use of configuration files. In the future the typing will be improved to be more explicit about allowed types with runtime type checking.
    • Updated the minimum shap version to the latest 0.40.0 as this fixes an installation issue if alibi and shap are installed with the same command.

    Fixed

    • Fix a bug with version saving being overwritten on subsequent saves (#481).
    • Fix a bug in the Integrated Gradients notebook with transformer models due to a regression in the upstream transformers library (#528).
    • Fix a bug in IntegratedGradients with forward_kwargs not always being correctly passed (#525).
    • Fix a bug resetting TreeShap predictor (#534).

    Development

    • Now using readthedocs Docker image in our CI to replicate the doc building environment exactly. Also enabled readthedocs build on PR feature which allows browsing the built docs on every PR.
    • New notebook execution testing framework via Github Actions. There are two new GA workflows, test_all_notebooks which is run once a week and can be triggered manually, and test_changed_notebooks which detects if any notebooks have been modified in a PR and executes only those. Not all notebooks are amenable to be tested automatically due to long running times or complex software/hardware dependencies. We maintain a list of notebooks to be excluded in the testing script under testing/test_notebooks.py.
    • Now using myst (a markdown superset) for more flexible documentation (#482).
    • Added a CITATION.cff file.
    Source code(tar.gz)
    Source code(zip)
  • v0.6.1(Sep 2, 2021)

    v0.6.1 (2021-09-02)

    Full Changelog

    Added

    Changed

    • Future breaking change The names of CounterFactual and CounterFactualProto classes have been changed to Counterfactual and CounterfactualProto respectively for consistency and correctness. The old class names continue working for now but emit a deprecation warning message and will be removed in an upcoming version.
    • dill behaviour was changed to not extend the pickle protocol so that standard usage of pickle in a session with alibi does not change expected pickle behaviour. See discussion.
    • AnchorImage internals refactored to avoid persistent state between explain calls.

    Development

    • A PR checklist is available under CONTRIBUTING.md. In the future many of these may be turned into automated checks.
    • pandoc version for docs building updated to 1.19.2 which is what is used on readthedocs.
    • Citation updated to the JMLR paper.
    Source code(tar.gz)
    Source code(zip)
  • v0.6.0(Jul 8, 2021)

    v0.6.0 (2021-07-08)

    Full Changelog

    Added

    • New feature AnchorText now supports sampling according to masked language models via the transformers library. See docs and the example for using the new functionality.
    • Breaking change due to the new masked language model sampling for AnchorText the public API for the constructor has changed. See docs for a full description of the new API.
    • AnchorTabular now supports one-hot encoded categorical variables in addition to the default ordinal/label encoded representation of categorical variables.
    • IntegratedGradients changes to allow explaining a wider variety of models. In particular, a new forward_kwargs argument to explain allows passing additional arguments to the model and attribute_to_layer_inputs flag to allow calculating attributions with respect to layer input instead of output if set to True. The API and capabilities now track more closely to the captum.ai PyTorch implementation.
    • Example of using IntegratedGradients to explain transformer models.
    • Python 3.9 support.

    Fixed

    • IntegratedGradients - fix the path definition for attributions calculated with respect to an internal layer. Previously the paths were defined in terms of the inputs and baselines, now they are correctly defined in terms of the corresponding layer input/output.
    Source code(tar.gz)
    Source code(zip)
  • v0.5.8(Apr 29, 2021)

    v0.5.8 (2021-04-29)

    Full Changelog

    Added

    • Experimental explainer serialization support using dill. See docs for more details.

    Fixed

    • Handle layers which are not part of model.layers for IntegratedGradients.

    Development

    • Update type hints to be compatible with numpy 1.20.
    • Separate licence build step in CI, only check licences against latest Python version.
    Source code(tar.gz)
    Source code(zip)
  • v0.5.7(Mar 31, 2021)

    v0.5.7 (2021-03-31)

    Full Changelog

    Changed

    • Support for KernelShap and TreeShap now requires installing the shap dependency explicitly after installing alibi. This can be achieved by running pip install alibi && pip install alibi[shap]. The reason for this is that the build process for the upstream shap package is not well configured resulting in broken installations as detailed in https://github.com/SeldonIO/alibi/pull/376 and https://github.com/slundberg/shap/pull/1802. We expect this to be a temporary change until changes are made upstream.

    Added

    • A reset_predictor method for black-box explainers. The intended use case for this is for deploying an already configured explainer to work with a remote predictor endpoint instead of the local predictor used in development.
    • alibi.datasets.load_cats function which loads a small sample of cat images shipped with the library to be used in examples.

    Fixed

    • Deprecated the alibi.datasets.fetch_imagenet function as the Imagenet API is no longer available.
    • IntegratedGradients now works with subclassed TensorFlow models.
    • Removed support for calculating attributions wrt multiple layers in IntegratedGradients as this was not working properly and is difficult to do in the general case.

    Development

    • Fixed an issue with AnchorTabular tests not being picked up due to a name change of test data fixtures.
    Source code(tar.gz)
    Source code(zip)
  • v0.5.6(Feb 18, 2021)

    v0.5.6 (2021-02-18)

    Full Changelog

    Added

    • Breaking change IntegratedGradients now supports models with multiple inputs. For each input of the model, attributions are calculated and returned in a list. Also extends the method allowing to calculate attributions for multiple internal layers. If a list of layers is passed, a list of attributions is returned. See https://github.com/SeldonIO/alibi/pull/321.
    • ALE now supports selecting a subset of features to explain. This can be useful to reduce runtime if only some features are of interest and also indirectly helps dealing with categorical variables by being able to exclude them (as ALE does not support categorical variables).

    Fixed

    • AnchorTabular coverage calculation was incorrect which was caused by incorrectly indexing a list, this is now resolved.
    • ALE was causing an error when a constant feature was present. This is now handled explicitly and the user has control over how to handle these features. See https://docs.seldon.io/projects/alibi/en/latest/api/alibi.explainers.ale.html#alibi.explainers.ale.ALE for more details.
    • Release of Spacy 3.0 broke the AnchorText functionality as the way lexeme_prob tables are loaded was changed. This is now fixed by explicitly handling the loading depending on the spacy version.
    • Fixed documentation to refer to the Explanation object instead of the old dict object.
    • Added warning boxes to CounterFactual, CounterFactualProto and CEM docs to explain the necessity of clearing the TensorFlow graph if switching to a new model in the same session.

    Development

    • Introduced lower and upper bounds for library and development dependencies to limit the potential for breaking functionality upon new releases of dependencies.
    • Added dependabot support to automatically monitor new releases of dependencies (both library and development).
    • Switched from Travis CI to Github Actions as the former limited their free tier.
    • Removed unused CI provider configs from the repo to reduce clutter.
    • Simplified development dependencies to just two files, requirements/dev.txt and requirements/docs.txt.
    • Split out the docs building stage as a separate step on CI as it doesn't need to run on every Python version thus saving time.
    • Added .readthedocs.yml to control how user-facing docs are built directly from the repo.
    • Removed testing related entries to setup.py as the workflow is both unused and outdated.
    • Avoid shap==0.38.1 as a dependency as it assumes IPython is installed and breaks the installation.
    Source code(tar.gz)
    Source code(zip)
  • v0.5.5(Oct 20, 2020)

    v0.5.5 (2020-10-20)

    Full Changelog

    Added

    • New feature Distributed backend using ray. To use, install ray using pip install alibi[ray].
    • New feature KernelShap distributed version using the new distributed backend.
    • For anchor methods added an explanation field data['raw']['instances'] which is a batch-wise version of the existing data['raw']['instance']. This is in preparation for the eventual batch support for anchor methods.
    • Pre-commit hook for pyupgrade via nbqa for formatting example notebooks using Python 3.6+ syntax.

    Fixed

    • Flaky test for distributed anchors (note: this is the old non-batchwise implementation) by dropping the precision treshold.
    • Notebook string formatting upgraded to Python 3.6+ f-strings.

    Changed

    • Breaking change For anchor methods, the returned explanation field data['raw']['prediction'] is now batch-wise, i.e. for AnchorTabular and AnchorImage it is a 1-dimensional numpy array whilst for AnchorText it is a list of strings. This is in preparation for the eventual batch support for anchor methods.
    • Removed dependency on prettyprinter and substituted with a slightly modified standard library version of PrettyPrinter. This is to prepare for a conda release which requires all dependencies to also be published on conda.
    Source code(tar.gz)
    Source code(zip)
  • v0.5.4(Sep 3, 2020)

    v0.5.4 (2020-09-03)

    Full Changelog

    Added

    • update_metadata method for any Explainer object to enable easy book-keeping for algorithm parameters

    Fixed

    • Updated KernelShap wrapper to work with the newest shap>=0.36 library
    • Fix some missing metadata parameters in KernelShap and TreeShap
    Source code(tar.gz)
    Source code(zip)
  • v0.5.3(Sep 1, 2020)

    v0.5.3 (2020-09-01)

    Full Changelog

    Changed

    • Updated roadmap

    Fixed

    • Bug in integrated gradients where incorrect layer handling led to output shape mismatch when explaining layer outputs
    • Remove tf.logging calls in example notebooks as TF 2.x API no longer supports tf.logging
    • Pin shap to 0.35.0, pending shap 0.36.0 patch release to support shap API updates/library refactoring
    Source code(tar.gz)
    Source code(zip)
  • v0.5.2(Aug 5, 2020)

    v0.5.2 (2020-08-05)

    Full Changelog

    This release changes the required TensorFlow version from <2.0 to >=2.0. This means that alibi code depends on TenorFlow>=2.0, however the explainer algorithms are compatible for models trained with both TF1.x and TF2.x.

    The alibi code that depends on TensorFlow itself has not been fully migrated in the sense that the code is still not idiomatic TF2.x code just that we now use the tf.compat.v1 package provided by TF2.x internally. This does mean that for the time being to run algorithms which depend on TensorFlow (CounterFactual, CEM and CounterFactualProto) require disabling TF2.x behaviour by running tf.compat.v1.disable_v2_behavior(). This is documented in the example notebooks. Work is underway to re-write the TensorFlow dependent components in idiomatic TF2.x code so that this will not be necessary in a future release.

    The upgrade to TensorFlow 2.x also enables this to be the first release with Python 3.8 support.

    Finally, white-box explainers are now tested with pre-trained models from both TF1.x and TF2.x. The binaries for the models along with loading functionality and datasets used to train these are available in the alibi-testing helper package which is now a requirement for running tests.

    Changed

    • Minimum required TensorFlow version is now 2.0
    • Tests depending on trained models are now run using pre-trained models hosted under the alibi-testing helper package

    Fixed

    • A bug in AnchorText resulting from missing string hash entries in some spacy models (https://github.com/SeldonIO/alibi/pull/276)
    • Explicitly import lazy_fixture in tests instead of relying on the deprecated usage of pytest namespace (https://github.com/SeldonIO/alibi/pull/281)
    • A few bugs in example notebooks
    Source code(tar.gz)
    Source code(zip)
  • v0.5.1(Jul 10, 2020)

    v0.5.1 (2020-07-10)

    Full Changelog

    This is a bug fix release.

    Fixed

    • Fix an issue with AnchorText not working on text instances with commas due to not checking for empty synonym lists
    • Enable correct behaviour of AnchorText with spacy>=2.3.0, this now requires installing spacy[lookups] as an additional dependency which contains model probability tables
    • Update the expected_value attribute of TreeSHAP which is internally updated after a call to explain
    • Fix some links in Integrated Gradients examples
    • Coverage after running tests on Travis is now correctly reported as the reports are merged for different pytest runs
    • Old Keras tests now require Keras<2.4.0 as the new release requires tensorflow>=2.2
    • Bump typing_extensions>=3.7.2 which includes the type Literal
    Source code(tar.gz)
    Source code(zip)
  • v0.5.0(Jun 10, 2020)

    v0.5.0 (2020-06-10)

    Full Changelog

    This version supports Python 3.6 and 3.7 as support for Python 3.5 is dropped.

    Added

    • New feature TreeSHAP explainer for white-box, tree based model SHAP value computation
    • New feature ALE explainer for computing feature effects for black-box, tabular data models
    • New feature IntegratedGradients explainer for computing feature attributions for TensorFlow and Keras models
    • Experimental utils.visualization module currently containing visualization functions for IntegratedGradients on image datasets.The location, implementation and content of the module and functions therein are subject to change.
    • Extend datasets.fetch_imagenet to work with any class
    • Extend utils.data.gen_category_map to take a list of strings of column names

    Changed

    • Internal refactoring of KernelSHAP to reuse functionality for TreeSHAP. Both SHAP wrappers are now under explainers.shap_wrappers
    • Tests are now split into two runs, one with TensorFlow in eager mode which is necessary for using IntegratedGradients
    • Added typing-extensions library as a requirement to take advantage of more precise types
    • Pinned scikit-image<0.17 due to a regression upstream
    • Pinned Sphinx<3.0 for documentation builds due to some issues with the m2r plugin

    Fixed

    • Various improvements to documentation
    • Some tests were importing old keras functions instead of tensorflow.keras
    Source code(tar.gz)
    Source code(zip)
  • v0.4.0(Mar 20, 2020)

    v0.4.0 (2020-03-20)

    Full Changelog

    NB: This is the last version supporting Python 3.5.

    Added

    • New feature KernelSHAP explainer for black-box model SHAP scores
    • Documentation for the LinearityMeasure algorithm

    Changed

    • Breaking change New API for explainer and explanation objects. Explainer objects now inherit from Explainer base class as a minimum. When calling .explain method, an Explanation object is returned (previously a dictionary). This contains two dictionaries meta and data accessed as attributes of the object, detailing the metadata and the data of the returned explanation. The common interfaces are under api.interfaces and default return metadata and data for each explainer are under api.defaults.
    • Complete refactoring of the Anchors algorithms, many code improvements
    • Explainer tests are now more modular, utilizing scoped fixtures defined in explainers.tests.conftest and various utility functions
    • Tests are now run sequentially insted of in parallel due to overhead of launching new processes
    Source code(tar.gz)
    Source code(zip)
  • v0.3.2(Oct 17, 2019)

    v0.3.2 (2019-10-17)

    Full Changelog

    Added

    • All explanations return a metadata field meta with a name subfield which is currently the name of the class

    Changed

    • Provide URL options for fetching some datasets, by default now fetches from a public Seldon bucket
    Source code(tar.gz)
    Source code(zip)
  • v0.3.1(Oct 1, 2019)

  • v0.3.0(Sep 25, 2019)

    v0.3.0 (2019-09-25)

    Full Changelog

    Added

    • New feature LinearityMeasure class and linearity_measure function for measuring the linearity of a classifier/regressor
    • New feature CounterFactualProto now supports categorical variables for tabular data

    Changed

    • Breaking change Remove need for the user to manage TensorFlow sessions for the explanation methods that use TF internally (CEM, CounterFactual, CounterFactualProto). The session is now inferred or created depending on what is passed to predict. For finer control the sess parameter can still be passed in directly
    • Breaking change Expose low-level arguments to AnchorText to the user for finer control of the explanation algorithm, also rename some arguments for consistency
    • Various improvements to existing notebook examples

    Fixed

    • CounterFactualProto and CEM bug when the class is initialized a second time it wouldn't run as the TF graph would become disconnected
    • Provide more useful error messages if external data APIs are down
    • Skip tests using external data APIs if they are down
    Source code(tar.gz)
    Source code(zip)
  • v0.2.3(Jul 29, 2019)

    v0.2.3 (2019-07-29)

    Full Changelog

    Added

    • gen_category_map utility function to facilitate using AnchorTabular explainer
    • Extend CounterFactualProto with a more flexible choice for prototypes using k closest encoded instances
    • Allow user to specify a hard target class for CounterFactualProto
    • Distributed tests usign pytest-xdist to overcome TF global session interfering with tests running in the same process

    Changed

    • Sample datasets now return a Bunch object by default, bundling all necessary and optional attributes for each dataset
    • Loading sample datasets are now invoked via the fetch_ functions to indicate that a network download is being made

    Fixed

    • Remove Home from docs sidebar as this was causing the sidebar logo to not show up on landing page
    Source code(tar.gz)
    Source code(zip)
  • v0.2.2(Jul 5, 2019)

  • v0.2.1(Jul 2, 2019)

    v0.2.1 (2019-07-02)

    Full Changelog

    Changed

    • Remove Keras and seaborn from install requirements and create optional [examples] extras_require
    • Remove python-opencv dependency in favour of PIL
    • Improve type checking with unimported modules - now requires python>3.5.1
    • Add some tests for alibi.datasets
    Source code(tar.gz)
    Source code(zip)
  • v0.2.0(May 24, 2019)

    v0.2.0 (2019-05-24)

    Full Changelog

    New features:

    Implemented enhancements:

    • Return nearest not predicted class for trust scores #63
    • Migrate Keras dependency to tf.keras #51
    • Add warning when no anchor is found #30
    • add anchor warning #74 (arnaudvl)
    • Return closest not predicted class for trust scores #67 (arnaudvl)

    Closed issues:

    • Build docs on Travis #70
    • High level documentation for 0.1 #37
    • Counterfactual explainers #12

    Merged pull requests:

    Source code(tar.gz)
    Source code(zip)
  • v0.1.0(May 3, 2019)

    Change Log

    v0.1.0 (2019-05-03)

    Closed issues:

    • Migrate CI to Travis post release #46
    • Trust scores #39
    • Make explicit Python>=3.5 requirement before release #18
    • Remove dependency on LIME #17
    • Set up CI #5
    • Set up docs #4

    Merged pull requests:

    * This Change Log was automatically generated by github_changelog_generator%

    Source code(tar.gz)
    Source code(zip)
Owner
Seldon
Machine Learning Deployment for Kubernetes
Seldon
Lime: Explaining the predictions of any machine learning classifier

lime This project is about explaining what machine learning classifiers (or models) are doing. At the moment, we support explaining individual predict

Marco Tulio Correia Ribeiro 10.3k Jan 1, 2023
A library that implements fairness-aware machine learning algorithms

Themis ML themis-ml is a Python library built on top of pandas and sklearnthat implements fairness-aware machine learning algorithms. Fairness-aware M

Niels Bantilan 105 Dec 30, 2022
Visualizer for neural network, deep learning, and machine learning models

Netron is a viewer for neural network, deep learning and machine learning models. Netron supports ONNX (.onnx, .pb, .pbtxt), Keras (.h5, .keras), Tens

Lutz Roeder 20.9k Dec 28, 2022
Visualizer for neural network, deep learning, and machine learning models

Netron is a viewer for neural network, deep learning and machine learning models. Netron supports ONNX, TensorFlow Lite, Keras, Caffe, Darknet, ncnn,

Lutz Roeder 16.3k Sep 27, 2021
Interpretability and explainability of data and machine learning models

AI Explainability 360 (v0.2.1) The AI Explainability 360 toolkit is an open-source library that supports interpretability and explainability of datase

null 1.2k Dec 29, 2022
FairML - is a python toolbox auditing the machine learning models for bias.

======== FairML: Auditing Black-Box Predictive Models FairML is a python toolbox auditing the machine learning models for bias. Description Predictive

Julius Adebayo 338 Nov 9, 2022
Visual analysis and diagnostic tools to facilitate machine learning model selection.

Yellowbrick Visual analysis and diagnostic tools to facilitate machine learning model selection. What is Yellowbrick? Yellowbrick is a suite of visual

District Data Labs 3.9k Dec 30, 2022
A collection of research papers and software related to explainability in graph machine learning.

A collection of research papers and software related to explainability in graph machine learning.

AstraZeneca 1.9k Dec 26, 2022
A data-driven approach to quantify the value of classifiers in a machine learning ensemble.

Documentation | External Resources | Research Paper Shapley is a Python library for evaluating binary classifiers in a machine learning ensemble. The

Benedek Rozemberczki 187 Dec 27, 2022
A game theoretic approach to explain the output of any machine learning model.

SHAP (SHapley Additive exPlanations) is a game theoretic approach to explain the output of any machine learning model. It connects optimal credit allo

Scott Lundberg 18.3k Jan 8, 2023
L2X - Code for replicating the experiments in the paper Learning to Explain: An Information-Theoretic Perspective on Model Interpretation.

L2X Code for replicating the experiments in the paper Learning to Explain: An Information-Theoretic Perspective on Model Interpretation at ICML 2018,

Jianbo Chen 113 Sep 6, 2022
JittorVis - Visual understanding of deep learning model.

JittorVis is a deep neural network computational graph visualization library based on Jittor.

null 182 Jan 6, 2023
Portal is the fastest way to load and visualize your deep neural networks on images and videos 🔮

Portal is the fastest way to load and visualize your deep neural networks on images and videos ??

Datature 243 Jan 5, 2023
Many Class Activation Map methods implemented in Pytorch for CNNs and Vision Transformers. Including Grad-CAM, Grad-CAM++, Score-CAM, Ablation-CAM and XGrad-CAM

Class Activation Map methods implemented in Pytorch pip install grad-cam ⭐ Comprehensive collection of Pixel Attribution methods for Computer Vision.

Jacob Gildenblat 6.5k Jan 1, 2023
Bias and Fairness Audit Toolkit

The Bias and Fairness Audit Toolkit Aequitas is an open-source bias audit toolkit for data scientists, machine learning researchers, and policymakers

Data Science for Social Good 513 Jan 6, 2023
treeinterpreter - Interpreting scikit-learn's decision tree and random forest predictions.

TreeInterpreter Package for interpreting scikit-learn's decision tree and random forest predictions. Allows decomposing each prediction into bias and

Ando Saabas 720 Dec 22, 2022
A collection of infrastructure and tools for research in neural network interpretability.

Lucid Lucid is a collection of infrastructure and tools for research in neural network interpretability. We're not currently supporting tensorflow 2!

null 4.5k Jan 7, 2023
tensorboard for pytorch (and chainer, mxnet, numpy, ...)

tensorboardX Write TensorBoard events with simple function call. The current release (v2.1) is tested on anaconda3, with PyTorch 1.5.1 / torchvision 0

Tzu-Wei Huang 7.5k Jan 7, 2023
TensorFlowTTS: Real-Time State-of-the-art Speech Synthesis for Tensorflow 2 (supported including English, Korean, Chinese, German and Easy to adapt for other languages)

?? TensorFlowTTS provides real-time state-of-the-art speech synthesis architectures such as Tacotron-2, Melgan, Multiband-Melgan, FastSpeech, FastSpeech2 based-on TensorFlow 2. With Tensorflow 2, we can speed-up training/inference progress, optimizer further by using fake-quantize aware and pruning, make TTS models can be run faster than real-time and be able to deploy on mobile devices or embedded systems.

null 3k Jan 4, 2023