Cached Sufficient Statistics for Efficient Machine Learning with Large Datasets