CS211 Spring 2020
Programming Assignment II
This assignment is designed to give you more experience programming in C and using the Unix
environment. Your task will be to write one program that implements a simple machine-learning
algorithm. This will require file I/O, dynamic memory allocation, and correctly implementing an
moderately complex algorithm.
Machine learning (ML) techniques are increasingly used to provide services, such as face recognition in photographs, spelling correction, automated translation, and predicting what YouTube
videos you might want to watch next. Implementing a full ML algorithm is beyond the scope of this
course, so you will implement a “one shot” learning algorithm that uses historical data to predict
house prices based on particular attributes.
For example, a house might have x1 bedrooms, x2 bathrooms, x3 square footage, and be built in
year x4. If we had appropriate weights, we could estimate the price of the house y with the formula
y = w0 + w1x1 + w2x2 + w3x3 + w4x4.
The goal of one-shot learning is to find values for the weights wi using a large provided set
of training data. Once those weights have been found, they can be used to estimate prices for
For example, if the training data includes n houses and has k attributes, this data can be
represented as an n × (k + 1) matrix X, of the form
where each row corresponds to a house and each column corresponds to an attribute. Note that the first column contains 1 for all rows: this corresponds to the weight w0.
Similarly, house prices can be represented as an n × 1 matrix Y , of the form