Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modularized computation of protoypes importance scores #826

Merged
merged 9 commits into from
Jan 4, 2023

Conversation

RobertSamoilescu
Copy link
Collaborator

This PR modularises the computation of prototypes importance scores from the visualisation function. This gives the option to compute the importance and use a different tool to plot the 2D representation of the prototypes.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@codecov
Copy link

codecov bot commented Nov 24, 2022

Codecov Report

Merging #826 (bb43635) into master (91a2a88) will decrease coverage by 0.04%.
The diff coverage is 37.14%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #826      +/-   ##
==========================================
- Coverage   84.65%   84.61%   -0.05%     
==========================================
  Files          74       74              
  Lines        8722     8727       +5     
==========================================
  Hits         7384     7384              
- Misses       1338     1343       +5     
Flag Coverage Δ
macos-latest-3.10 84.47% <37.14%> (-0.15%) ⬇️
ubuntu-latest-3.10 84.47% <37.14%> (-0.15%) ⬇️
ubuntu-latest-3.7 84.35% <37.14%> (-0.17%) ⬇️
ubuntu-latest-3.8 84.49% <37.14%> (-0.05%) ⬇️
ubuntu-latest-3.9 84.40% <37.14%> (-0.15%) ⬇️
windows-latest-3.9 82.13% <37.14%> (-0.14%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
alibi/api/defaults.py 100.00% <ø> (ø)
alibi/prototypes/protoselect.py 65.81% <37.14%> (-1.56%) ⬇️
alibi/explainers/permutation_importance.py 97.09% <0.00%> (-0.02%) ⬇️

alibi/prototypes/protoselect.py Outdated Show resolved Hide resolved
Comment on lines 580 to 582
- ``'prototypes_indices'`` - an array of the prototypes indices.

- ``'prototypes_importance'`` - an array of prototypes importance.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think more grammatically correct would be to call these prototype_indices and prototype_importances?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar for the name of the function.


- ``'X_protos'`` - an array of raw prototypes.

- ``'X_protos_ft'`` - an array of preprocessed prototypes. If the ``preprocess_fn=None``, no preprocessing \
Copy link
Contributor

@jklaise jklaise Nov 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be None (or empty) if there is no pre-processing? Basically do we avoid duplicating the same data?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point!

def compute_prototype_importances(summary: 'Explanation',
trainset: Tuple[np.ndarray, np.ndarray],
preprocess_fn: Optional[Callable[[np.ndarray], np.ndarray]] = None,
knn_kw: Optional[dict] = None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed - missing return type.

@jklaise jklaise merged commit 69a3cac into SeldonIO:master Jan 4, 2023
RobertSamoilescu added a commit to RobertSamoilescu/alibi that referenced this pull request Jan 4, 2023
* Modularized computation of protoypes importance scores from the visualization function.

* Updated .gitignore. Changed notebook kernel.

* Reverted .pymon and .gitignore.

* Duplicate docstrings and reverted example.

* Replaced prototypes_* to prototype_*.

* Avoid duplication when plotting the prototypes

* Updated example notebook.

* Included missing return type.
RobertSamoilescu added a commit to RobertSamoilescu/alibi that referenced this pull request Jan 4, 2023
* Modularized computation of protoypes importance scores from the visualization function.

* Updated .gitignore. Changed notebook kernel.

* Reverted .pymon and .gitignore.

* Duplicate docstrings and reverted example.

* Replaced prototypes_* to prototype_*.

* Avoid duplication when plotting the prototypes

* Updated example notebook.

* Included missing return type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants