def __euclidean_distance(self, X): X = R.expand_dims(X, axis=1, name="expand_dims") return R.square_root(R.sub(X, self._X).pow(Scalar(2)).sum(axis=2))
def closest_centroids(self, centroids): centroids = R.expand_dims(centroids, axis=1) return R.argmin( square_root( R.sub(self.points, centroids).pow(Scalar(2)).sum(axis=2)))
def closest_centroids(self, points, centroids): centroids = R.expand_dims(centroids, axis=1) return R.argmin( R.square_root(R.sum(R.square(R.sub(points, centroids)), axis=2)))
def __eucledian_distance(self, X): X = R.expand_dims(X, axis=1, name="expand_dims") return R.square_root( R.sub(X, self.X_train).pow(R.Scalar(2)).sum(axis=2))