int localItems = 0;
for (Tuple<DoubleVector, DoubleVector> tuple : dataStream) {
localItems++;
DoubleVector feature = tuple.getFirst();
DoubleVector outcome = tuple.getSecond();
DoubleVector z1 = theta.multiplyVectorColumn(feature);
DoubleVector activations = SIGMOID.apply(z1);
double loss = LOSS.calculateError(
new SparseDoubleRowMatrix(Arrays.asList(outcome)),
new SparseDoubleRowMatrix(Arrays.asList(activations)));
lossSum += loss;