Skip to content

Commit feff146

Browse files
committed
Merge branch 'fix-notebooks' of https://github.com/givasile/effector into fix-notebooks
2 parents 875337a + 0f2389e commit feff146

File tree

3 files changed

+14
-39
lines changed

3 files changed

+14
-39
lines changed

docs/docs/notebooks/synthetic-examples/01_linear_model.md

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
- **Description**: Apply global effect on a linear model
77

88
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/givasile/effector/blob/main/synthetic-examples/01_linear_model.ipynb)
9-
[![Show in Github](https://xai-effector.github.io/static/github-mark.png)](https://github.com/givasile/effector/blob/main/synthetic-examples/01_linear_model.ipynb)
9+
[![Open in Github](https://img.shields.io/badge/Open%20in-GitHub-black?logo=github)](https://github.com/givasile/effector/blob/main/notebooks/synthetic-examples/01_linear_model.ipynb)
1010

1111

1212
```python
@@ -26,8 +26,6 @@ Hopefully, there is a quantity called **heterogeneity** that can be used to chec
2626

2727
`Effector` provides five different feature effect methods, which are summarized in the table below. In all methods, setting `heterogeneity=True` the methods show the level of heterogeneity, along with the average effect.
2828

29-
<center>
30-
3129
| Method | Description | API in `Effector` | Paper |
3230
|-----------------------------------------|------------------------------------|------------------------------------------------------------------------------|-------------------------------------------------------------------|
3331
| [PDP](#partial-dependence-plot-pdp) | Partial Dependence Plot | [PDP]((./../../reference/#effector.pdp.DerivativePDP)) | [Friedman, 2001](https://statweb.stanford.edu/~jhf/ftp/trebst.pdf) | |
@@ -37,12 +35,8 @@ Hopefully, there is a quantity called **heterogeneity** that can be used to chec
3735
| [SHAP](#shap-dependence-plot) | SHAP Dependence Plot | [SHAPDependence](./../../reference/#effector.shap_dependence.SHAPDependence) | [Lundberg et. al, 2017](https://arxiv.org/pdf/1705.07874.pdf) |
3836

3937

40-
</center>
41-
4238
For the rest of the tutorial, we will use the following notation:
4339

44-
<center>
45-
4640
| Symbol | Description |
4741
|------------------------------------------------------------|---------------------------------------------------------|
4842
| $f(\mathbf{x})$ | The black box model |
@@ -52,23 +46,20 @@ For the rest of the tutorial, we will use the following notation:
5246
| $\mathbf{x} = (x_s, x_c) = (x_1, x_2, ..., x_s, ..., x_D)$ | The input features |
5347
| $\mathbf{x}^{(i)} = (x_s^{(i)}, x_c^{(i)})$ | The $i$-th instance of the dataset |
5448

55-
</center>
5649

5750
---
5851
## Dataset and Model
5952

6053
In this example, we will use as black-box function, a simple linear model $y = 7x_1 - 3x_2 + 4x_3$. Since there are no interactions
6154
terms we expect **all** methods to provide the following feature effects and zero heterogeneity:
6255

63-
<center>
6456

6557
| Feature | Feature Effect | Heterogeneity |
6658
| --- | --- | --- |
6759
| $x_1$ | $7x_1$ | 0 |
6860
| $x_2$ | $-3x_2$ | 0 |
6961
| $x_3$ | $4x_3$ | 0 |
7062

71-
</center>
7263

7364

7465
As dataset, we will generate $N=1000$ examples comming from the following distribution:
@@ -367,14 +358,12 @@ The upper subfigure shows how much the feature of interest _contributes_ to the
367358
For example, for $x_1$ the upper subplot shows a linear effect and the lower subplot confirms that the gradient is constantly $7$.
368359
`Effector` offers two alternatives for centering the ALE plot.
369360

370-
<center>
371361

372362
| `centering` | Description | Formula |
373363
|---------------------------|----------------------------------------|-----------------------------------------------------------------------|
374364
| `False` or `zero_start` | Don't enforce any additional centering | c=0 |
375365
| `True` or `zero_integral` | Center around the $y$ axis | c=$\mathbb{E}_{x_s \sim \mathcal{U(x_{s,min},x_{s, max})}}[ALE(x_s)]$ |
376366

377-
</center>
378367
Let's see how centering works for $x_1$:
379368

380369

@@ -472,15 +461,11 @@ In our example, this advantage is not evident; Since there are no interaction te
472461

473462
As with the ALE, there are two alternatives for centering the ALE plot.
474463

475-
<center>
476-
477464
| `centering` | Description | Formula |
478465
|---------------------------|----------------------------------------|-----------------------------------------------------------------------|
479466
| `False` or `zero_start` | Don't enforce any additional centering | c=0 |
480467
| `True` or `zero-integral` | Center around the $y$ axis | c=$\mathbb{E}_{x_s \sim \mathcal{U(x_{s,min},x_{s, max})}}[ALE(x_s)]$ |
481468

482-
</center>
483-
484469
Let's see how this works for $x_1$:
485470

486471

@@ -547,15 +532,11 @@ effector.ShapDP(data=X, model=predict).plot(feature=0, centering=False, show_avg
547532

548533
TODO add content
549534

550-
<center>
551-
552535
| `centering` | Description | Formula |
553536
|---------------------------|----------------------------------------|-----------------------------------------------------------------------|
554537
| `False` or `zero_start` | Don't enforce any additional centering | c=0 |
555538
| `True` or `zero-integral` | Center around the $y$ axis | c=$\mathbb{E}_{x_s \sim \mathcal{U(x_{s,min},x_{s, max})}}[ALE(x_s)]$ |
556539

557-
</center>
558-
559540
Let's see how this works for $x_1$:
560541

561542

@@ -601,16 +582,12 @@ In summary, given a dataset `X: (N, D)` and a black-box model `model: (N, D) ->
601582
the feature effect plot of the $s$-th feature `feature=s` is given with the table below.
602583
The argument `confidence_interval=True|False` indicates whether to plot the standard deviation of the instance-level effects as $\pm$ interval around the feature effect plot. Some methods also require the gradient of the model `model_jac: (N, D) -> (N, D)`.
603584

604-
<center>
605-
606585
| Method | How to use |
607586
|---------------|----------------------------------------------------------------------------------------------------------------------------------------------|
608-
| PDP | [`effector.PDP(X, model).plot(feature, centering, confidence_interval)`]((./../../reference/#effector.pdp.PDP)) |
609-
| d-PDP | [`effector.DerivativePDP(X, model, model_jac).plot(feature, centering, confidence_interval)`](./../../reference/#effector.pdp.DerivativePDP) |
610-
| ALE | [`effector.ALE(X, model).plot(feature, centering, confidence_interval)`](./../../reference/#effector.ale.ALE) |
611-
| RHALE | [`effector.RHALE(X, model, model_jac).plot(feature, centering, confidence_interval)`](./../../reference/#effector.ale.RHALE) |
612-
613-
</center>
587+
| PDP | [`effector.PDP(X, model).plot(feature, centering, confidence_interval)`](../../../api_docs/api_global/#effector.global_effect_pdp.PDP) |
588+
| d-PDP | [`effector.DerivativePDP(X, model, model_jac).plot(feature, centering, confidence_interval)`](../../../api_docs/api_global/#effector.global_effect_pdp.DerPDP) |
589+
| ALE | [`effector.ALE(X, model).plot(feature, centering, confidence_interval)`](../../../api_docs/api_global/#effector.global_effect_ale.ALE) |
590+
| RHALE | [`effector.RHALE(X, model, model_jac).plot(feature, centering, confidence_interval)`](../../../api_docs/api_global/#effector.global_effect_ale.RHALE) |
614591

615592

616593
```python

docs/docs/quickstart/flexible_api.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,11 @@ jacobian = model.jacobian
9494
`.plot()` all
9595

9696
=== "Simple API"
97-
98-
| `node_idx=1`: $x_1$ when $x_2 \leq 0$ | `node_idx=2`: $x_1$ when $x_2 > 0$ |
99-
|:---------:|:---------:|
100-
| ![Alt text](./../static/quickstart/flexible_api_files/flexible_api_16_0.png) | ![Alt text](./../static/quickstart/flexible_api_files/flexible_api_16_1.png) |
101-
| `node_idx=1`: $x_1$ when $x_2 \leq 0$ | `node_idx=2`: $x_1$ when $x_2 > 0$ |
97+
| `node_idx=3`: $x_0$ when $x_1 \leq 0$ and $x_2 \leq 0$ | `node_idx=4`: $x_0$ when $x_1 > 0$ and $x_2 \leq 0$|
10298
|:---------:|:---------:|
10399
| ![Alt text](./../static/quickstart/flexible_api_files/flexible_api_16_0.png) | ![Alt text](./../static/quickstart/flexible_api_files/flexible_api_16_1.png) |
100+
| `node_idx=5`: $x_0$ when $x_1 \leq 0$ and $x_2 > 0$ | `node_idx=6`: $x_0$ when $x_1 > 0$ and $x_2 > 0$|
101+
| ![Alt text](./../static/quickstart/flexible_api_files/flexible_api_16_2.png) | ![Alt text](./../static/quickstart/flexible_api_files/flexible_api_16_3.png) |
104102

105103
=== "Flexible API"
106104

@@ -109,6 +107,6 @@ jacobian = model.jacobian
109107
rhale.plot(feature=0, node_idx=2, y_limits=y_limits, dy_limits=dy_limits)
110108
```
111109

112-
| `node_idx=1`: $x_1$ when $x_2 \leq 0$ | `node_idx=2`: $x_1$ when $x_2 > 0$ |
110+
| `node_idx=1`: $x_0$ when $x_2 \leq 0$ | `node_idx=2`: $x_0$ when $x_2 > 0$ |
113111
|:---------:|:---------:|
114112
| ![Alt text](./../static/quickstart/flexible_api_files/flexible_api_20_0.png) | ![Alt text](./../static/quickstart/flexible_api_files/flexible_api_20_1.png) |

docs/docs/quickstart/simple_api.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ Apart from the added `node_idx` argument, the API is the same as the global effe
420420
[regional_effect.plot(0, node_idx) for node_idx in [1, 2]]
421421
```
422422

423-
| `node_idx=1`: $x_1$ when $x_2 \leq 0$ | `node_idx=2`: $x_1$ when $x_2 > 0$ |
423+
| `node_idx=1`: $x_0$ when $x_1 \leq 0$ | `node_idx=2`: $x_0$ when $x_1 > 0$ |
424424
|:---------:|:---------:|
425425
| ![Alt text](./../static/quickstart/simple_api_files/simple_api_20_0.png) | ![Alt text](./../static/quickstart/simple_api_files/simple_api_20_1.png) |
426426

@@ -431,7 +431,7 @@ Apart from the added `node_idx` argument, the API is the same as the global effe
431431
[regional_effect.plot(0, node_idx) for node_idx in [1, 2]]
432432
```
433433

434-
| `node_idx=1`: $x_1$ when $x_2 \leq 0$ | `node_idx=2`: $x_1$ when $x_2 > 0$ |
434+
| `node_idx=1`: $x_0$ when $x_1 \leq 0$ | `node_idx=2`: $x_0$ when $x_1 > 0$ |
435435
|:---------:|:---------:|
436436
| ![Alt text](./../static/quickstart/simple_api_files/simple_api_23_0.png) | ![Alt text](./../static/quickstart/simple_api_files/simple_api_23_1.png) |
437437

@@ -442,7 +442,7 @@ Apart from the added `node_idx` argument, the API is the same as the global effe
442442
[regional_effect.plot(0, node_idx) for node_idx in [1, 2]]
443443
```
444444

445-
| `node_idx=1`: $x_1$ when $x_2 \leq 0$ | `node_idx=2`: $x_1$ when $x_2 > 0$ |
445+
| `node_idx=1`: $x_0$ when $x_1 \leq 0$ | `node_idx=2`: $x_0$ when $x_1 > 0$ |
446446
|:---------:|:---------:|
447447
| ![Alt text](./../static/quickstart/simple_api_files/simple_api_26_0.png) | ![Alt text](./../static/quickstart/simple_api_files/simple_api_26_1.png) |
448448

@@ -453,7 +453,7 @@ Apart from the added `node_idx` argument, the API is the same as the global effe
453453
[regional_effect.plot(0, node_idx) for node_idx in [1, 2]]
454454
```
455455

456-
| `node_idx=1`: $x_1$ when $x_2 \leq 0$ | `node_idx=2`: $x_1$ when $x_2 > 0$ |
456+
| `node_idx=1`: $x_0$ when $x_1 \leq 0$ | `node_idx=2`: $x_0$ when $x_1 > 0$ |
457457
|:---------:|:---------:|
458458
| ![Alt text](./../static/quickstart/simple_api_files/simple_api_29_0.png) | ![Alt text](./../static/quickstart/simple_api_files/simple_api_29_1.png) |
459459

@@ -465,7 +465,7 @@ Apart from the added `node_idx` argument, the API is the same as the global effe
465465
[regional_effect.plot(0, node_idx) for node_idx in [1, 2]]
466466
```
467467

468-
| `node_idx=1`: $x_1$ when $x_2 \leq 0$ | `node_idx=2`: $x_1$ when $x_2 > 0$ |
468+
| `node_idx=1`: $x_0$ when $x_1 \leq 0$ | `node_idx=2`: $x_0$ when $x_1 > 0$ |
469469
|:---------:|:---------:|
470470
| ![Alt text](./../static/quickstart/simple_api_files/simple_api_32_0.png) | ![Alt text](./../static/quickstart/simple_api_files/simple_api_32_1.png) |
471471

0 commit comments

Comments
 (0)