You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@systemds.apache.org by ja...@apache.org on 2020/07/08 19:15:09 UTC
[systemds] branch master updated: [DOC][2/2] Builtin KMeans
function example added
This is an automated email from the ASF dual-hosted git repository.
janardhan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/systemds.git
The following commit(s) were added to refs/heads/master by this push:
new 7cdb51d [DOC][2/2] Builtin KMeans function example added
7cdb51d is described below
commit 7cdb51d18ee1a9d7a957f366a71d04ca818bdf91
Author: Janardhan Pulivarthi <j1...@protonmail.com>
AuthorDate: Thu Jun 4 10:18:34 2020 +0530
[DOC][2/2] Builtin KMeans function example added
* Example to invoke KMeans function
* Update the KMeans default number of centroids in dml script.
Closes #947.
---
docs/site/builtins-reference.md | 5 +++++
scripts/builtin/kmeans.dml | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/docs/site/builtins-reference.md b/docs/site/builtins-reference.md
index 812245d..c96e5d7 100644
--- a/docs/site/builtins-reference.md
+++ b/docs/site/builtins-reference.md
@@ -435,6 +435,11 @@ kmeans(X = X, k = 20, runs = 10, max_iter = 5000, eps = 0.000001, is_verbose = F
| String | The mapping of records to centroids |
| String | The output matrix with the centroids |
+### Example
+```r
+X = rand (rows = 3972, cols = 972)
+kmeans(X = X, k = 20, runs = 10, max_iter = 5000, eps = 0.000001, is_verbose = FALSE, avg_sample_size_per_centroid = 50)
+```
## `lm`-Function
diff --git a/scripts/builtin/kmeans.dml b/scripts/builtin/kmeans.dml
index 75e5bc7..6a4d249 100644
--- a/scripts/builtin/kmeans.dml
+++ b/scripts/builtin/kmeans.dml
@@ -43,7 +43,7 @@
# ----------------------------------------------------------------------------
-m_kmeans = function(Matrix[Double] X, Integer k = 0, Integer runs = 10, Integer max_iter = 1000,
+m_kmeans = function(Matrix[Double] X, Integer k = 10, Integer runs = 10, Integer max_iter = 1000,
Double eps = 0.000001, Boolean is_verbose = FALSE, Integer avg_sample_size_per_centroid = 50)
return (Matrix[Double] C, Matrix[Double] Y)
{