Description
1 Image Labelling – Linear Classification
This assignment will give you a chance to familiarize yourself with Jupyter, scikit-learn and other
ML tools. You will use the CMU Image dataset which can be downloaded from the UCI Machine
learning repository at http://archive.ics.uci.edu/ml/datasets/cmu+face+images. You are
looking for an archive called faces.tar.gz. This archive contains black and white images of
20 different peoples in four different poses but with different expressions and with and without
sunglasses. Furthermore, each image is already stored in three different resolutions.
In this assignment, you will train binary and multiclass linear classifier available from scikitlearn.
1.1 Getting Started [3]
You should the python image library (PIL), or rather its active fork pillow. You will find a pgm
image loader and test code attached to this assignment. Note that the labels for the images are
encoded in the file names. (Some images have the ending bad, i.e., they cannot be used.)
• The person in the image is encoded with a user id at the start of the filename. It is also the
directory name.
• The head pose is the next word in the file name. The choices are: straight, left, right, and
up.
• The facial expression is the next word in the file name. The choices are: neutral, happy, sad,
and angry.
• The sunglass state of the person is encoded next. The choices are: open and sunglasses.
• Finally, the size of the image is indicated with a number. Full resolution is 128 × 120 and 1
2
and 1
4
in each dimension of the full resolution are provided. This is encoded with no number,
2 and 4, respectively.
You will need to load all images and organize them suitably into three different design matrices
A1, A2 and A4 and corresponding matrices target labels Y1, Y2 and Y4. Each of these dataset
split into corresponding 80/20 splits for training and testing. By corresponding, I mean that
A1train[i,:], A2train[i,:] and A4train[i,:] all refer to the same image except for resolution.
(Note you have to settle on a strategy for dealing with bad images).
1
1.2 Binary Classifier [3]
Use A4 to train a logistic regression classifier for the class sunglasses vs. open. Find and print the
confusion matrix, the accuracy, the recall and the precision of your classifier based on the training
data, as well as on the testing data. Print the ROC curve.
1.3 Multiclass Classifier [2]
Use A4 again to train a logistic regression classifier but this time to classify into multiple classes
for the pose: left, right, straight and up. Find and print the confusion matrix and the accuracy.
Discuss briefly how the classifier perform on this task, e.g., are there easier or more difficult classes,
do certain classes tend to be confused etc.
1.4 Expression Classifiction [2 + Bonus]
Train a multi-class classifier of your choice to distinguish faces by their expression. You are allowed
to use any resolution training data and you are challenged to get good results. Find and print
the confusion matrix and the accuracy again as a foundation for your discussion. Discuss how
this task is similar and different than the task in Section 1.3. Make sure you use markup in your
Jupyter notebook to clearly identify the steps in your approach.
2 Submission
You will need to submit your solution in a Jupyter file. Make you have run all the cells. All text
must be embedded in the Jupyter file, I will not look at separately submitted text files. If your
Jupyter file needs a local python file to run, please submit it as well. Assignment submission is
only though Virtual Campus by the deadline. No late submissions are allowed, you can submit
multiple times but only your last submission is kept and marked.
2