def normalize( trainingset ):
    """
    Morph the input signal to a mean of 0 and scale the signal strength by 
    dividing with the standard deviation (rather that forcing a [0, 1] range)
    """
    
    def encoder( dataset ):
        for instance in dataset:
            if np.any(stds == 0):
                nonzero_indexes = np.where(stds!=0)
                instance.features[nonzero_indexes] = instance.features[nonzero_indexes] / stds[nonzero_indexes]
            else:
                instance.features = instance.features / stds
        return dataset
    #end
    
    training_data = np.array( [instance.features for instance in trainingset ] )
    stds = training_data.std(axis=0)
    
    return encoder
def normalize ( trainingset ) : def encoder ( dataset ) : for instance in dataset : if np . any ( stds == 0 ) : nonzero_indexes = np . where ( stds != 0 ) instance . features [ nonzero_indexes ] = instance . features [ nonzero_indexes ] / stds [ nonzero_indexes ] else : instance . features = instance . features / stds return dataset training_data = np . array ( [ instance . features for instance in trainingset ] ) stds = training_data . std ( axis = 0 ) return encoder
Morph the input signal to a mean of 0 and scale the signal strength by 
    dividing with the standard deviation (rather that forcing a [0, 1] range)