From 4eb1727fadb05eff8ba94bd067693b4b25f141d4 Mon Sep 17 00:00:00 2001 From: yoshoku Date: Wed, 20 Dec 2023 21:16:58 +0900 Subject: [PATCH] fix: change position where x is copied to y --- rumale-core/lib/rumale/pairwise_metric.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rumale-core/lib/rumale/pairwise_metric.rb b/rumale-core/lib/rumale/pairwise_metric.rb index 261e8f36..42d5b5a0 100644 --- a/rumale-core/lib/rumale/pairwise_metric.rb +++ b/rumale-core/lib/rumale/pairwise_metric.rb @@ -38,9 +38,9 @@ def manhattan_distance(x, y = nil) # @param y [Numo::DFloat] (shape: [n_samples_y, n_features]) # @return [Numo::DFloat] (shape: [n_samples_x, n_samples_x] or [n_samples_x, n_samples_y] if y is given) def squared_error(x, y = nil) - y = x if y.nil? sum_x_vec = (x**2).sum(axis: 1).expand_dims(1) sum_y_vec = y.nil? ? sum_x_vec.transpose : (y**2).sum(axis: 1).expand_dims(1).transpose + y = x if y.nil? err_mat = -2 * x.dot(y.transpose) err_mat += sum_x_vec err_mat += sum_y_vec