Skip to content

Commit 8594144

Browse files
committed
MNT use markdown in notebooks
1 parent 9184a5e commit 8594144

14 files changed

Lines changed: 28 additions & 33 deletions

tutorials/notebooks/shortclips/00_download_shortclips.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"name": "python",
9090
"nbconvert_exporter": "python",
9191
"pygments_lexer": "ipython3",
92-
"version": "3.10.9"
92+
"version": "3.8.3"
9393
}
9494
},
9595
"nbformat": 4,

tutorials/notebooks/shortclips/00_setup_colab.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
"name": "python",
133133
"nbconvert_exporter": "python",
134134
"pygments_lexer": "ipython3",
135-
"version": "3.10.9"
135+
"version": "3.8.3"
136136
}
137137
},
138138
"nbformat": 4,

tutorials/notebooks/shortclips/01_plot_explainable_variance.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@
337337
"name": "python",
338338
"nbconvert_exporter": "python",
339339
"pygments_lexer": "ipython3",
340-
"version": "3.10.9"
340+
"version": "3.8.3"
341341
}
342342
},
343343
"nbformat": 4,

tutorials/notebooks/shortclips/02_plot_ridge_regression.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@
386386
"cell_type": "markdown",
387387
"metadata": {},
388388
"source": [
389-
"To summarize, to select the best hyperparameter $\\alpha$, the standard\nmethod is to perform a grid search:\n\n - Split the training set into two subsets: one subset used to fit the\n models, and one subset to estimate the prediction accuracy (*validation\n set*)\n - Define a number of hyperparameter candidates, for example [0.1, 1, 10,\n 100].\n - Fit a separate ridge model with each hyperparameter candidate\n $\\alpha$.\n - Compute the prediction accuracy on the validation set.\n - Select the hyperparameter candidate leading to the best validation\n accuracy.\n\nTo make the grid search less sensitive to the choice of how the training data\nwas split, the process can be repeated for multiple splits. Then, the\ndifferent prediction accuracies can be averaged over splits before the\nhyperparameter selection. Thus, the process is called a *cross-validation*.\n\nLearn more about hyperparameter selection and cross-validation on the\n`scikit-learn documentation\n<https://scikit-learn.org/stable/modules/cross_validation.html>`_.\n\n"
389+
"To summarize, to select the best hyperparameter $\\alpha$, the standard\nmethod is to perform a grid search:\n\n - Split the training set into two subsets: one subset used to fit the\n models, and one subset to estimate the prediction accuracy (*validation\n set*)\n - Define a number of hyperparameter candidates, for example [0.1, 1, 10,\n 100].\n - Fit a separate ridge model with each hyperparameter candidate\n $\\alpha$.\n - Compute the prediction accuracy on the validation set.\n - Select the hyperparameter candidate leading to the best validation\n accuracy.\n\nTo make the grid search less sensitive to the choice of how the training data\nwas split, the process can be repeated for multiple splits. Then, the\ndifferent prediction accuracies can be averaged over splits before the\nhyperparameter selection. Thus, the process is called a *cross-validation*.\n\nLearn more about hyperparameter selection and cross-validation on the\n[scikit-learn documentation](https://scikit-learn.org/stable/modules/cross_validation.html).\n\n"
390390
]
391391
}
392392
],
@@ -406,7 +406,7 @@
406406
"name": "python",
407407
"nbconvert_exporter": "python",
408408
"pygments_lexer": "ipython3",
409-
"version": "3.7.12"
409+
"version": "3.8.3"
410410
}
411411
},
412412
"nbformat": 4,

tutorials/notebooks/shortclips/03_plot_wordnet_model.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"cell_type": "markdown",
1616
"metadata": {},
1717
"source": [
18-
"\n# Fit a ridge model with wordnet features\n\nIn this example, we model the fMRI responses with semantic \"wordnet\" features,\nmanually annotated on each frame of the movie stimulus. The model is a\nregularized linear regression model, known as ridge regression. Since this\nmodel is used to predict brain activity from the stimulus, it is called a\n(voxelwise) encoding model.\n\nThis example reproduces part of the analysis described in Huth et al (2012)\n[1]_. See this publication for more details about the experiment, the wordnet\nfeatures, along with more results and more discussions.\n\n*Wordnet features:* The features used in this example are semantic labels\nmanually annotated on each frame of the movie stimulus. The semantic labels\ninclude nouns (such as \"woman\", \"car\", or \"building\") and verbs (such as\n\"talking\", \"touching\", or \"walking\"), for a total of 1705 distinct category\nlabels. To interpret our model, labels can be organized in a graph of semantic\nrelashionship based on the `Wordnet <https://wordnet.princeton.edu/>`_ dataset.\n\n*Summary:* We first concatenate the features with multiple temporal delays to\naccount for the slow hemodynamic response. We then use linear regression to fit\na predictive model of brain activity. The linear regression is regularized to\nimprove robustness to correlated features and to improve generalization\nperformance. The optimal regularization hyperparameter is selected over a\ngrid-search with cross-validation. Finally, the model generalization\nperformance is evaluated on a held-out test set, comparing the model\npredictions to the corresponding ground-truth fMRI responses.\n"
18+
"\n# Fit a ridge model with wordnet features\n\nIn this example, we model the fMRI responses with semantic \"wordnet\" features,\nmanually annotated on each frame of the movie stimulus. The model is a\nregularized linear regression model, known as ridge regression. Since this\nmodel is used to predict brain activity from the stimulus, it is called a\n(voxelwise) encoding model.\n\nThis example reproduces part of the analysis described in Huth et al (2012)\n[1]_. See this publication for more details about the experiment, the wordnet\nfeatures, along with more results and more discussions.\n\n*Wordnet features:* The features used in this example are semantic labels\nmanually annotated on each frame of the movie stimulus. The semantic labels\ninclude nouns (such as \"woman\", \"car\", or \"building\") and verbs (such as\n\"talking\", \"touching\", or \"walking\"), for a total of 1705 distinct category\nlabels. To interpret our model, labels can be organized in a graph of semantic\nrelashionship based on the [Wordnet](https://wordnet.princeton.edu/) dataset.\n\n*Summary:* We first concatenate the features with multiple temporal delays to\naccount for the slow hemodynamic response. We then use linear regression to fit\na predictive model of brain activity. The linear regression is regularized to\nimprove robustness to correlated features and to improve generalization\nperformance. The optimal regularization hyperparameter is selected over a\ngrid-search with cross-validation. Finally, the model generalization\nperformance is evaluated on a held-out test set, comparing the model\npredictions to the corresponding ground-truth fMRI responses.\n"
1919
]
2020
},
2121
{
@@ -195,7 +195,7 @@
195195
"cell_type": "markdown",
196196
"metadata": {},
197197
"source": [
198-
"Finally, we use a ridge regression model. Ridge regression is a linear\nregression with L2 regularization. The L2 regularization improves robustness\nto correlated features and improves generalization performance. The L2\nregularization is controlled by a hyperparameter ``alpha`` that needs to be\ntuned for each dataset. This regularization hyperparameter is usually\nselected over a grid search with cross-validation, selecting the\nhyperparameter that maximizes the predictive performances on the validation\nset. See the previous example for more details about ridge regression and\nhyperparameter selection.\n\nFor computational reasons, when the number of features is larger than the\nnumber of samples, it is more efficient to solve ridge regression using the\n(equivalent) dual formulation [2]_. This dual formulation is equivalent to\nkernel ridge regression with a linear kernel. Here, we have 3600 training\nsamples, and 1705 * 4 = 6820 features (we multiply by 4 since we use 4 time\ndelays), therefore it is more efficient to use kernel ridge regression.\n\nWith one target, we could directly use the pipeline in ``scikit-learn``'s\n``GridSearchCV``, to select the optimal regularization hyperparameter\n(``alpha``) over cross-validation. However, ``GridSearchCV`` can only\noptimize a single score across all voxels (targets). Thus, in the\nmultiple-target case, ``GridSearchCV`` can only optimize (for example) the\nmean score over targets. Here, we want to find a different optimal\nhyperparameter per target/voxel, so we use the package `himalaya\n<https://github.com/gallantlab/himalaya>`_ which implements a\n``scikit-learn`` compatible estimator ``KernelRidgeCV``, with hyperparameter\nselection independently on each target.\n\n"
198+
"Finally, we use a ridge regression model. Ridge regression is a linear\nregression with L2 regularization. The L2 regularization improves robustness\nto correlated features and improves generalization performance. The L2\nregularization is controlled by a hyperparameter ``alpha`` that needs to be\ntuned for each dataset. This regularization hyperparameter is usually\nselected over a grid search with cross-validation, selecting the\nhyperparameter that maximizes the predictive performances on the validation\nset. See the previous example for more details about ridge regression and\nhyperparameter selection.\n\nFor computational reasons, when the number of features is larger than the\nnumber of samples, it is more efficient to solve ridge regression using the\n(equivalent) dual formulation [2]_. This dual formulation is equivalent to\nkernel ridge regression with a linear kernel. Here, we have 3600 training\nsamples, and 1705 * 4 = 6820 features (we multiply by 4 since we use 4 time\ndelays), therefore it is more efficient to use kernel ridge regression.\n\nWith one target, we could directly use the pipeline in ``scikit-learn``'s\n``GridSearchCV``, to select the optimal regularization hyperparameter\n(``alpha``) over cross-validation. However, ``GridSearchCV`` can only\noptimize a single score across all voxels (targets). Thus, in the\nmultiple-target case, ``GridSearchCV`` can only optimize (for example) the\nmean score over targets. Here, we want to find a different optimal\nhyperparameter per target/voxel, so we use the package [himalaya](https://github.com/gallantlab/himalaya) which implements a\n``scikit-learn`` compatible estimator ``KernelRidgeCV``, with hyperparameter\nselection independently on each target.\n\n"
199199
]
200200
},
201201
{
@@ -285,7 +285,7 @@
285285
"cell_type": "markdown",
286286
"metadata": {},
287287
"source": [
288-
"Finally, we use a ``scikit-learn`` ``Pipeline`` to link the different steps\ntogether. A ``Pipeline`` can be used as a regular estimator, calling\n``pipeline.fit``, ``pipeline.predict``, etc. Using a ``Pipeline`` can be\nuseful to clarify the different steps, avoid cross-validation mistakes, or\nautomatically cache intermediate results. See the ``scikit-learn``\n`documentation <https://scikit-learn.org/stable/modules/compose.html>`_ for\nmore information.\n\n"
288+
"Finally, we use a ``scikit-learn`` ``Pipeline`` to link the different steps\ntogether. A ``Pipeline`` can be used as a regular estimator, calling\n``pipeline.fit``, ``pipeline.predict``, etc. Using a ``Pipeline`` can be\nuseful to clarify the different steps, avoid cross-validation mistakes, or\nautomatically cache intermediate results. See the ``scikit-learn``\n[documentation](https://scikit-learn.org/stable/modules/compose.html) for\nmore information.\n\n"
289289
]
290290
},
291291
{
@@ -653,7 +653,7 @@
653653
"name": "python",
654654
"nbconvert_exporter": "python",
655655
"pygments_lexer": "ipython3",
656-
"version": "3.7.12"
656+
"version": "3.8.3"
657657
}
658658
},
659659
"nbformat": 4,

tutorials/notebooks/shortclips/04_plot_hemodynamic_response.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@
352352
"name": "python",
353353
"nbconvert_exporter": "python",
354354
"pygments_lexer": "ipython3",
355-
"version": "3.10.9"
355+
"version": "3.8.3"
356356
}
357357
},
358358
"nbformat": 4,

tutorials/notebooks/shortclips/05_plot_motion_energy_model.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@
341341
"name": "python",
342342
"nbconvert_exporter": "python",
343343
"pygments_lexer": "ipython3",
344-
"version": "3.7.12"
344+
"version": "3.8.3"
345345
}
346346
},
347347
"nbformat": 4,

tutorials/notebooks/shortclips/06_plot_banded_ridge_model.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"cell_type": "markdown",
1616
"metadata": {},
1717
"source": [
18-
"\n# Fit a banded ridge model with both wordnet and motion energy features\n\nIn this example, we model the fMRI responses with a `banded ridge regression`,\nwith two different feature spaces: motion energy and wordnet categories.\n\n*Banded ridge regression:* Since the relative scaling of both feature spaces is\nunknown, we use two regularization hyperparameters (one per feature space) in a\nmodel called banded ridge regression [1]_. Just like with ridge regression, we\noptimize the hyperparameters over cross-validation. An efficient implementation\nof this model is available in the `himalaya\n<https://github.com/gallantlab/himalaya>`_ package.\n\n*Running time:* This example is more computationally intensive than the\nprevious examples. With a GPU backend, model fitting takes around 6 minutes.\nWith a CPU backend, it can last 10 times more.\n"
18+
"\n# Fit a banded ridge model with both wordnet and motion energy features\n\nIn this example, we model the fMRI responses with a `banded ridge regression`,\nwith two different feature spaces: motion energy and wordnet categories.\n\n*Banded ridge regression:* Since the relative scaling of both feature spaces is\nunknown, we use two regularization hyperparameters (one per feature space) in a\nmodel called banded ridge regression [1]_. Just like with ridge regression, we\noptimize the hyperparameters over cross-validation. An efficient implementation\nof this model is available in the [himalaya](https://github.com/gallantlab/himalaya) package.\n\n*Running time:* This example is more computationally intensive than the\nprevious examples. With a GPU backend, model fitting takes around 6 minutes.\nWith a CPU backend, it can last 10 times more.\n"
1919
]
2020
},
2121
{
@@ -510,7 +510,7 @@
510510
"name": "python",
511511
"nbconvert_exporter": "python",
512512
"pygments_lexer": "ipython3",
513-
"version": "3.7.12"
513+
"version": "3.8.3"
514514
}
515515
},
516516
"nbformat": 4,

tutorials/notebooks/shortclips/07_extract_motion_energy.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
"name": "python",
137137
"nbconvert_exporter": "python",
138138
"pygments_lexer": "ipython3",
139-
"version": "3.10.9"
139+
"version": "3.8.3"
140140
}
141141
},
142142
"nbformat": 4,

tutorials/notebooks/shortclips/merged_for_colab.ipynb

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,8 +1333,7 @@
13331333
"hyperparameter selection. Thus, the process is called a *cross-validation*.\n",
13341334
"\n",
13351335
"Learn more about hyperparameter selection and cross-validation on the\n",
1336-
"`scikit-learn documentation\n",
1337-
"<https://scikit-learn.org/stable/modules/cross_validation.html>`_.\n",
1336+
"[scikit-learn documentation](https://scikit-learn.org/stable/modules/cross_validation.html).\n",
13381337
"\n"
13391338
]
13401339
},
@@ -1390,7 +1389,7 @@
13901389
"include nouns (such as \"woman\", \"car\", or \"building\") and verbs (such as\n",
13911390
"\"talking\", \"touching\", or \"walking\"), for a total of 1705 distinct category\n",
13921391
"labels. To interpret our model, labels can be organized in a graph of semantic\n",
1393-
"relashionship based on the `Wordnet <https://wordnet.princeton.edu/>`_ dataset.\n",
1392+
"relashionship based on the [Wordnet](https://wordnet.princeton.edu/) dataset.\n",
13941393
"\n",
13951394
"*Summary:* We first concatenate the features with multiple temporal delays to\n",
13961395
"account for the slow hemodynamic response. We then use linear regression to fit\n",
@@ -1688,8 +1687,7 @@
16881687
"optimize a single score across all voxels (targets). Thus, in the\n",
16891688
"multiple-target case, ``GridSearchCV`` can only optimize (for example) the\n",
16901689
"mean score over targets. Here, we want to find a different optimal\n",
1691-
"hyperparameter per target/voxel, so we use the package `himalaya\n",
1692-
"<https://github.com/gallantlab/himalaya>`_ which implements a\n",
1690+
"hyperparameter per target/voxel, so we use the package [himalaya](https://github.com/gallantlab/himalaya) which implements a\n",
16931691
"``scikit-learn`` compatible estimator ``KernelRidgeCV``, with hyperparameter\n",
16941692
"selection independently on each target.\n",
16951693
"\n"
@@ -1809,7 +1807,7 @@
18091807
"``pipeline.fit``, ``pipeline.predict``, etc. Using a ``Pipeline`` can be\n",
18101808
"useful to clarify the different steps, avoid cross-validation mistakes, or\n",
18111809
"automatically cache intermediate results. See the ``scikit-learn``\n",
1812-
"`documentation <https://scikit-learn.org/stable/modules/compose.html>`_ for\n",
1810+
"[documentation](https://scikit-learn.org/stable/modules/compose.html) for\n",
18131811
"more information.\n",
18141812
"\n"
18151813
]
@@ -3518,8 +3516,7 @@
35183516
"unknown, we use two regularization hyperparameters (one per feature space) in a\n",
35193517
"model called banded ridge regression [1]_. Just like with ridge regression, we\n",
35203518
"optimize the hyperparameters over cross-validation. An efficient implementation\n",
3521-
"of this model is available in the `himalaya\n",
3522-
"<https://github.com/gallantlab/himalaya>`_ package.\n",
3519+
"of this model is available in the [himalaya](https://github.com/gallantlab/himalaya) package.\n",
35233520
"\n",
35243521
"*Running time:* This example is more computationally intensive than the\n",
35253522
"previous examples. With a GPU backend, model fitting takes around 6 minutes.\n",
@@ -4287,7 +4284,7 @@
42874284
"name": "python",
42884285
"nbconvert_exporter": "python",
42894286
"pygments_lexer": "ipython3",
4290-
"version": "3.10.9"
4287+
"version": "3.8.3"
42914288
},
42924289
"name": "_merged"
42934290
},

0 commit comments

Comments
 (0)