def _calc_distortion(self):
        """Calculates the distortion value of the current clusters
        """
        m = self._X.shape[0]
        self.distortion = 1/m * sum(
            linalg.norm(self._X[i, :] - self.centroids[self.clusters[i]])**2 for i in range(m)
        )
        return self.distortion
def _calc_distortion ( self ) : m = self . _X . shape [ 0 ] self . distortion = 1 / m * sum ( linalg . norm ( self . _X [ i , : ] - self . centroids [ self . clusters [ i ] ] ) ** 2 for i in range ( m ) ) return self . distortion
Calculates the distortion value of the current clusters