src/core/preprocess/Normalizer.java
public void zScoreSamples(HashMap<Integer, MMatrix> data, boolean adjust, HashSet<Integer> normalizableRows) throws NeuralNetworkException {
        if (data.size() == 0) return;
        if (!adjustedZScore && !adjust) throw new NeuralNetworkException("Normalizer is not adjusted");
        if (adjust) {
            zScoreRows.clear();
            means.clear();
            standardDeviations.clear();
            int dataRows = data.values().toArray(new MMatrix[0])[0].get(0).getRows();
            if (normalizableRows == null || normalizableRows.isEmpty()) for (int row = 0; row < dataRows; row++) zScoreRows.add(row);
            else for (Integer row : normalizableRows) if (row >= 0 && row < dataRows) zScoreRows.add(row);
        }
        for (Integer row : zScoreRows) {
            if (adjust) {
                means.put(row, (double)0);
                for (Integer entry : data.keySet()) {
                    for (Integer depth : data.get(entry).keySet()) {
                        means.put(row, means.get(row) + data.get(entry).get(depth).getValue(row, 0));
                    }
                }
                means.put(row, means.get(row) / (double)data.size());

                standardDeviations.put(row, (double)0);
                for (Integer entry : data.keySet()) {
                    for (Integer depth : data.get(entry).keySet()) {
                        standardDeviations.put(row, standardDeviations.get(row) + Math.pow(data.get(entry).get(depth).getValue(row, 0) - means.get(row), 2));
                    }
                }
                standardDeviations.put(row, standardDeviations.get(row) > 0 ? Math.sqrt(standardDeviations.get(row) / ((double)data.size() - 1)) : 0);

                adjustedZScore = true;
            }
            if (standardDeviations.get(row) != 0) {
                for (Integer entry : data.keySet()) {
                    for (Integer depth : data.get(entry).keySet()) {
                        double newValue = (data.get(entry).get(depth).getValue(row, 0) - means.get(row)) / standardDeviations.get(row);
                        data.get(entry).get(depth).setValue(row, 0, newValue);
                    }
                }
            }
        }
    }
/**
     * Executes z- score normalization.<br>
     * Can either adjust normalizer or use earlier adjustment. This is useful if training data and test data must be adjusted by same normalization setting.<br>
     *
     * @param data data to be normalized.
     * @param adjust true if normalizer is adjusted with current data otherwise earlier normalization setting is applied.
     * @param normalizableRows rows to be normalized.
     * @throws NeuralNetworkException throws exception if normalizer is not yet adjusted.
     */
Executes z- score normalization.
Can either adjust normalizer or use earlier adjustment. This is useful if training data and test data must be adjusted by same normalization setting.

@param data data to be normalized.
@param adjust true if normalizer is adjusted with current data otherwise earlier normalization setting is applied.
@param normalizableRows rows to be normalized.
@throws NeuralNetworkException throws exception if normalizer is not yet adjusted.
Executes z - score normalization . Can either adjust normalizer or use earlier adjustment . This is useful if training data and test data must be adjusted by same normalization setting . @param data data to be normalized . @param adjust true if normalizer is adjusted with current data otherwise earlier normalization setting is applied . @param normalizableRows rows to be normalized . @throws NeuralNetworkException throws exception if normalizer is not yet adjusted .
public void zScoreSamples(HashMap<Integer, MMatrix> data, boolean adjust, HashSet<Integer> normalizableRows) throws NeuralNetworkException {
        if (data.size() == 0) return;
        if (!adjustedZScore && !adjust) throw new NeuralNetworkException("Normalizer is not adjusted");
        if (adjust) {
            zScoreRows.clear();
            means.clear();
            standardDeviations.clear();
            int dataRows = data.values().toArray(new MMatrix[0])[0].get(0).getRows();
            if (normalizableRows == null || normalizableRows.isEmpty()) for (int row = 0; row < dataRows; row++) zScoreRows.add(row);
            else for (Integer row : normalizableRows) if (row >= 0 && row < dataRows) zScoreRows.add(row);
        }
        for (Integer row : zScoreRows) {
            if (adjust) {
                means.put(row, (double)0);
                for (Integer entry : data.keySet()) {
                    for (Integer depth : data.get(entry).keySet()) {
                        means.put(row, means.get(row) + data.get(entry).get(depth).getValue(row, 0));
                    }
                }
                means.put(row, means.get(row) / (double)data.size());
                standardDeviations.put(row, (double)0);
                for (Integer entry : data.keySet()) {
                    for (Integer depth : data.get(entry).keySet()) {
                        standardDeviations.put(row, standardDeviations.get(row) + Math.pow(data.get(entry).get(depth).getValue(row, 0) - means.get(row), 2));
                    }
                }
                standardDeviations.put(row, standardDeviations.get(row) > 0 ? Math.sqrt(standardDeviations.get(row) / ((double)data.size() - 1)) : 0);
                adjustedZScore = true;
            }
            if (standardDeviations.get(row) != 0) {
                for (Integer entry : data.keySet()) {
                    for (Integer depth : data.get(entry).keySet()) {
                        double newValue = (data.get(entry).get(depth).getValue(row, 0) - means.get(row)) / standardDeviations.get(row);
                        data.get(entry).get(depth).setValue(row, 0, newValue);
                    }
                }
            }
        }
    }
public void zScoreSamples ( HashMap < Integer , MMatrix > data , boolean adjust , HashSet < Integer > normalizableRows ) throws NeuralNetworkException { if ( data . size ( ) == 0 ) return ; if ( ! adjustedZScore && ! adjust ) throw new NeuralNetworkException ( "Normalizer is not adjusted" ) ; if ( adjust ) { zScoreRows . clear ( ) ; means . clear ( ) ; standardDeviations . clear ( ) ; int dataRows = data . values ( ) . toArray ( new MMatrix [ 0 ] ) [ 0 ] . get ( 0 ) . getRows ( ) ; if ( normalizableRows == null || normalizableRows . isEmpty ( ) ) for ( int row = 0 ; row < dataRows ; row ++ ) zScoreRows . add ( row ) ; else for ( Integer row : normalizableRows ) if ( row >= 0 && row < dataRows ) zScoreRows . add ( row ) ; } for ( Integer row : zScoreRows ) { if ( adjust ) { means . put ( row , ( double ) 0 ) ; for ( Integer entry : data . keySet ( ) ) { for ( Integer depth : data . get ( entry ) . keySet ( ) ) { means . put ( row , means . get ( row ) + data . get ( entry ) . get ( depth ) . getValue ( row , 0 ) ) ; } } means . put ( row , means . get ( row ) / ( double ) data . size ( ) ) ; standardDeviations . put ( row , ( double ) 0 ) ; for ( Integer entry : data . keySet ( ) ) { for ( Integer depth : data . get ( entry ) . keySet ( ) ) { standardDeviations . put ( row , standardDeviations . get ( row ) + Math . pow ( data . get ( entry ) . get ( depth ) . getValue ( row , 0 ) - means . get ( row ) , 2 ) ) ; } } standardDeviations . put ( row , standardDeviations . get ( row ) > 0 ? Math . sqrt ( standardDeviations . get ( row ) / ( ( double ) data . size ( ) - 1 ) ) : 0 ) ; adjustedZScore = true ; } if ( standardDeviations . get ( row ) != 0 ) { for ( Integer entry : data . keySet ( ) ) { for ( Integer depth : data . get ( entry ) . keySet ( ) ) { double newValue = ( data . get ( entry ) . get ( depth ) . getValue ( row , 0 ) - means . get ( row ) ) / standardDeviations . get ( row ) ; data . get ( entry ) . get ( depth ) . setValue ( row , 0 , newValue ) ; } } } } }
Executes z- score normalization.<br>
 Can either adjust normalizer or use earlier adjustment.
Executes z - score normalization . <br > Can either adjust normalizer or use earlier adjustment .