def whiten( trainingset, epsilon = 1e-5 ):
    training_data = np.array( [instance.features for instance in trainingset ] )
    
    def encoder(dataset):
        manipulated_dataset = copy.deepcopy( dataset )
        for instance in manipulated_dataset:
            instance.features = np.dot(instance.features, W)
        return manipulated_dataset
    #end
    
    covariance = np.dot(training_data.T, training_data)
    d, V = np.linalg.eig( covariance )
    
    D = np.diag(np.sqrt(d+epsilon) / 1.)
    
    W = np.dot(np.dot(V, D), V.T)
    
    return encoder
#end
dataset/ETHPy150Open jorgenkg/python-neural-network/src/preprocessing.py/whiten/swapped operands of `/`