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

ADA-SVR (3/4) PR example of models #100

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
35a877f
Add documentation to ADA SVR
lionelkusch Dec 18, 2024
45d9992
Change name of the file
lionelkusch Dec 18, 2024
e28b8b8
fix bug in example
lionelkusch Dec 19, 2024
0a2fab4
Fix some error in conf of sphinx
lionelkusch Dec 19, 2024
02adbb5
Remove all the warning and error for generate docstring
lionelkusch Dec 19, 2024
358bd68
Format files
lionelkusch Dec 19, 2024
fd41d6c
Merge branch 'PR_comment_ADA-SVR' into PR_example_ADA_SVR
lionelkusch Dec 19, 2024
df80078
Include methods description in the examples
lionelkusch Dec 20, 2024
2a8f3c4
fix documentation
lionelkusch Dec 20, 2024
d3871f4
Add example for ADA-SVR
lionelkusch Dec 23, 2024
f868469
Add functions for get pvalue and fix format and doctsring
lionelkusch Dec 23, 2024
b1c14e1
Fix format
lionelkusch Dec 23, 2024
7cf0c4d
Add figure for ADA-SVR
lionelkusch Dec 23, 2024
71d407e
Add function for plotting elements
lionelkusch Dec 23, 2024
a530252
Fix typo
lionelkusch Dec 23, 2024
7ab4bfb
remove unecessary line
lionelkusch Dec 23, 2024
83f049e
unecessary option
lionelkusch Dec 23, 2024
5887b1b
Add a section in examples
lionelkusch Dec 26, 2024
05f47a7
Fix typo
lionelkusch Dec 26, 2024
e607676
Apply suggestions from code review
lionelkusch Dec 26, 2024
2e4037a
Fix include copyright figure
lionelkusch Dec 26, 2024
ca9575e
Fix format of the docstring
lionelkusch Dec 26, 2024
5c42cc3
Remove a comment of advantages
lionelkusch Dec 26, 2024
d73aeb9
Merge remote-tracking branch 'refs/remotes/origin/PR_example_ADA_SVR'…
lionelkusch Dec 26, 2024
ded4d51
Change folder for plotting result
lionelkusch Dec 26, 2024
ebad58c
Not use example as packages
lionelkusch Dec 26, 2024
64116e9
Change name of the file for methods
lionelkusch Dec 26, 2024
16cdad6
Update hidimstat/visualisation/plot_dataset.py
lionelkusch Dec 31, 2024
d41554f
Merge branch 'main' into PR_example_ADA_SVR
lionelkusch Dec 31, 2024
e895962
Remove previous file
lionelkusch Dec 31, 2024
6e2d4c9
Fix format
lionelkusch Dec 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc_conf/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Functions
:toctree: generated/

ada_svr
ada_svr_pvalue
aggregate_quantiles
clustered_inference
data_simulation
Expand Down
10 changes: 6 additions & 4 deletions doc_conf/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
# built documents.
#
# The short X.Y version.
from hidimstat._version import __version__ # noqa
from hidimstat import __version__

# The full version, including alpha/beta/rc tags.
release = __version__
Expand Down Expand Up @@ -217,9 +217,9 @@
"python": ("https://docs.python.org/3", None),
"numpy": ("https://numpy.org/devdocs", None),
"scipy": ("https://scipy.github.io/devdocs", None),
"matplotlib": ("https://matplotlib.org", None),
"matplotlib": ("https://matplotlib.org/stable/", None),
"sklearn": ("https://scikit-learn.org/stable", None),
"numba": ("https://numba.pydata.org/numba-doc/latest", None),
"numba": ("https://numba.readthedocs.io/en/stable/", None),
"joblib": ("https://joblib.readthedocs.io/en/latest", None),
"pandas": ("https://pandas.pydata.org/pandas-docs/stable", None),
"seaborn": ("https://seaborn.pydata.org/", None),
Expand All @@ -228,7 +228,6 @@

examples_dirs = ["../examples"]
gallery_dirs = ["auto_examples"]
import mne

scrapers = ("matplotlib",)
try:
Expand All @@ -240,6 +239,7 @@
pass
if any(x in scrapers for x in ("pyvista")):
from traits.api import push_exception_handler
import mne

push_exception_handler(reraise_exceptions=True)
report_scraper = mne.report._ReportScraper()
Expand All @@ -259,6 +259,8 @@
"abort_on_example_error": False,
"image_scrapers": scrapers,
"show_memory": True,
'filename_pattern': r'\.py',
'ignore_pattern': r'__init__\.py',
# 'reference_url': {
# 'numpy': 'http://docs.scipy.org/doc/numpy-1.9.1',
# 'scipy': 'http://docs.scipy.org/doc/scipy-0.17.0/reference',
Expand Down
19 changes: 9 additions & 10 deletions doc_conf/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ is also needed to install ``pytest``.
Documentation & Examples
------------------------

Documentation about the main HiDimStat functions is available
`here <api.html>`_ and examples are available `here <auto_examples/index.html>`_.
Documentation of HiDimStat is composed of an `API <api.html>`_ and `examples <auto_examples/index.html>`_.

As of now, there are three different examples (Python scripts) that
illustrate how to use the main HiDimStat functions.
Expand Down Expand Up @@ -118,15 +117,15 @@ Application to source localization (MEG/EEG data):

Single/Group statistically validated importance using conditional permutations:

* Chamma, A., Thirion, B., & Engemann, D. (2024). **Variable importance in
high-dimensional settings requires grouping**. In Proceedings of the 38th
Conference of the Association for the Advancement of Artificial
Intelligence(AAAI 2024), Vancouver, Canada.
* Chamma, A., Thirion, B., & Engemann, D. (2024). Variable importance in
high-dimensional settings requires grouping. In Proceedings of the 38th
Conference of the Association for the Advancement of Artificial
Intelligence(AAAI 2024), Vancouver, Canada.

* Chamma, A., Engemann, D., & Thirion, B. (2023). **Statistically Valid Variable
Importance Assessment through Conditional Permutations**. In Proceedings of the
37th Conference on Neural Information Processing Systems (NeurIPS 2023), New
Orleans, USA.
* Chamma, A., Engemann, D., & Thirion, B. (2023). Statistically Valid Variable
Importance Assessment through Conditional Permutations. In Proceedings of the
37th Conference on Neural Information Processing Systems (NeurIPS 2023), New
Orleans, USA.

If you use our packages, we would appreciate citations to the relevant
aforementioned papers.
Expand Down
26 changes: 25 additions & 1 deletion doc_conf/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,28 @@ @article{liuFastPowerfulConditional2021
archiveprefix = {arxiv},
keywords = {Statistics - Methodology},
file = {/home/ahmad/Zotero/storage/8HRQZX3H/Liu et al. - 2021 - Fast and Powerful Conditional Randomization Testin.pdf;/home/ahmad/Zotero/storage/YFNDKN2B/2006.html}
}
}

@article{gaonkar_deriving_2012,
title = {Deriving statistical significance maps for {SVM} based image classification and group comparisons},
volume = {15},
url = {https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3703958/},
abstract = {Population based pattern analysis and classification for quantifying structural and functional differences between diverse groups has been shown to be a powerful tool for the study of a number of diseases, and is quite commonly used especially in neuroimaging. The alternative to these pattern analysis methods, namely mass univariate methods such as voxel based analysis and all related methods, cannot detect multivariate patterns associated with group differences, and are not particularly suitable for developing individual-based diagnostic and prognostic biomarkers. A commonly used pattern analysis tool is the support vector machine ({SVM}). Unlike univariate statistical frameworks for morphometry, analytical tools for statistical inference are unavailable for the {SVM}. In this paper, we show that null distributions ordinarily obtained by permutation tests using {SVMs} can be analytically approximated from the data. The analytical computation takes a small fraction of the time it takes to do an actual permutation test, thereby rendering it possible to quickly create statistical significance maps derived from {SVMs}. Such maps are critical for understanding imaging patterns of group differences and interpreting which anatomical regions are important in determining the classifier's decision.},
pages = {723--730},
number = {0},
journaltitle = {Medical image computing and computer-assisted intervention : {MICCAI} ... International Conference on Medical Image Computing and Computer-Assisted Intervention},
journal = {Med Image Comput Comput Assist Interv},
author = {Gaonkar, Bilwaj and Davatzikos, Christos},
urldate = {2024-12-16},
year = {2012},
pmid = {23285616},
pmcid = {PMC3703958},
file = {PubMed Central Full Text PDF:/home/likusch/Zotero/storage/DX8QQAF5/Gaonkar and Davatzikos - 2012 - Deriving statistical significance maps for SVM based image classification and group comparisons.pdf:application/pdf},
lionelkusch marked this conversation as resolved.
Show resolved Hide resolved
}

@book{molnar2020interpretable,
title={Interpretable machine learning},
author={Molnar, Christoph},
year={2020},
publisher={Lulu. com}
}
2 changes: 1 addition & 1 deletion examples/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ Examples Gallery

.. contents:: Contents
:local:
:depth: 3
:depth: 0
Empty file added examples/__init__.py
Empty file.
Empty file added examples/_utils/__init__.py
Empty file.
246 changes: 246 additions & 0 deletions examples/_utils/plot_dataset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import LogNorm
from scipy import stats

Check warning on line 4 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L1-L4

Added lines #L1 - L4 were not covered by tests


def plot_dataset1D(X, y, beta, title="Toy dataset"):

Check warning on line 7 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L7

Added line #L7 was not covered by tests
"""
Plot a 1D toy dataset with the true regression line.
Parameters:
- X: Input features (n_samples, n_features)
lionelkusch marked this conversation as resolved.
Show resolved Hide resolved
- y: Vectors of the regression (n_samples,)
- beta: Coefficients of the true variable of importance (n_features,)
- title: Title of the plot (str)

Returns:
- a figure with 3 subplots
"""
# Create a figure and a set of subplots
fig, ([ax11, ax12], [ax21, ax22]) = plt.subplots(

Check warning on line 20 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L20

Added line #L20 was not covered by tests
2, 2, width_ratios=[0.9, 0.01], height_ratios=[0.9, 0.1], figsize=(6.4, 4.8)
)
# plot data
im_X = ax11.imshow(X, aspect="auto", interpolation="nearest")
cbaxes_X = fig.add_axes([0.05, 0.275, 0.03, 0.6])
col_X = plt.colorbar(im_X, cax=cbaxes_X, location="left")
col_X.ax.set_xlabel("X values", loc="center", labelpad=10)
col_X.ax.xaxis.set_label_position("top")
ax11.set_ylabel("n samples")
ax11.set_xlabel("n features")
ax11.set_title("X:data", fontdict={"fontweight": "bold"})

Check warning on line 31 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L24-L31

Added lines #L24 - L31 were not covered by tests
# plot regression
im_Y = ax12.imshow(np.expand_dims(y, 1), aspect="auto", interpolation="nearest")
ax12.set_ylabel("y:regression ", fontdict={"fontweight": "bold"})
ax12.yaxis.tick_right()
ax12.set_xticks([])
cbaxes_Y = fig.add_axes([0.95, 0.275, 0.03, 0.6])
col_Y = plt.colorbar(im_Y, cax=cbaxes_Y, location="left")
col_Y.ax.set_xlabel("Y values ", loc="center", labelpad=10)
col_Y.ax.xaxis.set_label_position("top")

Check warning on line 40 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L33-L40

Added lines #L33 - L40 were not covered by tests
# plot beta
ax21.imshow(np.expand_dims(beta, 0), aspect="auto", interpolation="nearest")
ax21.set_xlabel("beta:variable of importance", fontdict={"fontweight": "bold"})
ax21.set_yticks([])
ax22.axis("off")

Check warning on line 45 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L42-L45

Added lines #L42 - L45 were not covered by tests

plt.suptitle(title)
plt.subplots_adjust(hspace=0.3, left=0.15, right=0.85)

Check warning on line 48 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L47-L48

Added lines #L47 - L48 were not covered by tests


def plot_validate_variable_importance(beta, beta_hat, vmin=0.0, vmax=1.0):

Check warning on line 51 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L51

Added line #L51 was not covered by tests
"""
Plot for validating of the variable importance estimation.
Parameters:
lionelkusch marked this conversation as resolved.
Show resolved Hide resolved
- beta: Coefficients of the true variable of importance (n_features,)
- beta_hat: Coefficients of the estimated variable of importance (n_features,)
- vmin: Minimum value of the colorbar (float)
- vmax: Maximum value of the colorbar (float)

Returns:
- a figure with 2 subplots
"""
fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(6.4, 2.8))

Check warning on line 63 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L63

Added line #L63 was not covered by tests
# plot beta
ax1.imshow(np.expand_dims(beta, 0), vmin=vmin, vmax=vmax)
ax1.set_xlabel("beta:variable of importance", fontdict={"fontweight": "bold"})
ax1.set_yticks([])

Check warning on line 67 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L65-L67

Added lines #L65 - L67 were not covered by tests
# plot beta_hat
im = ax2.imshow(np.expand_dims(beta_hat, 0), vmin=vmin, vmax=vmax)
ax2.set_xlabel("beta hat:variable of importance", fontdict={"fontweight": "bold"})
ax2.set_yticks([])
plt.colorbar(

Check warning on line 72 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L69-L72

Added lines #L69 - L72 were not covered by tests
im, ax=ax2, orientation="horizontal", label="Variable importance", pad=0.5
)

plt.subplots_adjust(top=1.0, bottom=0.2)

Check warning on line 76 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L76

Added line #L76 was not covered by tests


def plot_pvalue_H0(

Check warning on line 79 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L79

Added line #L79 was not covered by tests
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe better: plot_p_values

beta_hat,
pvalue,
pvalue_corrected,
one_minus_pvalue,
one_minus_pvalue_corrected,
vmin=0.0,
vmax=1.0,
):
"""
Plot for the confidence in the hipothse that the variables are important.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Plot for the confidence in the hipothse that the variables are important.
Plot the variable importance p-values

Parameters:
- beta_hat: Coefficients of the estimated variable of importance (n_features,)
- pvalue: pvalue of each variable of importance (n_features,)
- pvalue_corrected: corrected pvalue of each variable of importance (n_features,)
- one_minus_pvalue: 1 - pvalue of each variable of importance (n_features,)
- one_minus_pvalue_corrected: 1 - corrected pvalue of each variable of importance (n_features,)
- vmin: Minimum value of the colorbar (float)
- vmax: Maximum value of the colorbar (float)

Returns:
- a figure with 3 subplots
Copy link
Contributor

Choose a reason for hiding this comment

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

None

"""
fig, (ax1, ax2, ax3) = plt.subplots(3, 1, figsize=(6.4, 4.8))

Check warning on line 102 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L102

Added line #L102 was not covered by tests
# plot beta_hat
im_beta_hat = ax1.imshow(np.expand_dims(beta_hat, 0), vmin=vmin, vmax=vmax)
ax1.set_title("beta hat:variable of importance", fontdict={"fontweight": "bold"})
ax1.set_yticks([])
colbar_beta_hat = plt.colorbar(

Check warning on line 107 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L104-L107

Added lines #L104 - L107 were not covered by tests
im_beta_hat,
ax=ax1,
orientation="horizontal",
label="Variable importance",
pad=0.2,
)
colbar_beta_hat.ax.xaxis.labelpad = 0

Check warning on line 114 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L114

Added line #L114 was not covered by tests
# plot pvalue
im_pvalue = ax2.imshow(

Check warning on line 116 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L116

Added line #L116 was not covered by tests
np.expand_dims(pvalue, 0),
norm=LogNorm(vmin=np.min(pvalue), vmax=np.max(pvalue)),
cmap=plt.cm.viridis.reversed(),
)
ax2.set_title(

Check warning on line 121 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L121

Added line #L121 was not covered by tests
"pvalue of each variable of importance", fontdict={"fontweight": "bold"}
)
ax2.set_yticks([])
colbar_pvalue = plt.colorbar(

Check warning on line 125 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L124-L125

Added lines #L124 - L125 were not covered by tests
im_pvalue, ax=ax2, orientation="horizontal", label="pvalue", pad=0.2
)
colbar_pvalue.ax.xaxis.labelpad = 0

Check warning on line 128 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L128

Added line #L128 was not covered by tests
# plot pvalue_corrected
im_pvalue_corrected = ax3.imshow(

Check warning on line 130 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L130

Added line #L130 was not covered by tests
np.expand_dims(pvalue_corrected, 0),
norm=LogNorm(vmin=np.min(pvalue_corrected), vmax=np.max(pvalue_corrected)),
cmap=plt.cm.viridis.reversed(),
)
ax3.set_title(

Check warning on line 135 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L135

Added line #L135 was not covered by tests
"corrected pvalue of each variable of importance",
fontdict={"fontweight": "bold"},
)
ax3.set_yticks([])
colbar_pvalue_corrected = plt.colorbar(

Check warning on line 140 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L139-L140

Added lines #L139 - L140 were not covered by tests
im_pvalue_corrected,
ax=ax3,
orientation="horizontal",
label="corrected pvalue",
pad=0.2,
)
colbar_pvalue_corrected.ax.xaxis.labelpad = 0

Check warning on line 147 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L147

Added line #L147 was not covered by tests

plt.subplots_adjust(top=1.0, hspace=0.3)

Check warning on line 149 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L149

Added line #L149 was not covered by tests


def plot_pvalue_H1(

Check warning on line 152 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L152

Added line #L152 was not covered by tests
beta_hat,
pvalue,
pvalue_corrected,
one_minus_pvalue,
one_minus_pvalue_corrected,
vmin=0.0,
vmax=1.0,
):
"""
Plot for the confidence in the hipothse that the variables are not important.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't quite get the difference between the two functions

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The first function plot_pvalue_H0 plots just the pvalue and the corrected pvalue with imshow.
The second function plot_pvalue_H1 plots just the 1-pvalue and the 1-corrected pvalue with imshow.
I want it to separate the t-test to be an important variable and not to be an important variable.

It's actually just a basic plot but this needs to be improved for mixing with the score (beta_hat). It should be replaced by a plot with the score of each variable and the associate p-value for being an important variable or not.

lionelkusch marked this conversation as resolved.
Show resolved Hide resolved
Parameters:
- beta_hat: Coefficients of the estimated variable of importance (n_features,)
- pvalue: pvalue of each variable of importance (n_features,)
- pvalue_corrected: corrected pvalue of each variable of importance (n_features,)
- one_minus_pvalue: 1 - pvalue of each variable of importance (n_features,)
- one_minus_pvalue_corrected: 1 - corrected pvalue of each variable of importance (n_features,)
- vmin: Minimum value of the colorbar (float)
- vmax: Maximum value of the colorbar (float)

Returns:
- a figure with 3 subplots
"""
fig, (ax1, ax2, ax3) = plt.subplots(3, 1, figsize=(6.4, 4.8))
im_beta_hat = ax1.imshow(np.expand_dims(beta_hat, 0), vmin=vmin, vmax=vmax)
ax1.set_title("beta hat:variable of importance", fontdict={"fontweight": "bold"})
ax1.set_yticks([])
colbar_beta_hat = plt.colorbar(

Check warning on line 179 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L175-L179

Added lines #L175 - L179 were not covered by tests
im_beta_hat,
ax=ax1,
orientation="horizontal",
label="Variable importance",
pad=0.2,
)
colbar_beta_hat.ax.xaxis.labelpad = 0
im_pvalue = ax2.imshow(

Check warning on line 187 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L186-L187

Added lines #L186 - L187 were not covered by tests
np.expand_dims(one_minus_pvalue_corrected, 0),
norm=LogNorm(
vmin=np.min(one_minus_pvalue), vmax=np.max(one_minus_pvalue_corrected)
),
cmap=plt.cm.viridis.reversed(),
)
ax2.set_title(

Check warning on line 194 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L194

Added line #L194 was not covered by tests
"pvalue of each variable of importance", fontdict={"fontweight": "bold"}
)
ax2.set_yticks([])
colbar_pvalue = plt.colorbar(

Check warning on line 198 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L197-L198

Added lines #L197 - L198 were not covered by tests
im_pvalue, ax=ax2, orientation="horizontal", label="pvalue", pad=0.2
)
colbar_pvalue.ax.xaxis.labelpad = 0
im_pvalue_corrected = ax3.imshow(

Check warning on line 202 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L201-L202

Added lines #L201 - L202 were not covered by tests
np.expand_dims(one_minus_pvalue_corrected, 0),
norm=LogNorm(
vmin=np.min(one_minus_pvalue_corrected),
vmax=np.max(one_minus_pvalue_corrected),
),
cmap=plt.cm.viridis.reversed(),
)
ax3.set_title(

Check warning on line 210 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L210

Added line #L210 was not covered by tests
"corrected pvalue of each variable of importance",
fontdict={"fontweight": "bold"},
)
ax3.set_yticks([])
colbar_pvalue_corrected = plt.colorbar(

Check warning on line 215 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L214-L215

Added lines #L214 - L215 were not covered by tests
im_pvalue_corrected,
ax=ax3,
orientation="horizontal",
label="corrected pvalue",
pad=0.2,
)
colbar_pvalue_corrected.ax.xaxis.labelpad = 0
plt.subplots_adjust(top=1.0, hspace=0.3)

Check warning on line 223 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L222-L223

Added lines #L222 - L223 were not covered by tests


def plot_compare_proba_estimated(proba, beta_hat, scale):

Check warning on line 226 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L226

Added line #L226 was not covered by tests
"""
Plot the comparison of the estimated probability with the normal distribution.
Parameters:
lionelkusch marked this conversation as resolved.
Show resolved Hide resolved
- proba: Probability of each coefficent (n_features, n_permutations)
- beta_hat: Coefficients of the estimated variable of importance (n_features,)
- scale: Standard deviation of the distribution of the coefficients (n_features,)

Returns:
- a figure with 5*5 subplots
"""
fig, axs = plt.subplots(5, 5, figsize=(6.4, 4.8))
for index, ax in enumerate(axs.flat):

Check warning on line 238 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L237-L238

Added lines #L237 - L238 were not covered by tests
# plot the histogram of the proba
ax.hist(

Check warning on line 240 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L240

Added line #L240 was not covered by tests
proba[:, index], bins=100, density=True, alpha=0.5, color="b", label="proba"
)
# plot the normal distribution
x = np.linspace(-3 * scale[index], +3 * scale[index], 100)
ax.plot(x, stats.norm.pdf(x, 0.0, scale[index]), "r-", lw=2, label="norm pdf")
ax.set_title(f"beta_hat[{index}]")

Check warning on line 246 in examples/_utils/plot_dataset.py

View check run for this annotation

Codecov / codecov/patch

examples/_utils/plot_dataset.py#L244-L246

Added lines #L244 - L246 were not covered by tests
Binary file added examples/figures/ada_svr_1.jpg
lionelkusch marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions examples/methods/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Description of the methods of the package
=========================================
The package contains the following methods:

.. contents:: Contents
:local:
:depth: 0
Loading
Loading