This is an automated email from the ASF dual-hosted git repository.
mboehm7 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/systemds.git
The following commit(s) were added to refs/heads/main by this push:
new f1afbf46db [MINOR] Fix and simplification kmeans-predict builtin
function
f1afbf46db is described below
commit f1afbf46db890c1475f9032981946c7351a4744e
Author: Matthias Boehm <[email protected]>
AuthorDate: Fri Mar 15 13:37:06 2024 +0100
[MINOR] Fix and simplification kmeans-predict builtin function
This patch fixes the very convoluted computation of cluster
assignments. For equal splits among clusters, we now use the last
whereas before the first was used.
---
scripts/builtin/kmeansPredict.dml | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/scripts/builtin/kmeansPredict.dml
b/scripts/builtin/kmeansPredict.dml
index 29dc395b80..b619311896 100644
--- a/scripts/builtin/kmeansPredict.dml
+++ b/scripts/builtin/kmeansPredict.dml
@@ -35,11 +35,8 @@
m_kmeansPredict = function(Matrix[Double] X, Matrix[Double] C)
return (Matrix[Double] Y)
{
-
- D = -2 * (X %*% t(C)) + t(rowSums (C ^ 2));
- P = (D <= rowMins (D));
- aggr_P = t(cumsum (t(P)));
- Y = rowSums (aggr_P == 0) + 1
-
+ D = -2 * (X %*% t(C)) + t(rowSums(C^2));
+ P = (D <= rowMins (D));
+ Y = rowIndexMax(P);
}