Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Jan 13, 2025
1 parent 19e6cf7 commit def7341
Show file tree
Hide file tree
Showing 53 changed files with 169 additions and 181 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"outputs": [],
"source": [
"import matplotlib.lines as mlines\nimport matplotlib.pyplot as plt\nimport numpy as np\nfrom scipy.linalg import toeplitz\nfrom scipy.stats import ttest_1samp\nfrom sklearn.base import clone\nfrom sklearn.linear_model import RidgeCV\nfrom sklearn.metrics import log_loss\nfrom sklearn.model_selection import RandomizedSearchCV, StratifiedKFold\nfrom sklearn.svm import SVC\n\nfrom hidimstat import CPI, PermutationImportance"
"import matplotlib.lines as mlines\nimport matplotlib.pyplot as plt\nimport numpy as np\nfrom scipy.linalg import toeplitz\nfrom scipy.stats import ttest_1samp\nfrom sklearn.base import clone\nfrom sklearn.linear_model import RidgeCV\nfrom sklearn.metrics import hinge_loss\nfrom sklearn.model_selection import RandomizedSearchCV, StratifiedKFold\nfrom sklearn.svm import SVC\n\nfrom hidimstat import CPI, PermutationImportance"
]
},
{
Expand Down Expand Up @@ -76,7 +76,7 @@
},
"outputs": [],
"source": [
"seed = 0\ncv = StratifiedKFold(n_splits=5, shuffle=True, random_state=seed)\nimportance_linear = []\nimportance_non_linear = []\nimportant_pi = []\n\nmodel_linear = RandomizedSearchCV(\n SVC(random_state=seed, kernel=\"linear\"),\n param_distributions={\n \"C\": np.logspace(-3, 3, 10),\n },\n n_iter=10,\n n_jobs=5,\n random_state=seed,\n)\nmodel_non_linear = RandomizedSearchCV(\n SVC(\n random_state=seed,\n kernel=\"poly\",\n degree=2,\n coef0=1,\n ),\n param_distributions={\n \"C\": np.logspace(-3, 3, 10),\n },\n n_iter=10,\n n_jobs=5,\n random_state=seed,\n)\nimputation_model = RidgeCV(alphas=np.logspace(-3, 3, 50))\n\n\nimportance_list = []\nfor train, test in cv.split(X, y):\n model_linear_c = clone(model_linear)\n model_linear_c.fit(X[train], y[train])\n cpi_linear = CPI(\n estimator=model_linear_c,\n imputation_model=clone(imputation_model),\n n_permutations=50,\n n_jobs=5,\n loss=log_loss,\n random_state=seed,\n method=\"decision_function\",\n )\n cpi_linear.fit(X[train], y[train])\n imp_cpi_linear = cpi_linear.score(X[test], y[test])[\"importance\"]\n\n model_non_linear_c = clone(model_non_linear)\n model_non_linear_c.fit(X[train], y[train])\n cpi_non_linear = CPI(\n estimator=model_non_linear_c,\n imputation_model=clone(imputation_model),\n n_permutations=50,\n n_jobs=5,\n loss=log_loss,\n random_state=seed,\n method=\"decision_function\",\n )\n cpi_non_linear.fit(X[train], y[train])\n imp_cpi_non_linear = cpi_non_linear.score(X[test], y[test])[\"importance\"]\n\n pi_non_linear = PermutationImportance(\n estimator=model_non_linear_c,\n n_permutations=50,\n n_jobs=5,\n random_state=seed,\n method=\"decision_function\",\n )\n pi_non_linear.fit(X[train], y[train])\n imp_pi_non_linear = pi_non_linear.score(X[test], y[test])[\"importance\"]\n\n importance_list.append(\n np.stack(\n [\n imp_cpi_linear,\n imp_cpi_non_linear,\n imp_pi_non_linear,\n ]\n )\n )\n\nimportance_arr = np.stack(importance_list)"
"seed = 0\ncv = StratifiedKFold(n_splits=5, shuffle=True, random_state=seed)\nimportance_linear = []\nimportance_non_linear = []\nimportant_pi = []\n\nmodel_linear = RandomizedSearchCV(\n SVC(random_state=seed, kernel=\"linear\"),\n param_distributions={\n \"C\": np.logspace(-3, 3, 10),\n },\n n_iter=10,\n n_jobs=5,\n random_state=seed,\n)\nmodel_non_linear = RandomizedSearchCV(\n SVC(\n random_state=seed,\n kernel=\"poly\",\n degree=2,\n coef0=1,\n ),\n param_distributions={\n \"C\": np.logspace(-3, 3, 10),\n },\n n_iter=10,\n n_jobs=5,\n random_state=seed,\n)\nimputation_model = RidgeCV(alphas=np.logspace(-3, 3, 50))\n\n\nimportance_list = []\nfor train, test in cv.split(X, y):\n model_linear_c = clone(model_linear)\n model_linear_c.fit(X[train], y[train])\n cpi_linear = CPI(\n estimator=model_linear_c,\n imputation_model=clone(imputation_model),\n n_permutations=50,\n n_jobs=5,\n loss=hinge_loss,\n random_state=seed,\n method=\"decision_function\",\n )\n cpi_linear.fit(X[train], y[train])\n imp_cpi_linear = cpi_linear.score(X[test], y[test])[\"importance\"]\n\n model_non_linear_c = clone(model_non_linear)\n model_non_linear_c.fit(X[train], y[train])\n cpi_non_linear = CPI(\n estimator=model_non_linear_c,\n imputation_model=clone(imputation_model),\n n_permutations=50,\n n_jobs=5,\n loss=hinge_loss,\n random_state=seed,\n method=\"decision_function\",\n )\n cpi_non_linear.fit(X[train], y[train])\n imp_cpi_non_linear = cpi_non_linear.score(X[test], y[test])[\"importance\"]\n\n pi_non_linear = PermutationImportance(\n estimator=model_non_linear_c,\n n_permutations=50,\n n_jobs=5,\n random_state=seed,\n method=\"decision_function\",\n )\n pi_non_linear.fit(X[train], y[train])\n imp_pi_non_linear = pi_non_linear.score(X[test], y[test])[\"importance\"]\n\n importance_list.append(\n np.stack(\n [\n imp_cpi_linear,\n imp_cpi_non_linear,\n imp_pi_non_linear,\n ]\n )\n )\n\nimportance_arr = np.stack(importance_list)"
]
},
{
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from scipy.stats import ttest_1samp
from sklearn.base import clone
from sklearn.linear_model import RidgeCV
from sklearn.metrics import log_loss
from sklearn.metrics import hinge_loss
from sklearn.model_selection import RandomizedSearchCV, StratifiedKFold
from sklearn.svm import SVC

Expand Down Expand Up @@ -163,7 +163,7 @@
imputation_model=clone(imputation_model),
n_permutations=50,
n_jobs=5,
loss=log_loss,
loss=hinge_loss,
random_state=seed,
method="decision_function",
)
Expand All @@ -177,7 +177,7 @@
imputation_model=clone(imputation_model),
n_permutations=50,
n_jobs=5,
loss=log_loss,
loss=hinge_loss,
random_state=seed,
method="decision_function",
)
Expand Down
Binary file modified docs/_images/sphx_glr_plot_variable_importance_classif_002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -554,9 +554,9 @@ randomization.

.. rst-class:: sphx-glr-timing

**Total running time of the script:** (1 minutes 11.171 seconds)
**Total running time of the script:** (1 minutes 5.243 seconds)

**Estimated memory usage:** 704 MB
**Estimated memory usage:** 701 MB


.. _sphx_glr_download_auto_examples_plot_2D_simulation_example.py:
Expand Down
4 changes: 2 additions & 2 deletions docs/_sources/auto_examples/plot_dcrt_example.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ Plotting the comparison

.. rst-class:: sphx-glr-timing

**Total running time of the script:** (1 minutes 5.337 seconds)
**Total running time of the script:** (1 minutes 2.810 seconds)

**Estimated memory usage:** 640 MB
**Estimated memory usage:** 638 MB


.. _sphx_glr_download_auto_examples_plot_dcrt_example.py:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,9 @@ Analyze the results
.. rst-class:: sphx-glr-timing

**Total running time of the script:** (0 minutes 9.424 seconds)
**Total running time of the script:** (0 minutes 8.765 seconds)

**Estimated memory usage:** 625 MB
**Estimated memory usage:** 623 MB


.. _sphx_glr_download_auto_examples_plot_diabetes_variable_importance_example.py:
Expand Down
20 changes: 8 additions & 12 deletions docs/_sources/auto_examples/plot_fmri_data_example.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,19 +176,15 @@ You may choose a subject in [1, 2, 3, 4, 5, 6]. By default subject=2.
[_add_readme_to_default_data_locations] Added README.md to /home/runner/nilearn_data
[get_dataset_dir] Dataset created in /home/runner/nilearn_data/haxby2001
[fetch_single_file] Downloading data from https://www.nitrc.org/frs/download.php/7868/mask.nii.gz ...
[fetch_single_file] ...done. (1 seconds, 0 min)
[fetch_single_file] ...done. (0 seconds, 0 min)
[fetch_single_file] Downloading data from http://data.pymvpa.org/datasets/haxby2001/MD5SUMS ...
[fetch_single_file] ...done. (0 seconds, 0 min)
[fetch_single_file] Downloading data from http://data.pymvpa.org/datasets/haxby2001/subj2-2010.01.14.tar.gz ...
[_chunk_report_] Downloaded 21749760 of 291168628 bytes (7.5%%, 12.7s remaining)
[_chunk_report_] Downloaded 67272704 of 291168628 bytes (23.1%%, 6.8s remaining)
[_chunk_report_] Downloaded 112746496 of 291168628 bytes (38.7%%, 4.8s remaining)
[_chunk_report_] Downloaded 156139520 of 291168628 bytes (53.6%%, 3.5s remaining)
[_chunk_report_] Downloaded 200409088 of 291168628 bytes (68.8%%, 2.3s remaining)
[_chunk_report_] Downloaded 245473280 of 291168628 bytes (84.3%%, 1.1s remaining)
[fetch_single_file] ...done. (7 seconds, 0 min)
[_chunk_report_] Downloaded 84115456 of 291168628 bytes (28.9%%, 2.5s remaining)
[_chunk_report_] Downloaded 187072512 of 291168628 bytes (64.2%%, 1.1s remaining)
[fetch_single_file] ...done. (3 seconds, 0 min)
[uncompress_file] Extracting data from /home/runner/nilearn_data/haxby2001/9cabe068089e791ef0c5fe930fc20e30/subj2-2010.01.14.tar.gz...
[uncompress_file] .. done.
Expand Down Expand Up @@ -293,7 +289,7 @@ Now, we compute p-values thanks to permutation tests applied to
.. code-block:: none
[Parallel(n_jobs=1)]: Done 49 tasks | elapsed: 1.6s
[Parallel(n_jobs=1)]: Done 199 tasks | elapsed: 6.7s
[Parallel(n_jobs=1)]: Done 199 tasks | elapsed: 6.6s
Expand Down Expand Up @@ -374,7 +370,7 @@ However you might benefit from clustering randomization taking
.. code-block:: none
[Parallel(n_jobs=2)]: Using backend LokyBackend with 2 concurrent workers.
[Parallel(n_jobs=2)]: Done 5 out of 5 | elapsed: 36.0s finished
[Parallel(n_jobs=2)]: Done 5 out of 5 | elapsed: 34.2s finished
Expand Down Expand Up @@ -619,9 +615,9 @@ spurious discoveries.
.. rst-class:: sphx-glr-timing

**Total running time of the script:** (1 minutes 35.950 seconds)
**Total running time of the script:** (1 minutes 27.619 seconds)

**Estimated memory usage:** 3251 MB
**Estimated memory usage:** 3365 MB


.. _sphx_glr_download_auto_examples_plot_fmri_data_example.py:
Expand Down
4 changes: 2 additions & 2 deletions docs/_sources/auto_examples/plot_knockoff_aggregation.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ Imports needed for this script

.. rst-class:: sphx-glr-timing

**Total running time of the script:** (5 minutes 51.290 seconds)
**Total running time of the script:** (5 minutes 39.528 seconds)

**Estimated memory usage:** 785 MB
**Estimated memory usage:** 815 MB


.. _sphx_glr_download_auto_examples_plot_knockoff_aggregation.py:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Imports needed
from scipy.stats import ttest_1samp
from sklearn.base import clone
from sklearn.linear_model import RidgeCV
from sklearn.metrics import log_loss
from sklearn.metrics import hinge_loss
from sklearn.model_selection import RandomizedSearchCV, StratifiedKFold
from sklearn.svm import SVC
Expand Down Expand Up @@ -176,7 +176,7 @@ Visualize the data
.. code-block:: none
[<matplotlib.axis.YTick object at 0x7fee88776120>, <matplotlib.axis.YTick object at 0x7fee887745c0>, <matplotlib.axis.YTick object at 0x7fee884de6f0>, <matplotlib.axis.YTick object at 0x7fee884dcc80>, <matplotlib.axis.YTick object at 0x7fee86056ff0>, <matplotlib.axis.YTick object at 0x7fee884dc680>, <matplotlib.axis.YTick object at 0x7fee884dd280>, <matplotlib.axis.YTick object at 0x7fee884dc4a0>, <matplotlib.axis.YTick object at 0x7fee8600fa70>, <matplotlib.axis.YTick object at 0x7fee884df770>]
[<matplotlib.axis.YTick object at 0x7fa1fa109160>, <matplotlib.axis.YTick object at 0x7fa1fa1a36b0>, <matplotlib.axis.YTick object at 0x7fa1fb042330>, <matplotlib.axis.YTick object at 0x7fa1fb0406b0>, <matplotlib.axis.YTick object at 0x7fa1fb101820>, <matplotlib.axis.YTick object at 0x7fa1fb043e30>, <matplotlib.axis.YTick object at 0x7fa1fb0414c0>, <matplotlib.axis.YTick object at 0x7fa1f94ed1c0>, <matplotlib.axis.YTick object at 0x7fa1f94ef4a0>, <matplotlib.axis.YTick object at 0x7fa1fb0410d0>]
Expand Down Expand Up @@ -236,7 +236,7 @@ estimate the importance of the features.
imputation_model=clone(imputation_model),
n_permutations=50,
n_jobs=5,
loss=log_loss,
loss=hinge_loss,
random_state=seed,
method="decision_function",
)
Expand All @@ -250,7 +250,7 @@ estimate the importance of the features.
imputation_model=clone(imputation_model),
n_permutations=50,
n_jobs=5,
loss=log_loss,
loss=hinge_loss,
random_state=seed,
method="decision_function",
)
Expand Down Expand Up @@ -422,16 +422,16 @@ the features.
.. code-block:: none
<matplotlib.legend.Legend object at 0x7fee8600ff20>
<matplotlib.legend.Legend object at 0x7fa1f94f54c0>
.. rst-class:: sphx-glr-timing

**Total running time of the script:** (0 minutes 44.780 seconds)
**Total running time of the script:** (0 minutes 44.777 seconds)

**Estimated memory usage:** 621 MB
**Estimated memory usage:** 619 MB


.. _sphx_glr_download_auto_examples_plot_variable_importance_classif.py:
Expand Down
26 changes: 13 additions & 13 deletions docs/_sources/auto_examples/sg_execution_times.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Computation times
=================
**10:37.954** total execution time for 6 files **from auto_examples**:
**10:08.743** total execution time for 6 files **from auto_examples**:

.. container::

Expand All @@ -33,20 +33,20 @@ Computation times
- Time
- Mem (MB)
* - :ref:`sphx_glr_auto_examples_plot_knockoff_aggregation.py` (``plot_knockoff_aggregation.py``)
- 05:51.290
- 785.0
- 05:39.528
- 814.6
* - :ref:`sphx_glr_auto_examples_plot_fmri_data_example.py` (``plot_fmri_data_example.py``)
- 01:35.950
- 3250.8
- 01:27.619
- 3365.0
* - :ref:`sphx_glr_auto_examples_plot_2D_simulation_example.py` (``plot_2D_simulation_example.py``)
- 01:11.171
- 704.2
- 01:05.243
- 701.4
* - :ref:`sphx_glr_auto_examples_plot_dcrt_example.py` (``plot_dcrt_example.py``)
- 01:05.337
- 639.9
- 01:02.810
- 637.9
* - :ref:`sphx_glr_auto_examples_plot_variable_importance_classif.py` (``plot_variable_importance_classif.py``)
- 00:44.780
- 621.0
- 00:44.777
- 618.6
* - :ref:`sphx_glr_auto_examples_plot_diabetes_variable_importance_example.py` (``plot_diabetes_variable_importance_example.py``)
- 00:09.424
- 625.3
- 00:08.765
- 622.7
26 changes: 13 additions & 13 deletions docs/_sources/sg_execution_times.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Computation times
=================
**10:37.954** total execution time for 6 files **from all galleries**:
**10:08.743** total execution time for 6 files **from all galleries**:

.. container::

Expand All @@ -33,20 +33,20 @@ Computation times
- Time
- Mem (MB)
* - :ref:`sphx_glr_auto_examples_plot_knockoff_aggregation.py` (``../examples/plot_knockoff_aggregation.py``)
- 05:51.290
- 785.0
- 05:39.528
- 814.6
* - :ref:`sphx_glr_auto_examples_plot_fmri_data_example.py` (``../examples/plot_fmri_data_example.py``)
- 01:35.950
- 3250.8
- 01:27.619
- 3365.0
* - :ref:`sphx_glr_auto_examples_plot_2D_simulation_example.py` (``../examples/plot_2D_simulation_example.py``)
- 01:11.171
- 704.2
- 01:05.243
- 701.4
* - :ref:`sphx_glr_auto_examples_plot_dcrt_example.py` (``../examples/plot_dcrt_example.py``)
- 01:05.337
- 639.9
- 01:02.810
- 637.9
* - :ref:`sphx_glr_auto_examples_plot_variable_importance_classif.py` (``../examples/plot_variable_importance_classif.py``)
- 00:44.780
- 621.0
- 00:44.777
- 618.6
* - :ref:`sphx_glr_auto_examples_plot_diabetes_variable_importance_example.py` (``../examples/plot_diabetes_variable_importance_example.py``)
- 00:09.424
- 625.3
- 00:08.765
- 622.7
2 changes: 1 addition & 1 deletion docs/_static/documentation_options.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const DOCUMENTATION_OPTIONS = {
VERSION: '0.1.dev1+g85746e2',
VERSION: '0.1.dev1+g19e6cf7',
LANGUAGE: 'en',
COLLAPSE_INDEX: false,
BUILDER: 'html',
Expand Down
4 changes: 2 additions & 2 deletions docs/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

<title>API Documentation &#8212; HiDimStat 0.1.dev1+g85746e2 documentation</title>
<title>API Documentation &#8212; HiDimStat 0.1.dev1+g19e6cf7 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="_static/bootstrap-sphinx.css?v=284a2d1d" />
<link rel="stylesheet" type="text/css" href="_static/style.css?v=fbda0898" />
<link rel="stylesheet" type="text/css" href="_static/sg_gallery.css?v=d2d258e8" />
<link rel="stylesheet" type="text/css" href="_static/sg_gallery-binder.css?v=f4aeca0c" />
<link rel="stylesheet" type="text/css" href="_static/sg_gallery-dataframe.css?v=2082cf3c" />
<link rel="stylesheet" type="text/css" href="_static/sg_gallery-rendered-html.css?v=1277b6f3" />
<script src="_static/documentation_options.js?v=2751c6d6"></script>
<script src="_static/documentation_options.js?v=4f73dee8"></script>
<script src="_static/doctools.js?v=9bcbadda"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<link rel="index" title="Index" href="genindex.html" />
Expand Down
4 changes: 2 additions & 2 deletions docs/auto_examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

<title>Examples Gallery &#8212; HiDimStat 0.1.dev1+g85746e2 documentation</title>
<title>Examples Gallery &#8212; HiDimStat 0.1.dev1+g19e6cf7 documentation</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="../_static/bootstrap-sphinx.css?v=284a2d1d" />
<link rel="stylesheet" type="text/css" href="../_static/style.css?v=fbda0898" />
<link rel="stylesheet" type="text/css" href="../_static/sg_gallery.css?v=d2d258e8" />
<link rel="stylesheet" type="text/css" href="../_static/sg_gallery-binder.css?v=f4aeca0c" />
<link rel="stylesheet" type="text/css" href="../_static/sg_gallery-dataframe.css?v=2082cf3c" />
<link rel="stylesheet" type="text/css" href="../_static/sg_gallery-rendered-html.css?v=1277b6f3" />
<script src="../_static/documentation_options.js?v=2751c6d6"></script>
<script src="../_static/documentation_options.js?v=4f73dee8"></script>
<script src="../_static/doctools.js?v=9bcbadda"></script>
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
<script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
Expand Down
Loading

0 comments on commit def7341

Please sign in to comment.