### Question:
ZeroMeanNormalizer implements Normalizer { public void normalize(DataSet dataSet) { double[] maxInput = DataSetStatistics.calculateMaxByColumns(dataSet); double[] minInput = DataSetStatistics.calculateMinByColumns(dataSet); double[] meanInput = DataSetStatistics.calculateMean(dataSet); for (DataSetRow row : dataSet.getRows()) { double[] normalizedInput = row.getInput(); for (int i = 0; i < dataSet.getInputSize(); i++) { double divider = maxInput[i] - minInput[i] == 0 ? 1 : maxInput[i] - minInput[i] ; normalizedInput[i] = (normalizedInput[i] - meanInput[i]) / divider; } row.setInput(normalizedInput); } }  void normalize(DataSet dataSet);  }### Answer:
@Test public void testOneRowWithManyElementsNormalization() { double[] inputRow1 = new double[] { 0, 2, 3, 4 }; DataSetRow row1 = createDataRow(inputRow1); DataSet dataSet = createDataSetFromRows(row1); normalizer.normalize(dataSet); double[] columnMeans = DataSetStatistics.calculateMean(dataSet); for (int i = 0; i < dataSet.getInputSize(); i++) { double currentColumnMean = columnMeans[i]; assertEquals(0.0, currentColumnMean, 0.01); } }
@Test public void testTwoRowsWithOneElementNormalization() { double[] inputRow1 = new double[] { 2 }; double[] inputRow2 = new double[] { 4 }; DataSetRow row1 = createDataRow(inputRow1); DataSetRow row2 = createDataRow(inputRow2); DataSet dataSet = createDataSetFromRows(row1, row2); normalizer.normalize(dataSet); double[] columnMeans = DataSetStatistics.calculateMean(dataSet); for (int i = 0; i < dataSet.getInputSize(); i++) { double currentColumnMean = columnMeans[i]; assertEquals(0.0, currentColumnMean, 0.01); } }