Skip to content

Code & Data for Computational Psychiatry Course Tutorial on Machine Learning

Notifications You must be signed in to change notification settings

saigerutherford/CPC_ML_tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Machine Learning with Normative Modeling Tutorial

Computational Psychiatry Course 2022

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: Open In Colab

We will also be using the Pandas library for a lot of our code. There is a great intro to Pandas Colab notebook here: Open In Colab

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):

  1. Pandas cheatsheet
  2. Pandas Selecting/Indexing API

⚠️ Setup instructions for Google Colab ⚠️

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.

⚠️ Note: sometimes if the notebook is left running for a long time without any activity (i.e. your computer goes to sleep), you will be disconnected from the runtime. In that case, you will need to click on this same button. It will appear as 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 ▶️ play button on the left side. These are the cells that the notebook will run as code. To run a code cell, you can either click on the play button ▶️ on the left side or use ‘Shift + Enter’ (your cursor must be inside the code cell).

Now you are ready to begin coding 🧠 💻!

Good luck 🍀 and remember to have fun 😃!

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 Open In Colab

Task 2: Applying pre-trained normative models Open In Colab

Task 3: Interpreting and visualizing the outputs of normative models Open In Colab

Task 4: Using the outputs (Z-scores) as features in predictive model Open In Colab

About

Code & Data for Computational Psychiatry Course Tutorial on Machine Learning

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published