This repository contains written instructions, links to code, and data used for the (virtual) Machine Learning/Normative Modeling Practical at the Computational Psychiatry Course on September 17th, 2022.
This repository is a group effort by Saige Rutherford and Thomas Wolfers.
We will be running all of our code in Google Colab python notebooks. These are essentially Jupyter notebooks run in the ☁️ cloud ☁️. Running our code using Colab will save us from dealing with python library installation and virtual environment setup. It also ensures that we are all working on the same operating system which makes troubleshooting much easier (since there are only 2 instructors and lots of students)!
If you have never used Google Colab before, you can check out an introduction notebook with lots of helpful links here:
We will also be using the Pandas library for a lot of our code. There is a great intro to Pandas Colab notebook here:
Other helpful pandas:panda_face:/plotting:bar_chart: links (not required to do during the practial, just added for those who might need extra python help):
You can open the python notebook that we will use in this practical directly from this Github account (the links to the notebook are at the bottom of this Read Me file). Before you open the notebook, make sure you are logged into a Google account. All of the code has been tested using Google Chrome web browser. When you are ready to begin, you will click on the template Google Colab button below. This will launch a new browser tab with the Google Colab notebook.
Once you are in the Colab notebook tab, in the top right corner you will see a Connect
(or Reconnect
) button. Click on this, and a dropdown menu will appear as shown below. Click on Connect to hosted runtime
this will allow you to run the notebook using Google’s cloud resources, which are likely much faster than your computer. If you would prefer to use your own computer’s resources (this is not recommended and instructors will not be able to help you troubleshoot if you are not running the notebook in the cloud), select Connect to local runtime
.
Reconnect
instead of Connect
. You will also need to re-run all code blocks.
➡️ If you are using the Google cloud hosted option: in the upper left corner, you will see a button called Runtime
. Click on Runtime
, and another dropdown panel will appear (as shown below). Click on Change runtime type
.
➡️ This box will open, and you can click the GPU
option, then click save
.
➡️ In the same menu you used to change the runtime, there are several other optional things you can explore that may make your interacting with the notebook easier. Under ‘Tools’ there is a ‘Settings’ tab, which you can use to change the theme to light or dark mode using the ‘Site’ sub-tab. Then under the ‘Miscellaneous’ sub-tab, you can select Corgi or Kitty mode, and this will make cute animals walk across the top of your screen. There is no practical utility to this whatsoever, and it is for the sole purpose that cute animals spark joy.
➡️ Also under the ‘Tools’ tab, there is an option to look at Keyboard shortcuts. You don’t need to change any of these, but you can review some of them if you want to learn about speeding up your coding practice.
➡️ In the Colab python notebook, there are 2 types of cells: text cells & code cells
. The text cells have plain text in them, that the notebook will not interpret as code. These are the cells that contain the background story & task instructions. The code
cells have a code cell
, you can either click on the play button
Before clicking on the colab button below, make sure you are logged into a google account and using Chrome or Firefox internet browser (hopefully a current version)
Task 1: Fitting normative models from scratch
Task 2: Applying pre-trained normative models
Task 3: Interpreting and visualizing the outputs of normative models
Task 4: Using the outputs (Z-scores) as features in predictive model