pudu
- class pudu.pudu(x, y, pf, model=None)[source]
- __init__(x, y, pf, model=None)[source]
pudu constructor.
- Parameters:
x (list) – Features (input) to be analyzed. Must have same format as train and test descriptors with dientionality as (batch, rows, columns, depth).
y (int, float) – Targets (output) for x. It is a sclaar and not categorical for easier inclusion of regression problems.
pf (function) – probability, or prediction, function of the algorithm. The input must be x and the ouput a list of probabilities for each class (in case of classification algorithm). If the default function does not work this way (i.e.: needs a batch as input), it must be wrapped to do so. Please refer to the documentation’s examples to see specific cases.
model (Keras model) – Optional Keras model, only for layer_activations and unit_activation.
- importance(window=1, scope=None, evolution=None, padding='center', bias=0, absolute=False, perturbation=<perturbation.Bidirectional object>, mask=<masks.All object>)[source]
Calculates the importance vector for the input feature.
- Parameters:
window (int) – feature width to be changeg each time.
scope (tupple(int, int)) – Starting and ending point of the analysis for each feature. If None, the all the vector is analysed.
evolution (int) – feature width to be changeg each time.
padding (string) – Type of padding. If the legnth of x is not divisible by window then padding is applyed. If center, then equal padding to each side is applyed. If right, then paading to the right is added and window`starts from `0. If left, padding to the left is applyied and window ends at length x. If perfet center is not possible, then ipadding left is added 1.
absolute (bool) – Weather or not the result is in absolute value or not. Default is False.
- reactivations(layer=0, slope=0, p=0.005, window=1, scope=None, bias=0, padding='center', threshold=0, perturbation=<perturbation.Bidirectional object>, mask=<masks.All object>)[source]
- Counts the unit activations in the selected layer of a Keras model according
to change in the feature.
- Parameters:
layer (int) – Position number within the keras model to be analyzed. Use model.summary() to see exactly the position of the desired layer.
slope (float) – Default is 0 (relu).
window (int) – feature width to be changeg each time.
scope (tupple(int, int)) – Starting and ending point of the analysis for each feature. If None, the all the vector is analysed.
padding (string) – Type of padding. If the legnth of x is not divisible by window then padding is applyed. If center, then equal padding to each side is applyed. If right, then paading to the right is added and window`starts from `0. If left, padding to the left is applyied and window ends at length x. If perfet center is not possible, then ipadding left is added 1.
- relatable(layer=0, slope=0, p=0.005, window=1, scope=None, bias=0, padding='center', threshold=0, perturbation=<perturbation.Bidirectional object>, mask=<masks.All object>)[source]
This function generates an activation report for each set of coordinates in x and y.
- Parameters:
layer (int) – Specifies the layer of the model for which the activation report is to be generated. Default is 0.
slope (int or float) –
p (float) – Specifies the p-value threshold for significance testing of activations. Default is 0.005.
window (int) – Specifies the size of the window for the activation function. Default is 1.
scope (str) – Specifies the scope of the activations. Possible values are ‘global’ and ‘local’. Default is None.
padding (str) – Specifies the padding strategy for the activations. Default is ‘center’.
kwargs (dict) – Additional keyword arguments passed to the activation function.
- speed(window=1, scope=None, evolution=None, padding='center', bias=0, absolute=False, mask=<masks.All object>, perturbation=[<perturbation.Bidirectional object>, <perturbation.Bidirectional object>, <perturbation.Bidirectional object>])[source]
- Calculates the gradient of the importance. In other words, the slope
of the curve formed by the importance at different values. This indicates how fast a feature can change the result.
- Parameters:
window (int) – feature width to be changeg each time.
scope (tupple(int, int)) – Starting and ending point of the analysis for each feature. If None, the all the vector is analysed.
evolution (int) – feature width to be changeg each time.
padding (string) – Type of padding. If the legnth of x is not divisible by window then padding is applyed. If center, then equal padding to each side is applyed. If right, then paading to the right is added and window`starts from `0. If left, padding to the left is applyied and window ends at length x. If perfet center is not possible, then ipadding left is added 1.
absolute (bool) – Weather or not the result is in absolute value or not. Default is False.
- synergy(window=1, inspect=0, scope=None, absolute=False, bias=0, evolution=None, padding='center', perturbation=<perturbation.Bidirectional object>, mask=<masks.All object>)[source]
Calculates the synergy between features.
- Parameters:
delta (float) – maximum variation to apply to each feature.
window (int) – feature width to be changeg each time.
scope (tupple(int, int)) – Starting and ending point of the analysis for each feature. If None, the all the vector is analysed.
evolution (int) – feature width to be changeg each time.
padding (string) – Type of padding. If the legnth of x is not divisible by window then padding is applyed. If center, then equal padding to each side is applyed. If right, then paading to the right is added and window`starts from `0. If left, padding to the left is applyied and window ends at length x. If perfet center is not possible, then ipadding left is added 1.
absolute (bool) – Weather or not the result is in absolute value or not. Default is False.