diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 26c7082..42244ce 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -56,8 +56,7 @@ Ready to contribute? Here's how to set up `pudu` for local development. $ git clone git@github.com:your_name_here/pudu.git -3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up -your fork for local development:: +3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:: $ mkvirtualenv pudu $ cd pudu/ @@ -67,8 +66,7 @@ your fork for local development:: $ git checkout -b name-of-your-bugfix-or-feature -5. When you're done making changes, check that your changes pass flake8 and the tests, including testing other Python -versions with tox:: +5. When you're done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:: $ flake8 pudu tests $ pytest @@ -97,6 +95,5 @@ Before you submit a pull request, check that it meets these guidelines: 1. The pull request should include tests. Coverage should not go below 70% with `Codecov`. 2. CodeQL should pass. -3. If the pull request adds functionality, the docs should be updated. Add useful -documentation to your functionality so it is included in the `docs`. +3. If the pull request adds functionality, the docs should be updated. Add useful documentation to your functionality so it is included in the `docs`. 4. The pull request should work for Python 3.6 through 3.10. diff --git a/LICENSE b/LICENSE index 0f5a470..d71a319 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022, Institut de Recerca en Energia de Catalunya +Copyright (c) 2023, Institut de Recerca en Energia de Catalunya Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/__init__.py b/__init__.py index 7f60ae5..40ddc44 100644 --- a/__init__.py +++ b/__init__.py @@ -2,4 +2,4 @@ __author__ = """Enric Tomas Grau-Luque""" __email__ = 'patenric@gmail.com' -__version__ = '0.2.0' +__version__ = '0.3.0' diff --git a/docs/_modules/pudu.html b/docs/_modules/pudu.html index 14e8efc..94f715e 100644 --- a/docs/_modules/pudu.html +++ b/docs/_modules/pudu.html @@ -195,12 +195,6 @@
temp, temp2 = perturbation.apply(x_copy, row, col, window, bias)
- # print(np.shape(temp[0,:,:,0]), np.shape(self.x[0,:,:,0]))
- # plt.plot(temp[0,0,:,0])
- # plt.plot(self.x[0,0,:,0])
- # plt.show()
- # exit()
-
if temp2 is None:
val = self.pf(temp) - p0
else:
@@ -620,23 +614,15 @@ Source code for pudu
s_x, s_y = self.x, self.y
master = []
- # master = np.array()
for x, y in zip(s_x, s_y):
x = np.expand_dims(x, 0)
self.x, self.y = x, y
feats, units = self.reactivations(layer, slope, p, window, scope, bias, padding,
- perturbation=perturbation, mask=mask)
+ perturbation, mask)
master.extend((i, j) for i, j in zip(feats, units))
- feats = np.array(feats)
- units = np.array(units)
- master = np.column_stack((feats, units))
-
- master = master.tolist()
-
- master = [tuple(arr) for arr in master]
counts = Counter(master)
result = [[j, count, i] for (i, j), count in counts.items()]
result = np.transpose(result)
diff --git a/docs/_sources/examples.rst.txt b/docs/_sources/examples.rst.txt
index 5da074a..3edd191 100644
--- a/docs/_sources/examples.rst.txt
+++ b/docs/_sources/examples.rst.txt
@@ -8,44 +8,50 @@ Example 1: PC-LDA with Scikit-learn for classification of spectroscopic data
:linenos:
-Examples 2: Regression for predicition of open circuit voltage of solar cells with RBFN
+Example 2: Regression for predicition of open circuit voltage of solar cells with RBFN
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. literalinclude:: ../examples/example_rbnf.py
:language: python
-Examples 3: Handwritten numbers recognition using CNN with Keras and Mnist
+Example 3: Handwritten numbers recognition using CNN with Keras and Mnist
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. literalinclude:: ../examples/example_cnn_mnist.py
:language: python
-Examples 4: How to call different masks
+Example 4: How to call different masks
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. literalinclude:: ../examples/example_masking.py
:language: python
-Examples 5: How to call different perturbations
+Example 5: How to call different perturbations
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. literalinclude:: ../examples/example_perturbation.py
:language: python
-Examples 6: Re-activations with 1-D CNN
+Example 6: Re-activations with 1-D CNN
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. literalinclude:: ../examples/example_activations_1d.py
:language: python
-Examples 7: Re-activations with 2-D CNN
+Example 7: Re-activations with 2-D CNN
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. literalinclude:: ../examples/example_activations_2d.py
:language: python
-
\ No newline at end of file
+
+
+Example 8: SEelcting specific sections to evaluate
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. literalinclude:: ../examples/example_specific_sections.py
+ :language: python
\ No newline at end of file
diff --git a/docs/contributions.html b/docs/contributions.html
index 6aa78d5..ca75928 100644
--- a/docs/contributions.html
+++ b/docs/contributions.html
@@ -136,29 +136,25 @@ Get Started!$ mkvirtualenv pudu
$ cd pudu/
$ python setup.py develop
-
+
Create a branch for local development to make changes locally:
$ git checkout -b name-of-your-bugfix-or-feature
-
-5. When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python
-versions with tox:
+
When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:
$ flake8 pudu tests
$ pytest
$ tox
Run unittest, check the test coverage, and create a coverage report in the tests folder:
$ coverage run -m unittest test_pudu.py
$ coverage xml
@@ -185,10 +181,9 @@ Pull Request Guidelines
The pull request should include tests. Coverage should not go below 70% with Codecov.
CodeQL should pass.
+If the pull request adds functionality, the docs should be updated. Add useful documentation to your functionality so it is included in the docs.
+The pull request should work for Python 3.6 through 3.10.
-3. If the pull request adds functionality, the docs should be updated. Add useful
-documentation to your functionality so it is included in the docs.
-4. The pull request should work for Python 3.6 through 3.10.
diff --git a/docs/examples.html b/docs/examples.html
index 7b3de1f..35f4eb1 100644
--- a/docs/examples.html
+++ b/docs/examples.html
@@ -51,12 +51,13 @@
Mask Functions
Examples
- Example 1: PC-LDA with Scikit-learn for classification of spectroscopic data
-- Examples 2: Regression for predicition of open circuit voltage of solar cells with RBFN
-- Examples 3: Handwritten numbers recognition using CNN with Keras and Mnist
-- Examples 4: How to call different masks
-- Examples 5: How to call different perturbations
-- Examples 6: Re-activations with 1-D CNN
-- Examples 7: Re-activations with 2-D CNN
+- Example 2: Regression for predicition of open circuit voltage of solar cells with RBFN
+- Example 3: Handwritten numbers recognition using CNN with Keras and Mnist
+- Example 4: How to call different masks
+- Example 5: How to call different perturbations
+- Example 6: Re-activations with 1-D CNN
+- Example 7: Re-activations with 2-D CNN
+- Example 8: SEelcting specific sections to evaluate
Contributing
@@ -184,8 +185,8 @@ Example 1: PC-LDA with Scikit-learn for classification of spectroscopic data
from localreg import RBFnet
from sklearn.metrics import r2_score
import matplotlib.pyplot as plt
@@ -256,8 +257,8 @@ Examples 2: Regression for predicition of open circuit voltage of solar cell
import matplotlib.pyplot as plt
from lime import lime_tabular
import spectrapepper as spep
@@ -444,8 +445,8 @@ Examples 4: How to call different masks
-Examples 5: How to call different perturbations
+
+Example 5: How to call different perturbations
import matplotlib.pyplot as plt
from lime import lime_tabular
import spectrapepper as spep
@@ -496,8 +497,8 @@ Examples 5: How to call different perturbations
-Examples 6: Re-activations with 1-D CNN
+
+Example 6: Re-activations with 1-D CNN
import numpy as np
from tensorflow import keras
from keras.models import load_model
@@ -572,8 +573,8 @@ Examples 6: Re-activations with 1-D CNN
-Examples 7: Re-activations with 2-D CNN
+
+Example 7: Re-activations with 2-D CNN
import numpy as np
from tensorflow import keras
from keras.models import load_model
@@ -655,6 +656,70 @@ Examples 7: Re-activations with 2-D CNN
+Example 8: SEelcting specific sections to evaluate
+import spectrapepper as spep
+import numpy as np
+import pickle
+
+from pudu import pudu, plots
+
+
+# Load features (spectra) and targets (open circuit coltage, voc)
+features = spep.load('data/features.txt')
+targets = spep.load('data/targets.txt', transpose=True)[2]
+
+# Load pre-trained LDA and PCA models
+lda = pickle.load(open('data/lda_model.sav', 'rb'))
+pca = pickle.load(open('data/pca_model.sav', 'rb'))
+
+
+### PUDU ###
+# Select x (feature) and respective y (target)
+x = features[100]
+x_len = len(x)
+x = x[np.newaxis, np.newaxis, :, np.newaxis]
+y = targets[100]
+
+# Input should be 4d: (batch * rows * columns * depth)
+# This is a classification problem, thus the output should be the
+# probability by category: [prob_1, prob_2, ..., prob_c]
+def pf(X):
+ X = X[0,:,:,0]
+ return lda.predict_proba(pca.transform(X))[0]
+
+# Build pudu
+imp = pudu.pudu(x, y, pf)
+
+# To evaluate more specific areas, we can do ir one-by-one and the
+# put them all together in a vector for plotting and/or normalizing.
+# This can be done for `importnace` and `speed` only.
+
+# For this, we first define the areas of interest
+areas = [[170, 200],[225, 250], [250, 290], [300, 330]]
+
+# In aloop we evaluate them individially. We make sure that `window`
+# and `scope` are equal so all the area is evaluated. The results are
+# saved in `custom`.
+custom = np.zeros(x_len)
+for i in areas:
+ imp.importance(window=int(i[1]-i[0]), scope=(i[0], i[1]))
+ custom[imp.imp[0, 0, :, 0] != 0] = imp.imp[0, 0, imp.imp[0, 0, :, 0] != 0, 0]
+
+custom = custom[np.newaxis, np.newaxis, :, np.newaxis]
+plots.plot(imp.x, custom, title="Importance", yticks=[], font_size=15, cmap='jet')
+
+# Repeat the same for `speed`.
+custom = np.zeros(x_len)
+for i in areas:
+ imp.speed(window=int(i[1]-i[0]), scope=(i[0], i[1]))
+ custom[imp.spe[0, 0, :, 0] != 0] = imp.spe[0, 0, imp.spe[0, 0, :, 0] != 0, 0]
+
+custom = custom[np.newaxis, np.newaxis, :, np.newaxis]
+plots.plot(imp.x, custom, title="Speed", yticks=[], font_size=15, cmap='jet')
+
+
+
diff --git a/docs/searchindex.js b/docs/searchindex.js
index 975848a..10ca193 100644
--- a/docs/searchindex.js
+++ b/docs/searchindex.js
@@ -1 +1 @@
-Search.setIndex({"docnames": ["contributions", "definitions", "examples", "index", "introduction", "masks", "perturbations", "pudu"], "filenames": ["contributions.rst", "definitions.rst", "examples.rst", "index.rst", "introduction.rst", "masks.rst", "perturbations.rst", "pudu.rst"], "titles": ["Contributing", "Definitions", "Examples", "<no title>", "Introduction to pudu", "Mask Functions", "Perturbation Functions", "pudu"], "terms": {"ar": [0, 1, 2, 7], "welcom": 0, "thei": 0, "greatli": 0, "appreci": 0, "everi": 0, "littl": 0, "bit": 0, "help": [0, 2, 4], "credit": [0, 3], "alwai": [0, 5], "given": [0, 5], "you": [0, 2, 4], "can": [0, 1, 2, 7], "mani": [0, 1, 2], "wai": [0, 2, 4, 7], "http": [0, 4], "github": [0, 4], "com": [0, 4], "pudu": [0, 2, 3], "py": [0, 4], "issu": 0, "If": [0, 4, 7], "pleas": [0, 4, 7], "includ": [0, 2], "your": [0, 2], "oper": 0, "system": 0, "name": [0, 2], "version": 0, "ani": [0, 4], "detail": 0, "about": 0, "local": [0, 1, 7], "setup": 0, "might": [0, 2], "troubleshoot": 0, "step": 0, "reproduc": 0, "look": [0, 1], "through": [0, 1], "anyth": 0, "tag": 0, "want": [0, 2], "i": [0, 1, 2, 4, 5, 6, 7], "open": [0, 3], "whoever": 0, "enhanc": 0, "could": [0, 2], "us": [0, 1, 3, 4, 5, 7], "more": [0, 1, 2], "whether": 0, "part": 0, "offici": 0, "doc": [0, 4], "docstr": 0, "The": [0, 1, 2, 4, 5, 6, 7], "best": 0, "send": 0, "file": [0, 2], "an": [0, 1, 2, 4, 6, 7], "propos": 0, "explain": [0, 2, 4], "how": [0, 1, 3, 4, 7], "would": [0, 1, 2], "work": [0, 2, 4, 7], "keep": [0, 2], "scope": [0, 2, 7], "narrow": 0, "possibl": [0, 1, 7], "make": [0, 2], "easier": [0, 7], "rememb": 0, "thi": [0, 1, 2, 4, 7], "volunt": 0, "driven": 0, "project": [0, 4], "readi": 0, "here": [0, 1], "": [0, 1, 2, 7], "set": [0, 1, 2, 6, 7], "up": [0, 4], "develop": 0, "fork": 0, "repo": [0, 4], "clone": 0, "git": 0, "your_name_her": 0, "3": [0, 3], "instal": [0, 4], "copi": 0, "virtualenv": 0, "assum": 0, "have": [0, 1, 2, 7], "virtualenvwrapp": 0, "mkvirtualenv": 0, "cd": 0, "python": [0, 4], "creat": [0, 2, 4], "branch": 0, "chang": [0, 1, 2, 4, 6, 7], "checkout": 0, "b": [0, 1], "bugfix": 0, "5": [0, 3], "when": [0, 2, 4], "re": [0, 3, 4], "done": 0, "check": [0, 2], "pass": [0, 1, 7], "flake8": 0, "test": [0, 2, 4, 7], "other": [0, 1, 2, 7], "tox": 0, "pytest": 0, "run": [0, 4], "unittest": 0, "coverag": 0, "folder": 0, "m": [0, 1, 4], "test_pudu": 0, "xml": 0, "independ": 0, "what": [0, 1, 2], "do": [0, 7], "all": [0, 1, 2, 3, 5, 6, 7], "must": [0, 7], "add": 0, "function": [0, 1, 2, 3, 4, 7], "like": [0, 2], "class": [0, 1, 2, 5, 6, 7], "commit": 0, "push": 0, "descript": 0, "origin": [0, 1], "websit": 0, "befor": [0, 6], "meet": 0, "should": [0, 2], "go": 0, "below": [0, 6], "70": 0, "codecov": 0, "codeql": 0, "updat": [0, 4], "so": [0, 2, 7], "4": [0, 3], "6": [0, 3], "10": [0, 2, 6], "let": 1, "x": [1, 2, 7], "2": [1, 3, 4, 5, 6], "d": [1, 3, 4], "arrai": [1, 2, 6], "dimens": 1, "h": 1, "time": [1, 2, 7], "w": [1, 2], "p_m": 1, "probabl": [1, 2, 4, 7], "model": [1, 2, 7], "Then": [1, 2], "belong": 1, "classif": [1, 3, 4, 7], "accord": [1, 2, 4, 7], "problem": [1, 2, 4, 7], "solv": 1, "consid": [1, 2, 4], "j": [1, 2], "featur": [1, 2, 3, 7], "posit": [1, 2, 3, 6, 7], "h_j": 1, "w_j": 1, "li": 1, "said": 1, "defin": 1, "li_j": 1, "left": [1, 7], "right": [1, 7], "r_j": 1, "where": [1, 2], "r": [1, 6], "perturb": [1, 3, 7], "rel": [1, 4], "ri": 1, "denot": 1, "ri_j": 1, "frac": 1, "min": [1, 2], "max": [1, 2], "contain": [1, 2], "sampl": [1, 2], "differ": [1, 3, 7], "state": [1, 5], "paramet": [1, 2, 5, 6, 7], "r_1": 1, "r_2": 1, "As": 1, "perturbaion": 1, "li_": 1, "1": [1, 3, 4, 5, 6, 7], "slope": [1, 2, 7], "calcul": [1, 2, 4, 6, 7], "linear": [1, 6], "fit": 1, "point": [1, 2, 7], "fast": [1, 2, 4, 7], "imort": 1, "accod": 1, "sensit": 1, "These": 1, "neg": [1, 2, 3, 6], "valu": [1, 2, 6, 7], "depend": [1, 2], "A": [1, 4, 6], "mean": [1, 2, 6], "bigger": 1, "produc": 1, "prediciton": 1, "smaller": 1, "predict": [1, 2, 7], "distinct": 1, "from": [1, 2, 4, 7], "x_i": 1, "both": [1, 4, 6], "under": 1, "obtain": [1, 2], "x_": 1, "foral": 1, "neq": 1, "indic": [1, 2, 3, 7], "complement": [1, 2], "each": [1, 2, 7], "term": 1, "anf": 1, "effec": 1, "tion": 1, "In": [1, 2, 4, 7], "convolut": 1, "layer": [1, 2, 7], "l": 1, "group": [1, 2], "number": [1, 3, 7], "k": [1, 2], "size": [1, 2, 7], "input": [1, 2, 5, 6, 7], "kernel": 1, "k_h": 1, "k_w": 1, "stride": 1, "s_h": 1, "s_w": 1, "filter": 1, "f": 1, "specif": [1, 2, 5, 6, 7], "h_o": 1, "w_o": 1, "output": [1, 2, 7], "bau": 1, "zhou": 1, "et": 1, "al": 1, "2017": 1, "take": [1, 6], "a_k": 1, "distribut": [1, 6], "individu": 1, "subset": 1, "p": [1, 2, 7], "quantil": 1, "t_k": 1, "were": 1, "abov": [1, 4, 6], "which": [1, 2, 4, 5, 6, 7], "exist": 1, "evalu": [1, 2, 5], "base": [1, 6], "data": [1, 3], "x_j": 1, "b_k": 1, "delta": [1, 2, 6, 7], "b_": 1, "pre": [1, 2], "activatoin": 1, "we": [1, 2], "extract": [1, 2], "select": [1, 2, 7], "a_": 1, "final": [1, 2], "case": [1, 2, 4, 7], "deriv": 1, "latter": 1, "account": 1, "after": [1, 2], "For": [1, 2], "exampl": [1, 3, 4, 7], "ha": [1, 4], "u": [1, 2], "same": [1, 2, 7], "rightarrow": 1, "0": [1, 2, 5, 6, 7], "relu": [1, 2, 3, 6, 7], "leakyrelu": [1, 2, 3, 6], "word": [1, 7], "signific": [1, 7], "accor": 1, "With": 1, "follow": [1, 4], "inform": [1, 2], "per": 1, "most": [1, 2], "though": 1, "singl": [1, 2, 6], "better": [1, 2], "them": 1, "khosla": 1, "aud": 1, "o": 1, "torralba": 1, "network": 1, "dissect": 1, "quantifi": [1, 4], "interpret": 1, "deep": 1, "visual": [1, 2], "represent": 1, "import": [2, 3, 4, 7], "matplotlib": 2, "pyplot": 2, "plt": 2, "lime": 2, "lime_tabular": 2, "spectrapepp": 2, "spep": 2, "numpi": 2, "np": 2, "pickl": 2, "plot": [2, 4], "load": 2, "spectra": 2, "target": [2, 7], "coltag": 2, "voc": 2, "txt": 2, "transpos": 2, "true": 2, "train": [2, 7], "pca": 2, "lda_model": 2, "sav": 2, "rb": 2, "pca_model": 2, "first": 2, "try": [2, 4], "see": [2, 4, 7], "need": [2, 4, 7], "wrap": [2, 7], "def": 2, "pcalda_proba": 2, "transform": 2, "return": [2, 5, 6], "predict_proba": 2, "categor": [2, 7], "correct": 2, "format": [2, 4, 7], "fn": 2, "str": [2, 7], "rang": [2, 6], "len": 2, "100": 2, "cf": 2, "instanc": 2, "limetabularexplain": 2, "mode": 2, "feature_nam": 2, "categorical_featur": 2, "verbos": 2, "fals": [2, 7], "exp": [2, 3, 6], "explain_inst": 2, "num_featur": 2, "num_sampl": 2, "1000": 2, "reformat": 2, "order": [2, 4], "over": 2, "e": [2, 4, 7], "as_list": 2, "lm": 2, "_": 2, "1536": 2, "int": [2, 5, 6, 7], "split": 2, "result": [2, 4, 7], "rc": 2, "font": 2, "15": 2, "figur": 2, "figsiz": 2, "14": 2, "imshow": 2, "expand_dim": 2, "cmap": 2, "green": 2, "aspect": 2, "auto": 2, "interpol": 2, "nearest": 2, "extent": 2, "alpha": [2, 6], "colorbar": 2, "titl": [2, 4], "xlabel": 2, "ylabel": 2, "intens": 2, "ytick": 2, "show": 2, "respect": 2, "y": [2, 7], "newaxi": 2, "4d": [2, 6], "batch": [2, 7], "row": [2, 7], "column": [2, 7], "depth": [2, 7], "thu": 2, "categori": 2, "prob_1": 2, "prob_2": 2, "prob_c": 2, "pf": [2, 7], "build": 2, "imp": 2, "vanilla": 2, "one": [2, 4], "except": 2, "window": [2, 7], "50": 2, "font_siz": 2, "pixel": 2, "irrelev": 2, "spectroscopi": 2, "togeth": 2, "speed": [2, 3, 4, 7], "spe": 2, "ot": 2, "main": [2, 4], "raman": 2, "peak": 2, "aprox": 2, "3rd": 2, "its": 2, "synergi": [2, 3, 4, 7], "rest": 2, "inspect": [2, 7], "syn": 2, "localreg": 2, "rbfnet": 2, "sklearn": 2, "metric": 2, "r2_score": 2, "ptn": 2, "msk": 2, "area": 2, "ra": 2, "shuffl": 2, "spearat": 2, "type": [2, 5, 6, 7], "ra0": 2, "ra1": 2, "ra2": 2, "ra3": 2, "ra0_t": 2, "ra1_t": 2, "ra2_t": 2, "ra3_t": 2, "voc_t": 2, "1494": 2, "ra0_tr": 2, "ra1_tr": 2, "ra2_tr": 2, "ra3_tr": 2, "voc_tr": 2, "prepar": 2, "rbnf": 2, "t": 2, "z": 2, "net": 2, "num": 2, "200": 2, "z_hat": 2, "z_hat_t": 2, "print": 2, "r2": 2, "round": 2, "scatter": 2, "c": [2, 4, 6], "blue": 2, "rbf_pred": 2, "bidirect": [2, 3, 6, 7], "ouput": [2, 7], "axi": 2, "tick": 2, "a1": 2, "a2": 2, "a3": 2, "a4": 2, "25": 2, "show_data": 2, "xtick": 2, "tensorflow": 2, "load_model": 2, "num_class": 2, "input_shap": 2, "28": 2, "between": [2, 4, 5, 7], "x_train": 2, "y_train": 2, "x_test": 2, "y_test": 2, "dataset": 2, "load_data": 2, "scale": [2, 6], "imag": [2, 4], "astyp": 2, "float32": 2, "255": 2, "sure": 2, "shape": 2, "convert": 2, "vector": [2, 5, 7], "binari": [2, 3, 6], "matric": 2, "util": 2, "to_categor": 2, "mnist_class": 2, "h5": 2, "summari": [2, 7], "score": 2, "loss": 2, "accuraci": 2, "cnn2d_prob": 2, "diment": 2, "standar": 2, "argmax": 2, "tupl": [2, 6], "width": [2, 7], "height": 2, "none": [2, 5, 7], "pad": [2, 7], "center": [2, 7], "cool": 2, "some": 2, "bia": [2, 7], "those": 2, "sinc": 2, "lime_imag": 2, "skimag": 2, "segment": 2, "mark_boundari": 2, "color": 2, "gray2rgb": 2, "3d": 2, "rgb": 2, "our": 2, "non": 2, "2d": 2, "rbg": 2, "limeimageexplain": 2, "explan": 2, "batch_siz": 2, "temp": 2, "get_image_and_mask": 2, "top_label": 2, "positive_onli": 2, "hide_rest": 2, "grad": 2, "cam": 2, "tf": 2, "ipython": 2, "displai": 2, "cm": 2, "make_gradcam_heatmap": 2, "img_arrai": 2, "last_conv_layer_nam": 2, "pred_index": 2, "map": 2, "last": 2, "conv": 2, "well": 2, "grad_model": 2, "get_lay": 2, "comput": 2, "gradient": [2, 7], "top": 2, "gradienttap": 2, "tape": 2, "last_conv_layer_output": 2, "pred": 2, "class_channel": 2, "neuron": 2, "chosen": 2, "regard": 2, "entri": [2, 6], "channel": 2, "pooled_grad": 2, "reduce_mean": 2, "multipli": 2, "sum": 2, "heatmap": 2, "squeez": 2, "purpos": 2, "also": 2, "normal": [2, 4], "maximum": [2, 7], "math": 2, "reduce_max": 2, "conv2d_5": 2, "remov": [2, 4], "softmax": 2, "gener": [2, 7], "jet": 2, "75": 2, "allow": 2, "cover": 2, "featuresof": 2, "analysi": [2, 7], "It": [2, 4, 7], "serv": 2, "ni": 2, "structur": 2, "pattern": 2, "option": [2, 7], "avail": [2, 4], "everyoth": [2, 3, 5], "random": [2, 5, 6], "randommask": [2, 3, 5], "m_name": 2, "zip": 2, "absolut": [2, 4, 7], "averag": 2, "positevli": 2, "neativ": 2, "natur": 2, "difer": 2, "yield": 2, "note": 2, "onli": [2, 7], "pert": 2, "ptn_name": 2, "for_1d_cnn_c3": 2, "0_526_model_": 2, "80": 2, "79": 2, "cnn1d_prob": 2, "y0": 2, "x0": 2, "150": 2, "now": 2, "explor": [2, 4], "unit": [2, 6, 7], "observ": 2, "005": [2, 7], "less": 2, "being": 2, "reactiv": [2, 7], "0025": 2, "lac": 2, "n\u00ba": 2, "There": 2, "frequent": 2, "too": 2, "report": [2, 3, 7], "feature_report": 2, "fac": 2, "print_report": 2, "show_top": 2, "unit_report": 2, "uac": 2, "To": 2, "coordin": [2, 7], "preview": 2, "bold": 2, "infomr": 2, "sever": 2, "relat": [2, 7], "appli": [2, 5, 6, 7], "n": 2, "reshap": 2, "14730": 2, "anoth": 2, "idx": 2, "cnt": 2, "cor": 2, "icc": 2, "index": [2, 3], "count": [2, 7], "relate_report": 2, "20": 2, "rot_tick": 2, "45": 2, "sort": 2, "12": 2, "low": 2, "30": [2, 6], "90": 2, "introduct": 3, "quickstart": 3, "definit": 3, "activ": [3, 7], "activaiton": 3, "refer": [3, 4, 7], "constant": [3, 6], "custom": [3, 5, 6], "gaussian": [3, 6], "gaussiannois": [3, 6], "invers": [3, 6], "log": [3, 6], "lowerthreshold": [3, 6], "offset": [3, 6], "randomptn": [3, 6], "sigmoid": [3, 6], "sinusoid": [3, 6], "softplu": [3, 6], "tanh": [3, 6], "uniformnois": [3, 6], "upperthreshold": [3, 6], "mask": [3, 7], "odd": [3, 5], "pair": [3, 5], "percentag": [3, 5, 6], "quantiti": [3, 5], "pc": 3, "lda": 3, "scikit": [3, 4], "learn": [3, 4], "spectroscop": 3, "regress": [3, 7], "predicit": 3, "circuit": 3, "voltag": 3, "solar": 3, "cell": 3, "rbfn": 3, "handwritten": 3, "recognit": 3, "cnn": 3, "kera": [3, 4, 7], "mnist": 3, "call": 3, "7": 3, "contribut": 3, "bug": 3, "fix": 3, "implement": 3, "write": 3, "document": [3, 4, 7], "submit": 3, "feedback": 3, "get": 3, "start": [3, 7], "pull": 3, "request": 3, "guidelin": 3, "tabl": 3, "librari": 4, "machin": 4, "learinng": 4, "algorithm": [4, 7], "agnost": 4, "determinist": 4, "simpl": 4, "io": 4, "pypi": 4, "org": 4, "conda": 4, "forg": 4, "anaconda": 4, "free": 4, "softwar": 4, "mit": 4, "licens": 4, "packag": 4, "intepret": 4, "machinm": 4, "algorythm": 4, "doe": [4, 7], "method": [4, 5], "vectror": 4, "exact": 4, "procedur": 4, "list": [4, 5, 7], "enabl": 4, "estim": 4, "oif": 4, "preditci0on": 4, "teh": 4, "easi": 4, "pip": 4, "find": 4, "citat": 4, "misc": 4, "grau": 4, "luque2023pudu": 4, "author": 4, "luqu": 4, "becerril": 4, "romero": 4, "perez": 4, "rodriguez": 4, "guc": 4, "v": 4, "izquierdo": 4, "roca": 4, "year": 4, "2023": 4, "publish": 4, "journal": 4, "repositori": 4, "howpublish": 4, "url": 4, "stai": 4, "date": 4, "encount": 4, "uninstal": 4, "wa": 4, "cookiecutt": 4, "giswq": 4, "pypackag": 4, "templat": 4, "sourc": [5, 6, 7], "regardless": 5, "initi": 5, "is_eo": 5, "section": 5, "otherwis": 5, "even": 5, "float": [5, 6, 7], "qty": 5, "integ": 5, "percetag": 6, "th": 6, "upper": 6, "lower": 6, "threshold": [6, 7], "replac": 6, "func": 6, "callabl": 6, "argument": [6, 7], "exponenti": 6, "expon": 6, "stdv": 6, "standard": 6, "deviat": 6, "nois": 6, "leaki": 6, "rectifi": 6, "coeffici": 6, "logarithm": 6, "certain": 6, "specifi": [6, 7], "ad": [6, 7], "sf": 6, "factor": 6, "freq": 6, "amp": 6, "frequenc": 6, "sine": 6, "wave": 6, "amplitud": 6, "hyperbol": 6, "tangent": 6, "uniform": 6, "bound": 6, "either": 5, "__init__": 7, "constructor": 7, "analyz": 7, "descriptor": 7, "diention": 7, "sclaar": 7, "inclus": 7, "default": 7, "layer_activ": 7, "unit_activ": 7, "evolut": 7, "object": 7, "changeg": 7, "tuppl": 7, "end": 7, "analys": 7, "string": 7, "legnth": 7, "divis": 7, "equal": 7, "side": 7, "paad": 7, "applyi": 7, "length": 7, "perfet": 7, "ipad": 7, "bool": 7, "weather": 7, "within": 7, "exactli": 7, "desir": 7, "global": 7, "strategi": 7, "kwarg": 7, "dict": 7, "addit": 7, "keyword": 7, "curv": 7, "form": 7, "variat": 7}, "objects": {"": [[5, 0, 0, "-", "masks"], [6, 0, 0, "-", "perturbation"]], "masks": [[5, 1, 1, "", "All"], [5, 1, 1, "", "Custom"], [5, 1, 1, "", "EveryOther"], [5, 1, 1, "", "Odds"], [5, 1, 1, "", "Pairs"], [5, 1, 1, "", "Percentage"], [5, 1, 1, "", "Quantity"], [5, 1, 1, "", "RandomMask"]], "perturbation": [[6, 1, 1, "", "Bidirectional"], [6, 1, 1, "", "Binary"], [6, 1, 1, "", "Constant"], [6, 1, 1, "", "Custom"], [6, 1, 1, "", "Exp"], [6, 1, 1, "", "Gaussian"], [6, 1, 1, "", "GaussianNoise"], [6, 1, 1, "", "Inverse"], [6, 1, 1, "", "LeakyReLU"], [6, 1, 1, "", "Log"], [6, 1, 1, "", "LowerThreshold"], [6, 1, 1, "", "Negative"], [6, 1, 1, "", "Offset"], [6, 1, 1, "", "Positive"], [6, 1, 1, "", "RandomPtn"], [6, 1, 1, "", "ReLU"], [6, 1, 1, "", "Sigmoid"], [6, 1, 1, "", "Sinusoidal"], [6, 1, 1, "", "Softplus"], [6, 1, 1, "", "Tanh"], [6, 1, 1, "", "UniformNoise"], [6, 1, 1, "", "UpperThreshold"]], "pudu": [[7, 1, 1, "", "pudu"]], "pudu.pudu": [[7, 2, 1, "", "__init__"], [7, 2, 1, "", "importance"], [7, 2, 1, "", "reactivations"], [7, 2, 1, "", "relatable"], [7, 2, 1, "", "speed"], [7, 2, 1, "", "synergy"]]}, "objtypes": {"0": "py:module", "1": "py:class", "2": "py:method"}, "objnames": {"0": ["py", "module", "Python module"], "1": ["py", "class", "Python class"], "2": ["py", "method", "Python method"]}, "titleterms": {"contribut": 0, "report": 0, "bug": 0, "fix": 0, "implement": 0, "featur": [0, 4], "write": 0, "document": 0, "submit": 0, "feedback": 0, "get": 0, "start": 0, "pull": 0, "request": 0, "guidelin": 0, "definit": 1, "import": 1, "speed": 1, "synergi": 1, "activ": [1, 2], "re": [1, 2], "activaiton": 1, "unit": 1, "acitv": 1, "map": 1, "refer": 1, "exampl": 2, "1": 2, "pc": 2, "lda": 2, "scikit": 2, "learn": 2, "classif": 2, "spectroscop": 2, "data": 2, "2": 2, "regress": 2, "predicit": 2, "open": 2, "circuit": 2, "voltag": 2, "solar": 2, "cell": 2, "rbfn": 2, "3": 2, "handwritten": 2, "number": 2, "recognit": 2, "us": 2, "cnn": 2, "kera": 2, "mnist": 2, "4": 2, "how": 2, "call": 2, "differ": 2, "mask": [2, 5], "5": 2, "perturb": [2, 6], "6": 2, "d": 2, "7": 2, "content": 3, "introduct": 4, "pudu": [4, 7], "quickstart": 4, "credit": 4, "function": [5, 6]}, "envversion": {"sphinx.domains.c": 2, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 8, "sphinx.domains.index": 1, "sphinx.domains.javascript": 2, "sphinx.domains.math": 2, "sphinx.domains.python": 3, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx.ext.todo": 2, "sphinx.ext.viewcode": 1, "sphinx": 57}, "alltitles": {"Contributing": [[0, "contributing"]], "Report Bugs": [[0, "report-bugs"]], "Fix Bugs": [[0, "fix-bugs"]], "Implement Features": [[0, "implement-features"]], "Write Documentation": [[0, "write-documentation"]], "Submit Feedback": [[0, "submit-feedback"]], "Get Started!": [[0, "get-started"]], "Pull Request Guidelines": [[0, "pull-request-guidelines"]], "Definitions": [[1, "definitions"]], "Importance": [[1, "importance"]], "Speed": [[1, "speed"]], "Synergy": [[1, "synergy"]], "Activations and re-activaiton": [[1, "activations-and-re-activaiton"]], "Units": [[1, "units"]], "Acitvation map": [[1, "acitvation-map"]], "Re-activation map": [[1, "re-activation-map"]], "References": [[1, "references"]], "Examples": [[2, "examples"]], "Example 1: PC-LDA with Scikit-learn for classification of spectroscopic data": [[2, "example-1-pc-lda-with-scikit-learn-for-classification-of-spectroscopic-data"]], "Examples 2: Regression for predicition of open circuit voltage of solar cells with RBFN": [[2, "examples-2-regression-for-predicition-of-open-circuit-voltage-of-solar-cells-with-rbfn"]], "Examples 3: Handwritten numbers recognition using CNN with Keras and Mnist": [[2, "examples-3-handwritten-numbers-recognition-using-cnn-with-keras-and-mnist"]], "Examples 4: How to call different masks": [[2, "examples-4-how-to-call-different-masks"]], "Examples 5: How to call different perturbations": [[2, "examples-5-how-to-call-different-perturbations"]], "Examples 6: Re-activations with 1-D CNN": [[2, "examples-6-re-activations-with-1-d-cnn"]], "Examples 7: Re-activations with 2-D CNN": [[2, "examples-7-re-activations-with-2-d-cnn"]], "Contents:": [[3, null]], "Introduction to pudu": [[4, "introduction-to-pudu"]], "Features": [[4, "features"]], "Quickstart": [[4, "quickstart"]], "Credits": [[4, "credits"]], "Perturbation Functions": [[6, "module-perturbation"]], "Mask Functions": [[5, "module-masks"]], "pudu": [[7, "pudu"]]}, "indexentries": {"__init__() (pudu.pudu method)": [[7, "pudu.pudu.__init__"]], "importance() (pudu.pudu method)": [[7, "pudu.pudu.importance"]], "pudu (class in pudu)": [[7, "pudu.pudu"]], "reactivations() (pudu.pudu method)": [[7, "pudu.pudu.reactivations"]], "relatable() (pudu.pudu method)": [[7, "pudu.pudu.relatable"]], "speed() (pudu.pudu method)": [[7, "pudu.pudu.speed"]], "synergy() (pudu.pudu method)": [[7, "pudu.pudu.synergy"]]}})
\ No newline at end of file
+Search.setIndex({"docnames": ["contributions", "definitions", "examples", "index", "introduction", "masks", "perturbations", "pudu"], "filenames": ["contributions.rst", "definitions.rst", "examples.rst", "index.rst", "introduction.rst", "masks.rst", "perturbations.rst", "pudu.rst"], "titles": ["Contributing", "Definitions", "Examples", "<no title>", "Introduction to pudu", "Mask Functions", "Perturbation Functions", "pudu"], "terms": {"ar": [0, 1, 2, 7], "welcom": 0, "thei": 0, "greatli": 0, "appreci": 0, "everi": 0, "littl": 0, "bit": 0, "help": [0, 2, 4], "credit": [0, 3], "alwai": [0, 5], "given": [0, 5], "you": [0, 2, 4], "can": [0, 1, 2, 7], "mani": [0, 1, 2], "wai": [0, 2, 4, 7], "http": [0, 4], "github": [0, 4], "com": [0, 4], "pudu": [0, 2, 3], "py": [0, 4], "issu": 0, "If": [0, 4, 7], "pleas": [0, 4, 7], "includ": [0, 2], "your": [0, 2], "oper": 0, "system": 0, "name": [0, 2], "version": 0, "ani": [0, 4], "detail": 0, "about": 0, "local": [0, 1, 7], "setup": 0, "might": [0, 2], "troubleshoot": 0, "step": 0, "reproduc": 0, "look": [0, 1], "through": [0, 1], "anyth": 0, "tag": 0, "want": [0, 2], "i": [0, 1, 2, 4, 5, 6, 7], "open": [0, 3], "whoever": 0, "enhanc": 0, "could": [0, 2], "us": [0, 1, 3, 4, 5, 7], "more": [0, 1, 2], "whether": 0, "part": 0, "offici": 0, "doc": [0, 4], "docstr": 0, "The": [0, 1, 2, 4, 5, 6, 7], "best": 0, "send": 0, "file": [0, 2], "an": [0, 1, 2, 4, 6, 7], "propos": 0, "explain": [0, 2, 4], "how": [0, 1, 3, 4, 7], "would": [0, 1, 2], "work": [0, 2, 4, 7], "keep": [0, 2], "scope": [0, 2, 7], "narrow": 0, "possibl": [0, 1, 7], "make": [0, 2], "easier": [0, 7], "rememb": 0, "thi": [0, 1, 2, 4, 7], "volunt": 0, "driven": 0, "project": [0, 4], "readi": 0, "here": [0, 1], "": [0, 1, 2, 7], "set": [0, 1, 2, 6, 7], "up": [0, 4], "develop": 0, "fork": 0, "repo": [0, 4], "clone": 0, "git": 0, "your_name_her": 0, "3": [0, 3], "instal": [0, 4], "copi": 0, "virtualenv": 0, "assum": 0, "have": [0, 1, 2, 7], "virtualenvwrapp": 0, "mkvirtualenv": 0, "cd": 0, "python": [0, 4], "creat": [0, 2, 4], "branch": 0, "chang": [0, 1, 2, 4, 6, 7], "checkout": 0, "b": [0, 1], "bugfix": 0, "5": 3, "when": [0, 2, 4], "re": [0, 3, 4], "done": 0, "check": [0, 2], "pass": [0, 1, 7], "flake8": 0, "test": [0, 2, 4, 7], "other": [0, 1, 2, 7], "tox": 0, "pytest": 0, "run": [0, 4], "unittest": 0, "coverag": 0, "folder": 0, "m": [0, 1, 4], "test_pudu": 0, "xml": 0, "independ": 0, "what": [0, 1, 2], "do": [0, 7], "all": [0, 1, 2, 3, 5, 6, 7], "must": [0, 7], "add": 0, "function": [0, 1, 2, 3, 4, 7], "like": [0, 2], "class": [0, 1, 2, 5, 6, 7], "commit": 0, "push": 0, "descript": 0, "origin": [0, 1], "websit": 0, "befor": [0, 6], "meet": 0, "should": [0, 2], "go": 0, "below": [0, 6], "70": 0, "codecov": 0, "codeql": 0, "updat": [0, 4], "so": [0, 2, 7], "4": 3, "6": [0, 3], "10": [0, 2, 6], "let": 1, "x": [1, 2, 7], "2": [1, 3, 4, 5, 6], "d": [1, 3, 4], "arrai": [1, 2, 6], "dimens": 1, "h": 1, "time": [1, 2, 7], "w": [1, 2], "p_m": 1, "probabl": [1, 2, 4, 7], "model": [1, 2, 7], "Then": [1, 2], "belong": 1, "classif": [1, 3, 4, 7], "accord": [1, 2, 4, 7], "problem": [1, 2, 4, 7], "solv": 1, "consid": [1, 2, 4], "j": [1, 2], "featur": [1, 2, 3, 7], "posit": [1, 2, 3, 6, 7], "h_j": 1, "w_j": 1, "li": 1, "said": 1, "defin": 1, "li_j": 1, "left": [1, 7], "right": [1, 7], "r_j": 1, "where": [1, 2], "r": [1, 6], "perturb": [1, 3, 7], "rel": [1, 4], "ri": 1, "denot": 1, "ri_j": 1, "frac": 1, "min": [1, 2], "max": [1, 2], "contain": [1, 2], "sampl": [1, 2], "differ": [1, 3, 7], "state": [1, 5], "paramet": [1, 2, 5, 6, 7], "r_1": 1, "r_2": 1, "As": 1, "perturbaion": 1, "li_": 1, "1": [1, 3, 4, 5, 6, 7], "slope": [1, 2, 7], "calcul": [1, 2, 4, 6, 7], "linear": [1, 6], "fit": 1, "point": [1, 2, 7], "fast": [1, 2, 4, 7], "imort": 1, "accod": 1, "sensit": 1, "These": 1, "neg": [1, 2, 3, 6], "valu": [1, 2, 6, 7], "depend": [1, 2], "A": [1, 4, 6], "mean": [1, 2, 6], "bigger": 1, "produc": 1, "prediciton": 1, "smaller": 1, "predict": [1, 2, 7], "distinct": 1, "from": [1, 2, 4, 7], "x_i": 1, "both": [1, 4, 6], "under": 1, "obtain": [1, 2], "x_": 1, "foral": 1, "neq": 1, "indic": [1, 2, 3, 7], "complement": [1, 2], "each": [1, 2, 7], "term": 1, "anf": 1, "effec": 1, "tion": 1, "In": [1, 2, 4, 7], "convolut": 1, "layer": [1, 2, 7], "l": 1, "group": [1, 2], "number": [1, 3, 7], "k": [1, 2], "size": [1, 2, 7], "input": [1, 2, 5, 6, 7], "kernel": 1, "k_h": 1, "k_w": 1, "stride": 1, "s_h": 1, "s_w": 1, "filter": 1, "f": 1, "specif": [1, 2, 5, 6, 7], "h_o": 1, "w_o": 1, "output": [1, 2, 7], "bau": 1, "zhou": 1, "et": 1, "al": 1, "2017": 1, "take": [1, 6], "a_k": 1, "distribut": [1, 6], "individu": 1, "subset": 1, "p": [1, 2, 7], "quantil": 1, "t_k": 1, "were": 1, "abov": [1, 4, 6], "which": [1, 2, 4, 5, 6, 7], "exist": 1, "evalu": [1, 2, 5], "base": [1, 6], "data": [1, 3], "x_j": 1, "b_k": 1, "delta": [1, 2, 6, 7], "b_": 1, "pre": [1, 2], "activatoin": 1, "we": [1, 2], "extract": [1, 2], "select": [1, 2, 7], "a_": 1, "final": [1, 2], "case": [1, 2, 4, 7], "deriv": 1, "latter": 1, "account": 1, "after": [1, 2], "For": [1, 2], "exampl": [1, 3, 4, 7], "ha": [1, 4], "u": [1, 2], "same": [1, 2, 7], "rightarrow": 1, "0": [1, 2, 5, 6, 7], "relu": [1, 2, 3, 6, 7], "leakyrelu": [1, 2, 3, 6], "word": [1, 7], "signific": [1, 7], "accor": 1, "With": 1, "follow": [1, 4], "inform": [1, 2], "per": 1, "most": [1, 2], "though": 1, "singl": [1, 2, 6], "better": [1, 2], "them": 1, "khosla": 1, "aud": 1, "o": 1, "torralba": 1, "network": 1, "dissect": 1, "quantifi": [1, 4], "interpret": 1, "deep": 1, "visual": [1, 2], "represent": 1, "import": [2, 3, 4, 7], "matplotlib": 2, "pyplot": 2, "plt": 2, "lime": 2, "lime_tabular": 2, "spectrapepp": 2, "spep": 2, "numpi": 2, "np": 2, "pickl": 2, "plot": [2, 4], "load": 2, "spectra": 2, "target": [2, 7], "coltag": 2, "voc": 2, "txt": 2, "transpos": 2, "true": 2, "train": [2, 7], "pca": 2, "lda_model": 2, "sav": 2, "rb": 2, "pca_model": 2, "first": 2, "try": [2, 4], "see": [2, 4, 7], "need": [2, 4, 7], "wrap": [2, 7], "def": 2, "pcalda_proba": 2, "transform": 2, "return": [2, 5, 6], "predict_proba": 2, "categor": [2, 7], "correct": 2, "format": [2, 4, 7], "fn": 2, "str": [2, 7], "rang": [2, 6], "len": 2, "100": 2, "cf": 2, "instanc": 2, "limetabularexplain": 2, "mode": 2, "feature_nam": 2, "categorical_featur": 2, "verbos": 2, "fals": [2, 7], "exp": [2, 3, 6], "explain_inst": 2, "num_featur": 2, "num_sampl": 2, "1000": 2, "reformat": 2, "order": [2, 4], "over": 2, "e": [2, 4, 7], "as_list": 2, "lm": 2, "_": 2, "1536": 2, "int": [2, 5, 6, 7], "split": 2, "result": [2, 4, 7], "rc": 2, "font": 2, "15": 2, "figur": 2, "figsiz": 2, "14": 2, "imshow": 2, "expand_dim": 2, "cmap": 2, "green": 2, "aspect": 2, "auto": 2, "interpol": 2, "nearest": 2, "extent": 2, "alpha": [2, 6], "colorbar": 2, "titl": [2, 4], "xlabel": 2, "ylabel": 2, "intens": 2, "ytick": 2, "show": 2, "respect": 2, "y": [2, 7], "newaxi": 2, "4d": [2, 6], "batch": [2, 7], "row": [2, 7], "column": [2, 7], "depth": [2, 7], "thu": 2, "categori": 2, "prob_1": 2, "prob_2": 2, "prob_c": 2, "pf": [2, 7], "build": 2, "imp": 2, "vanilla": 2, "one": [2, 4], "except": 2, "window": [2, 7], "50": 2, "font_siz": 2, "pixel": 2, "irrelev": 2, "spectroscopi": 2, "togeth": 2, "speed": [2, 3, 4, 7], "spe": 2, "ot": 2, "main": [2, 4], "raman": 2, "peak": 2, "aprox": 2, "3rd": 2, "its": 2, "synergi": [2, 3, 4, 7], "rest": 2, "inspect": [2, 7], "syn": 2, "localreg": 2, "rbfnet": 2, "sklearn": 2, "metric": 2, "r2_score": 2, "ptn": 2, "msk": 2, "area": 2, "ra": 2, "shuffl": 2, "spearat": 2, "type": [2, 5, 6, 7], "ra0": 2, "ra1": 2, "ra2": 2, "ra3": 2, "ra0_t": 2, "ra1_t": 2, "ra2_t": 2, "ra3_t": 2, "voc_t": 2, "1494": 2, "ra0_tr": 2, "ra1_tr": 2, "ra2_tr": 2, "ra3_tr": 2, "voc_tr": 2, "prepar": 2, "rbnf": 2, "t": 2, "z": 2, "net": 2, "num": 2, "200": 2, "z_hat": 2, "z_hat_t": 2, "print": 2, "r2": 2, "round": 2, "scatter": 2, "c": [2, 4, 6], "blue": 2, "rbf_pred": 2, "bidirect": [2, 3, 6, 7], "ouput": [2, 7], "axi": 2, "tick": 2, "a1": 2, "a2": 2, "a3": 2, "a4": 2, "25": 2, "show_data": 2, "xtick": 2, "tensorflow": 2, "load_model": 2, "num_class": 2, "input_shap": 2, "28": 2, "between": [2, 4, 5, 7], "x_train": 2, "y_train": 2, "x_test": 2, "y_test": 2, "dataset": 2, "load_data": 2, "scale": [2, 6], "imag": [2, 4], "astyp": 2, "float32": 2, "255": 2, "sure": 2, "shape": 2, "convert": 2, "vector": [2, 5, 7], "binari": [2, 3, 6], "matric": 2, "util": 2, "to_categor": 2, "mnist_class": 2, "h5": 2, "summari": [2, 7], "score": 2, "loss": 2, "accuraci": 2, "cnn2d_prob": 2, "diment": 2, "standar": 2, "argmax": 2, "tupl": [2, 6], "width": [2, 7], "height": 2, "none": [2, 5, 7], "pad": [2, 7], "center": [2, 7], "cool": 2, "some": 2, "bia": [2, 7], "those": 2, "sinc": 2, "lime_imag": 2, "skimag": 2, "segment": 2, "mark_boundari": 2, "color": 2, "gray2rgb": 2, "3d": 2, "rgb": 2, "our": 2, "non": 2, "2d": 2, "rbg": 2, "limeimageexplain": 2, "explan": 2, "batch_siz": 2, "temp": 2, "get_image_and_mask": 2, "top_label": 2, "positive_onli": 2, "hide_rest": 2, "grad": 2, "cam": 2, "tf": 2, "ipython": 2, "displai": 2, "cm": 2, "make_gradcam_heatmap": 2, "img_arrai": 2, "last_conv_layer_nam": 2, "pred_index": 2, "map": 2, "last": 2, "conv": 2, "well": 2, "grad_model": 2, "get_lay": 2, "comput": 2, "gradient": [2, 7], "top": 2, "gradienttap": 2, "tape": 2, "last_conv_layer_output": 2, "pred": 2, "class_channel": 2, "neuron": 2, "chosen": 2, "regard": 2, "entri": [2, 6], "channel": 2, "pooled_grad": 2, "reduce_mean": 2, "multipli": 2, "sum": 2, "heatmap": 2, "squeez": 2, "purpos": 2, "also": 2, "normal": [2, 4], "maximum": [2, 7], "math": 2, "reduce_max": 2, "conv2d_5": 2, "remov": [2, 4], "softmax": 2, "gener": [2, 7], "jet": 2, "75": 2, "allow": 2, "cover": 2, "featuresof": 2, "analysi": [2, 7], "It": [2, 4, 7], "serv": 2, "ni": 2, "structur": 2, "pattern": 2, "option": [2, 7], "avail": [2, 4], "everyoth": [2, 3, 5], "random": [2, 5, 6], "randommask": [2, 3, 5], "m_name": 2, "zip": 2, "absolut": [2, 4, 7], "averag": 2, "positevli": 2, "neativ": 2, "natur": 2, "difer": 2, "yield": 2, "note": 2, "onli": [2, 7], "pert": 2, "ptn_name": 2, "for_1d_cnn_c3": 2, "0_526_model_": 2, "80": 2, "79": 2, "cnn1d_prob": 2, "y0": 2, "x0": 2, "150": 2, "now": 2, "explor": [2, 4], "unit": [2, 6, 7], "observ": 2, "005": [2, 7], "less": 2, "being": 2, "reactiv": [2, 7], "0025": 2, "lac": 2, "n\u00ba": 2, "There": 2, "frequent": 2, "too": 2, "report": [2, 3, 7], "feature_report": 2, "fac": 2, "print_report": 2, "show_top": 2, "unit_report": 2, "uac": 2, "To": 2, "coordin": [2, 7], "preview": 2, "bold": 2, "infomr": 2, "sever": 2, "relat": [2, 7], "appli": [2, 5, 6, 7], "n": 2, "reshap": 2, "14730": 2, "anoth": 2, "idx": 2, "cnt": 2, "cor": 2, "icc": 2, "index": [2, 3], "count": [2, 7], "relate_report": 2, "20": 2, "rot_tick": 2, "45": 2, "sort": 2, "12": 2, "low": 2, "30": [2, 6], "90": 2, "introduct": 3, "quickstart": 3, "definit": 3, "activ": [3, 7], "activaiton": 3, "refer": [3, 4, 7], "constant": [3, 6], "custom": [3, 5, 6], "gaussian": [3, 6], "gaussiannois": [3, 6], "invers": [3, 6], "log": [3, 6], "lowerthreshold": [3, 6], "offset": [3, 6], "randomptn": [3, 6], "sigmoid": [3, 6], "sinusoid": [3, 6], "softplu": [3, 6], "tanh": [3, 6], "uniformnois": [3, 6], "upperthreshold": [3, 6], "mask": [3, 7], "odd": [3, 5], "pair": [3, 5], "percentag": [3, 5, 6], "quantiti": [3, 5], "pc": 3, "lda": 3, "scikit": [3, 4], "learn": [3, 4], "spectroscop": 3, "regress": [3, 7], "predicit": 3, "circuit": 3, "voltag": 3, "solar": 3, "cell": 3, "rbfn": 3, "handwritten": 3, "recognit": 3, "cnn": 3, "kera": [3, 4, 7], "mnist": 3, "call": 3, "7": 3, "contribut": 3, "bug": 3, "fix": 3, "implement": 3, "write": 3, "document": [3, 4, 7], "submit": 3, "feedback": 3, "get": 3, "start": [3, 7], "pull": 3, "request": 3, "guidelin": 3, "tabl": 3, "librari": 4, "machin": 4, "learinng": 4, "algorithm": [4, 7], "agnost": 4, "determinist": 4, "simpl": 4, "io": 4, "pypi": 4, "org": 4, "conda": 4, "forg": 4, "anaconda": 4, "free": 4, "softwar": 4, "mit": 4, "licens": 4, "packag": 4, "intepret": 4, "machinm": 4, "algorythm": 4, "doe": [4, 7], "method": [4, 5], "vectror": 4, "exact": 4, "procedur": 4, "list": [4, 5, 7], "enabl": 4, "estim": 4, "oif": 4, "preditci0on": 4, "teh": 4, "easi": 4, "pip": 4, "find": 4, "citat": 4, "misc": 4, "grau": 4, "luque2023pudu": 4, "author": 4, "luqu": 4, "becerril": 4, "romero": 4, "perez": 4, "rodriguez": 4, "guc": 4, "v": 4, "izquierdo": 4, "roca": 4, "year": 4, "2023": 4, "publish": 4, "journal": 4, "repositori": 4, "howpublish": 4, "url": 4, "stai": 4, "date": 4, "encount": 4, "uninstal": 4, "wa": 4, "cookiecutt": 4, "giswq": 4, "pypackag": 4, "templat": 4, "sourc": [5, 6, 7], "regardless": 5, "initi": 5, "either": 5, "is_eo": 5, "section": 5, "otherwis": 5, "even": 5, "float": [5, 6, 7], "qty": 5, "integ": 5, "percetag": 6, "th": 6, "upper": 6, "lower": 6, "threshold": [6, 7], "replac": 6, "func": 6, "callabl": 6, "argument": [6, 7], "exponenti": 6, "expon": 6, "stdv": 6, "standard": 6, "deviat": 6, "nois": 6, "leaki": 6, "rectifi": 6, "coeffici": 6, "logarithm": 6, "certain": 6, "specifi": [6, 7], "ad": [6, 7], "sf": 6, "factor": 6, "freq": 6, "amp": 6, "frequenc": 6, "sine": 6, "wave": 6, "amplitud": 6, "hyperbol": 6, "tangent": 6, "uniform": 6, "bound": 6, "__init__": 7, "constructor": 7, "analyz": 7, "descriptor": 7, "diention": 7, "sclaar": 7, "inclus": 7, "default": 7, "layer_activ": 7, "unit_activ": 7, "evolut": 7, "object": 7, "changeg": 7, "tuppl": 7, "end": 7, "analys": 7, "string": 7, "legnth": 7, "divis": 7, "equal": 7, "side": 7, "paad": 7, "applyi": 7, "length": 7, "perfet": 7, "ipad": 7, "bool": 7, "weather": 7, "within": 7, "exactli": 7, "desir": 7, "global": 7, "strategi": 7, "kwarg": 7, "dict": 7, "addit": 7, "keyword": 7, "curv": 7, "form": 7, "variat": 7}, "objects": {"": [[5, 0, 0, "-", "masks"], [6, 0, 0, "-", "perturbation"]], "masks": [[5, 1, 1, "", "All"], [5, 1, 1, "", "Custom"], [5, 1, 1, "", "EveryOther"], [5, 1, 1, "", "Odds"], [5, 1, 1, "", "Pairs"], [5, 1, 1, "", "Percentage"], [5, 1, 1, "", "Quantity"], [5, 1, 1, "", "RandomMask"]], "perturbation": [[6, 1, 1, "", "Bidirectional"], [6, 1, 1, "", "Binary"], [6, 1, 1, "", "Constant"], [6, 1, 1, "", "Custom"], [6, 1, 1, "", "Exp"], [6, 1, 1, "", "Gaussian"], [6, 1, 1, "", "GaussianNoise"], [6, 1, 1, "", "Inverse"], [6, 1, 1, "", "LeakyReLU"], [6, 1, 1, "", "Log"], [6, 1, 1, "", "LowerThreshold"], [6, 1, 1, "", "Negative"], [6, 1, 1, "", "Offset"], [6, 1, 1, "", "Positive"], [6, 1, 1, "", "RandomPtn"], [6, 1, 1, "", "ReLU"], [6, 1, 1, "", "Sigmoid"], [6, 1, 1, "", "Sinusoidal"], [6, 1, 1, "", "Softplus"], [6, 1, 1, "", "Tanh"], [6, 1, 1, "", "UniformNoise"], [6, 1, 1, "", "UpperThreshold"]], "pudu": [[7, 1, 1, "", "pudu"]], "pudu.pudu": [[7, 2, 1, "", "__init__"], [7, 2, 1, "", "importance"], [7, 2, 1, "", "reactivations"], [7, 2, 1, "", "relatable"], [7, 2, 1, "", "speed"], [7, 2, 1, "", "synergy"]]}, "objtypes": {"0": "py:module", "1": "py:class", "2": "py:method"}, "objnames": {"0": ["py", "module", "Python module"], "1": ["py", "class", "Python class"], "2": ["py", "method", "Python method"]}, "titleterms": {"contribut": 0, "report": 0, "bug": 0, "fix": 0, "implement": 0, "featur": [0, 4], "write": 0, "document": 0, "submit": 0, "feedback": 0, "get": 0, "start": 0, "pull": 0, "request": 0, "guidelin": 0, "definit": 1, "import": 1, "speed": 1, "synergi": 1, "activ": [1, 2], "re": [1, 2], "activaiton": 1, "unit": 1, "acitv": 1, "map": 1, "refer": 1, "exampl": 2, "1": 2, "pc": 2, "lda": 2, "scikit": 2, "learn": 2, "classif": 2, "spectroscop": 2, "data": 2, "2": 2, "regress": 2, "predicit": 2, "open": 2, "circuit": 2, "voltag": 2, "solar": 2, "cell": 2, "rbfn": 2, "3": 2, "handwritten": 2, "number": 2, "recognit": 2, "us": 2, "cnn": 2, "kera": 2, "mnist": 2, "4": 2, "how": 2, "call": 2, "differ": 2, "mask": [2, 5], "5": 2, "perturb": [2, 6], "6": 2, "d": 2, "7": 2, "content": 3, "introduct": 4, "pudu": [4, 7], "quickstart": 4, "credit": 4, "function": [5, 6]}, "envversion": {"sphinx.domains.c": 2, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 8, "sphinx.domains.index": 1, "sphinx.domains.javascript": 2, "sphinx.domains.math": 2, "sphinx.domains.python": 3, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx.ext.todo": 2, "sphinx.ext.viewcode": 1, "sphinx": 57}, "alltitles": {"Definitions": [[1, "definitions"]], "Importance": [[1, "importance"]], "Speed": [[1, "speed"]], "Synergy": [[1, "synergy"]], "Activations and re-activaiton": [[1, "activations-and-re-activaiton"]], "Units": [[1, "units"]], "Acitvation map": [[1, "acitvation-map"]], "Re-activation map": [[1, "re-activation-map"]], "References": [[1, "references"]], "Examples": [[2, "examples"]], "Example 1: PC-LDA with Scikit-learn for classification of spectroscopic data": [[2, "example-1-pc-lda-with-scikit-learn-for-classification-of-spectroscopic-data"]], "Examples 2: Regression for predicition of open circuit voltage of solar cells with RBFN": [[2, "examples-2-regression-for-predicition-of-open-circuit-voltage-of-solar-cells-with-rbfn"]], "Examples 3: Handwritten numbers recognition using CNN with Keras and Mnist": [[2, "examples-3-handwritten-numbers-recognition-using-cnn-with-keras-and-mnist"]], "Examples 4: How to call different masks": [[2, "examples-4-how-to-call-different-masks"]], "Examples 5: How to call different perturbations": [[2, "examples-5-how-to-call-different-perturbations"]], "Examples 6: Re-activations with 1-D CNN": [[2, "examples-6-re-activations-with-1-d-cnn"]], "Examples 7: Re-activations with 2-D CNN": [[2, "examples-7-re-activations-with-2-d-cnn"]], "Contents:": [[3, null]], "Introduction to pudu": [[4, "introduction-to-pudu"]], "Features": [[4, "features"]], "Quickstart": [[4, "quickstart"]], "Credits": [[4, "credits"]], "Mask Functions": [[5, "module-masks"]], "Perturbation Functions": [[6, "module-perturbation"]], "pudu": [[7, "pudu"]], "Contributing": [[0, "contributing"]], "Report Bugs": [[0, "report-bugs"]], "Fix Bugs": [[0, "fix-bugs"]], "Implement Features": [[0, "implement-features"]], "Write Documentation": [[0, "write-documentation"]], "Submit Feedback": [[0, "submit-feedback"]], "Get Started!": [[0, "get-started"]], "Pull Request Guidelines": [[0, "pull-request-guidelines"]]}, "indexentries": {}})
\ No newline at end of file
diff --git a/examples/example_specific_sections.py b/examples/example_specific_sections.py
new file mode 100644
index 0000000..254c9b2
--- /dev/null
+++ b/examples/example_specific_sections.py
@@ -0,0 +1,59 @@
+import spectrapepper as spep
+import numpy as np
+import pickle
+
+from pudu import pudu, plots
+
+
+# Load features (spectra) and targets (open circuit coltage, voc)
+features = spep.load('data/features.txt')
+targets = spep.load('data/targets.txt', transpose=True)[2]
+
+# Load pre-trained LDA and PCA models
+lda = pickle.load(open('data/lda_model.sav', 'rb'))
+pca = pickle.load(open('data/pca_model.sav', 'rb'))
+
+
+### PUDU ###
+# Select x (feature) and respective y (target)
+x = features[100]
+x_len = len(x)
+x = x[np.newaxis, np.newaxis, :, np.newaxis]
+y = targets[100]
+
+# Input should be 4d: (batch * rows * columns * depth)
+# This is a classification problem, thus the output should be the
+# probability by category: [prob_1, prob_2, ..., prob_c]
+def pf(X):
+ X = X[0,:,:,0]
+ return lda.predict_proba(pca.transform(X))[0]
+
+# Build pudu
+imp = pudu.pudu(x, y, pf)
+
+# To evaluate more specific areas, we can do ir one-by-one and the
+# put them all together in a vector for plotting and/or normalizing.
+# This can be done for `importnace` and `speed` only.
+
+# For this, we first define the areas of interest
+areas = [[170, 200],[225, 250], [250, 290], [300, 330]]
+
+# In aloop we evaluate them individially. We make sure that `window`
+# and `scope` are equal so all the area is evaluated. The results are
+# saved in `custom`.
+custom = np.zeros(x_len)
+for i in areas:
+ imp.importance(window=int(i[1]-i[0]), scope=(i[0], i[1]))
+ custom[imp.imp[0, 0, :, 0] != 0] = imp.imp[0, 0, imp.imp[0, 0, :, 0] != 0, 0]
+
+custom = custom[np.newaxis, np.newaxis, :, np.newaxis]
+plots.plot(imp.x, custom, title="Importance", yticks=[], font_size=15, cmap='jet')
+
+# Repeat the same for `speed`.
+custom = np.zeros(x_len)
+for i in areas:
+ imp.speed(window=int(i[1]-i[0]), scope=(i[0], i[1]))
+ custom[imp.spe[0, 0, :, 0] != 0] = imp.spe[0, 0, imp.spe[0, 0, :, 0] != 0, 0]
+
+custom = custom[np.newaxis, np.newaxis, :, np.newaxis]
+plots.plot(imp.x, custom, title="Speed", yticks=[], font_size=15, cmap='jet')
diff --git a/paper/paper.md b/paper/paper.md
index aac9778..37c019e 100644
--- a/paper/paper.md
+++ b/paper/paper.md
@@ -44,11 +44,11 @@ Even though there are products and libraries available for explaining different
# Overview
-The **pudu** library is a Python toolkit created to help make sense of machine learning results. It does this by taking a clear and deterministic (or stochastic if the user desires) approach, performing sensitivity analysis on classification and regression tasks. This toolbox uses the same basic principles as RELIEF, but offers the user plenty of flexibility with parameters and use cases. Additionally, it offers activation analysis for Neural Networks, adapting some of the guidelines defined in [Bau2018] to measure the impact of feature changes through sensitivity analysis. **pudu** measures the importance of features based on how changes in the input affect the target instance. To do this, **pudu** works under the assumption that the algorithm in use has a classification probability function or a prediction function for classification and regression problems, respectively. Using this, it changes the feature space in a predictable (or random) way and evaluates the importance of the defined features based on the changes to the target. **pudu** is versatile: it can analyze both classification and regression problems for both 1-dimensional (vectors) and 2-dimensional (non-RGB images) data types as input. **pudu** creates visual explanations in an easy-to-understand way by highlighting the importance of a feature on each decision, and also offers the ability to provide localized explanations by selecting specific areas of interest.
+The **pudu** library is a Python toolkit created to help make sense of machine learning results. It does this by taking a clear and deterministic approach, performing sensitivity analysis on classification and regression tasks. This toolbox uses the same basic principles as RELIEF, but offers the user plenty of flexibility with parameters and use cases. Additionally, it offers activation analysis for Neural Networks, adapting some of the guidelines defined in [Bau2018] to measure the impact of feature changes through sensitivity analysis. **pudu** measures the importance of features based on how changes in the input affect the target instance. To do this, **pudu** works under the assumption that the algorithm in use has a classification probability function or a prediction function for classification and regression problems, respectively. Using this, it changes the feature space in a predictable way and evaluates the importance of the defined features based on the changes to the target. **pudu** is versatile: it can analyze both classification and regression problems for both 1-dimensional and 2-dimensional data types as input. **pudu** creates visual explanations in an easy-to-understand way by highlighting the importance of a feature on each decision, and also offers the ability to provide localized explanations by selecting specific areas of interest.
To illustrate this functionality, examples using scikit-learn [@Pedregosa2011], keras [@chollet2018keras], and localreg [@Marholm2022] are included in the documentation, along with the use of LIME and GradCAM to show how **pudu** can complement the understanding of AI decisions in different types of problems.
-**pudu** is built in Python 3 [@VanRossumGuidoDrake2009], and also uses third-party packages including numpy [@Harris2020], matplotlib [@Hunter2007], and keras. It is available in both pipy and conda, and comes with complete documentation, including quick start, examples, and contribution guidelines. Source code and documentation can be downloaded from https://github.com/pudu-py/pudu.
+**pudu** is built in Python 3 [@VanRossumGuidoDrake2009], and also uses third-party packages including numpy [@Harris2020], matplotlib [@Hunter2007], and keras. It is available in both [PyPI](https://pypi.org/project/pudu/) and [conda] (https://anaconda.org/conda-forge/pudu), and comes with complete documentation, including quick start, examples, and contribution guidelines. Source code and documentation can be downloaded from https://github.com/pudu-py/pudu.
# Features
@@ -58,17 +58,15 @@ A brief list of features includes:
- Importance: estimates the importance of the features with sensitivity analysis.
- Speed: calculates how fast a prediction changes according to the changes in the features.
- Synergy: explores the interaction between features and how they influence the classification probability.
-- Layer Activation: identifies how changes in features affect the activation of units within a layer.
-- Unit Activation: tracks how often each unit within a layer activates in response to input changes.
-- Unit to Feature: links features and units by identifying the most activated unit based on specific feature changes.
-- Wide selection of feature perturbation and masking functions is available, including fully customizable options to ensure complete tailoring capability.
+- Reactivation: identifies how perturbations in features affect the activation of units within a layer in Convolutional Neural Networks.
+- Selection of feature perturbation and masking functions is available, including fully customizable options to ensure complete tailoring capability.
- Easy plotting of the results.
# Acknowledgements
This work has received funding from the European Union's Horizon 2020 Research and Innovation Programme under grant agreement no. 952982 (Custom-Art project) and Fast Track to Innovation Programme under grant agreement no. 870004 (Solar-Win project). Authors from IREC belong to the SEMS (Solar Energy Materials and Systems) Consolidated Research Group of the “Generalitat de Catalunya” (ref. 2017 SGR 862) and are grateful to European Regional Development Funds (ERDF, FEDER Programa Competitivitat de Catalunya 2007–2013). MG acknowledges the financial support from Spanish Ministry of Science, Innovation and Universities within the Juan de la Cierva fellowship (IJC2018-038199-I).
-# Authors contribution with [CRediT](/guides/content/editing-an-existing-page)
+# Authors contribution with [CRediT](https://credit.niso.org/)
- Enric Grau-Luque: Conceptualization, Data curation, Software, Writing – original draft
- Ignacio Becerril-Romero: Investigation, Methodology, Writing – review & edition
diff --git a/pudu/__init__.py b/pudu/__init__.py
index 7f60ae5..40ddc44 100644
--- a/pudu/__init__.py
+++ b/pudu/__init__.py
@@ -2,4 +2,4 @@
__author__ = """Enric Tomas Grau-Luque"""
__email__ = 'patenric@gmail.com'
-__version__ = '0.2.0'
+__version__ = '0.3.0'
diff --git a/pudu/pudu.py b/pudu/pudu.py
index 96e39c0..be24293 100644
--- a/pudu/pudu.py
+++ b/pudu/pudu.py
@@ -7,7 +7,6 @@
from . import masks as msk
from . import perturbation as ptn
-
class pudu:
def __init__(self, x, y, pf, model=None):
"""
@@ -115,12 +114,6 @@ def importance(self, window=1, scope=None, evolution=None, padding='center', bia
temp, temp2 = perturbation.apply(x_copy, row, col, window, bias)
- # print(np.shape(temp[0,:,:,0]), np.shape(self.x[0,:,:,0]))
- # plt.plot(temp[0,0,:,0])
- # plt.plot(self.x[0,0,:,0])
- # plt.show()
- # exit()
-
if temp2 is None:
val = self.pf(temp) - p0
else:
@@ -540,23 +533,15 @@ def relatable(self, layer=0, slope=0, p=0.005, window=1, scope=None, bias=0,
s_x, s_y = self.x, self.y
master = []
- # master = np.array()
for x, y in zip(s_x, s_y):
x = np.expand_dims(x, 0)
self.x, self.y = x, y
feats, units = self.reactivations(layer, slope, p, window, scope, bias, padding,
- perturbation=perturbation, mask=mask)
+ perturbation, mask)
master.extend((i, j) for i, j in zip(feats, units))
- feats = np.array(feats)
- units = np.array(units)
- master = np.column_stack((feats, units))
-
- master = master.tolist()
-
- master = [tuple(arr) for arr in master]
counts = Counter(master)
result = [[j, count, i] for (i, j), count in counts.items()]
result = np.transpose(result)
diff --git a/setup.cfg b/setup.cfg
index d0b5ad9..5f0f14f 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,5 +1,5 @@
[bumpversion]
-current_version = 0.2.0
+current_version = 0.3.0
commit = True
tag = True
diff --git a/setup.py b/setup.py
index 3c09cd1..ccda785 100644
--- a/setup.py
+++ b/setup.py
@@ -53,6 +53,6 @@
test_suite='tests',
tests_require=test_requirements,
url='https://github.com/pudu-py/pudu',
- version='0.2.0',
+ version='0.3.0',
zip_safe=False,
)