Regression code using only nonzero training examples