This repository contains a brief introduction to Python for pattern recognition. The tutorial is designed to provide tools and help students of pattern recognition module (EE468/EE9SO29/EE9CS729, EEE dept. at Imperial College London) to complete their coursework. It's not an exhaustive tutorial on Python and it's tailored for this course, complementing the theory lectures.
This tutorial covers:
- Basic Python: Some basic data structures, loops and functions.
- Numpy: arrays, array indexing, datatypes, array math, broadcasting.
- Linear algebra with Numpy: basic operations, determinants, inverses, eigenvalues and eigenvectors.
- Data visualisation: plotting, subplots, images, confusion matrix
- Images: loading and manipulating face data for coursework 1, intro to opencv (optional)
- SVM: an example of using super vector machines with scikit.
The tutorial runs on Jupyter Notebook:
The Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations and narrative text. Uses include: data cleaning and transformation, numerical simulation, statistical modeling, data visualization, machine learning, and much more.
Why Jupyter Notebook?
Simply put, it's a great way to share Python code for scientific computing. Check out this Nature article or this introduction for a bit of history.
If you submit your code on your coursework 1 report feel free to use any format, including notebook .ipynb
, standard Python py
format and Matlab. For coursework 2 please read the instructions on the coursework 2 guidelines.
Here in GitHub you can visualise the tutorial, however you can't run the code. To run the code, you need to open the notebooks either in your local machine or in a remote machine. We recommend using the remote machine because you won't have to install/configure anything. In the following we briefly introduce these two options:
You can use any cloud computing service that you like (e.g. Google Colab, Microsoft Azure, etc.). Google Colab requires a Google account, while Microsoft Azure can be accessed with your Imperial account thanks to an agreement between the college and Microsoft. Instructions to run the tutorial on Azure are as follows:
- Go to the service website.
- Sign in with your Imperial account (
[email protected]
). - Follow the steps to set your account.
- Go to
My projects > Upload GitHub Repo
. Introduce this GitHub repo linkguiggh/pr-python-tutorial
. This will clone this repository to your Azure space. - Open the notebook of your choice (you can start with 1_intro.ipynb) and start playing!
- Install Jupyter Notebook on your computer. Note: you need to have an installation of Python and a package manager. We recommend using Python 3 with Anaconda.
- Download or clone this repository on your computer.
- Run
jupyter notebook
and navigate to the folder. - Open the notebook of your choice (you can start with 1_intro.ipynb) and start playing!
You can think of a notebook as a document organised in cells that can contain formatted text and run code. We believe the best way to learn how it works is just playing with them. Open one notebook and press the run
button to start running cells. Run one cell with code, see the output, change the code re-run again... If you are still lost, ask any of the GTAs during the tutorial session or check online resources.
Jupyter Notebook is a way to present and run interactive Python code with additional features such as adding formatted text to the code source files. If you aren't interested in using the notebook you can still follow the tutorial and run the Python code parts in your favourite way.
This tutorial is inspired (and borrows some parts) by the tutorial by Kuleshov and Caswell, which is an adaptation of Johnson's tutorial.