algorithms/k-means/algorithms.py
def update_centers(this):
        """
        Choose a new center for each cluster.
        :return: None.
        """
        # FIXME: sometimes, a cluster does not contain any point. Hence, the call to _average will result in an error.
        for i in range(this.k):
            if this.clusters[i] == []:
                for e in this.data:
                    break
                this.centers[i] = this.random_point(len(e))
            else:
                this.centers[i] = this._average(this.clusters[i], this.data_type)

        Choose a new center for each cluster.
        :return: None.
        
Choose a new center for each cluster.
Choose a new center for each cluster .
def update_centers(this):
        for i in range(this.k):
            if this.clusters[i] == []:
                for e in this.data:
                    break
                this.centers[i] = this.random_point(len(e))
            else:
                this.centers[i] = this._average(this.clusters[i], this.data_type)
def update_centers ( this ) : for i in range ( this . k ) : if this . clusters [ i ] == [ ] : for e in this . data : break this . centers [ i ] = this . random_point ( len ( e ) ) else : this . centers [ i ] = this . _average ( this . clusters [ i ] , this . data_type )
Choose a new center for each cluster.
Choose a new center for each cluster .
"""
        Choose a new center for each cluster.
        :return: None.
        """ # FIXME: sometimes, a cluster does not contain any point. Hence, the call to _average will result in an error.
None
this