som/som.py
def topology_error(self, test_vectors):
        """Calculates the topology error, a simple topology preservation
        measure. It calculates for a test_vector or multiple test_vectors
        whether the bmu and the second bmu are neighbouring nodes.
        """
        if not isinstance(test_vectors, collections.Iterable):
            test_vectors = [test_vectors]

        def are_bmus_neighbours(test_vector):
            bmu = self.bmu(test_vector)
            nodes_wo_bmu = (node for node in self.codebook if node is not bmu)
            bmu2 = min(nodes_wo_bmu, key=lambda x: x.distance_sq(test_vector))
            return self.codebook.are_neighbours(bmu, bmu2)

        return (sum(not(are_bmus_neighbours(vec)) for vec in test_vectors) /
                len(test_vectors))
Calculates the topology error, a simple topology preservation
        measure. It calculates for a test_vector or multiple test_vectors
        whether the bmu and the second bmu are neighbouring nodes.
        
Calculates the topology error, a simple topology preservation
measure. It calculates for a test_vector or multiple test_vectors
whether the bmu and the second bmu are neighbouring nodes.
Calculates the topology error a simple topology preservation measure . It calculates for a test_vector or multiple test_vectors whether the bmu and the second bmu are neighbouring nodes .
def topology_error(self, test_vectors):
        if not isinstance(test_vectors, collections.Iterable):
            test_vectors = [test_vectors]
        def are_bmus_neighbours(test_vector):
            bmu = self.bmu(test_vector)
            nodes_wo_bmu = (node for node in self.codebook if node is not bmu)
            bmu2 = min(nodes_wo_bmu, key=lambda x: x.distance_sq(test_vector))
            return self.codebook.are_neighbours(bmu, bmu2)
        return (sum(not(are_bmus_neighbours(vec)) for vec in test_vectors) /
                len(test_vectors))
def topology_error ( self , test_vectors ) : if not isinstance ( test_vectors , collections . Iterable ) : test_vectors = [ test_vectors ] def are_bmus_neighbours ( test_vector ) : bmu = self . bmu ( test_vector ) nodes_wo_bmu = ( node for node in self . codebook if node is not bmu ) bmu2 = min ( nodes_wo_bmu , key = lambda x : x . distance_sq ( test_vector ) ) return self . codebook . are_neighbours ( bmu , bmu2 ) return ( sum ( not ( are_bmus_neighbours ( vec ) ) for vec in test_vectors ) / len ( test_vectors ) )
Calculates the topology error, a simple topology preservation
measure.
Calculates the topology error a simple topology preservation measure .
"""Calculates the topology error, a simple topology preservation
        measure. It calculates for a test_vector or multiple test_vectors
        whether the bmu and the second bmu are neighbouring nodes.
        """
self
test_vectors