algorithms/k-means/algorithms.py
def remember_best_result(this):
        """
        Stores the best result so far
        """

        totalDistance = 0

        for cluster in range(len(this.clusters)):
            for point in this.clusters[i]:
                totalDistance += this.distances[point][i]

        # If this is the best result so far (or the 1st) we remember it
        if totalDistance < this.distMin or this.distMin == 0:
            this.centers_best = this.centers
            this.clusters_best = this.clusters
            this.distMin = totalDistance

        Stores the best result so far
        
Stores the best result so far
Stores the best result so far
def remember_best_result(this):
        totalDistance = 0
        for cluster in range(len(this.clusters)):
            for point in this.clusters[i]:
                totalDistance += this.distances[point][i]
        if totalDistance < this.distMin or this.distMin == 0:
            this.centers_best = this.centers
            this.clusters_best = this.clusters
            this.distMin = totalDistance
def remember_best_result ( this ) : totalDistance = 0 for cluster in range ( len ( this . clusters ) ) : for point in this . clusters [ i ] : totalDistance += this . distances [ point ] [ i ] if totalDistance < this . distMin or this . distMin == 0 : this . centers_best = this . centers this . clusters_best = this . clusters this . distMin = totalDistance
Stores the best result so far
Stores the best result so far
"""
        Stores the best result so far
        """ # If this is the best result so far (or the 1st) we remember it
this