Confusion matrix and recall/precision rates implementation

Not written by Tom.