Computer Science 242

Homework 5

You are asked to implement training for logistic regression, and to train and evaluate on the adult income dataset in /u/cs242/hw5. This homework should be done individually, and is due by TURN_IN script Fri April 26 at 5pm. You should:
  • implement the algorithm in the logistic regression notes, not Russell and Norvig chapter 19.
  • experiment with different learning rates.
  • plot a learning curve of updates vs accuracy on test data. You can use any tools you like to produce a pdf, which should be included in your turn in directory.
  • discuss whether you see evidence of overfitting.
  • code your own dot product and sigmoid (logistic) functions.

Optional: implement randomized selection of training examples, and measure the variance in the learning curve over different runs with different random selections.

Optional: implement the version of logistic regression in Russell and Norvig chapter 19, and compare in terms of performance and speed of training.

Recommended user interface: accept learning rate, number of iterations, train and test file names on command line, print one line per iteration (iteration means one pass through training data) with train accuracy and cross entropy, and test accuracy and cross entropy.

% ./logistic.py --lr 0.1 --iterations 10 /u/cs242/hw5/a7a.train /u/cs242/hw5/data/a7a.test 
TRAIN accuracy 0.XXX xent 0.XXX   TEST accuracy 0.XXX xent 0.XXX
TRAIN accuracy 0.XXX xent 0.XXX   TEST accuracy 0.XXX xent 0.XXX
TRAIN accuracy 0.XXX xent 0.XXX   TEST accuracy 0.XXX xent 0.XXX
TRAIN accuracy 0.XXX xent 0.XXX   TEST accuracy 0.XXX xent 0.XXX
TRAIN accuracy 0.XXX xent 0.XXX   TEST accuracy 0.XXX xent 0.XXX
TRAIN accuracy 0.XXX xent 0.XXX   TEST accuracy 0.XXX xent 0.XXX
TRAIN accuracy 0.XXX xent 0.XXX   TEST accuracy 0.XXX xent 0.XXX
TRAIN accuracy 0.XXX xent 0.XXX   TEST accuracy 0.XXX xent 0.XXX
TRAIN accuracy 0.XXX xent 0.XXX   TEST accuracy 0.XXX xent 0.XXX
TRAIN accuracy 0.XXX xent 0.XXX   TEST accuracy 0.XXX xent 0.XXX