Github user srowen commented on a diff in the pull request:
https://github.com/apache/spark/pull/6737#discussion_r32189568
--- Diff:
mllib/src/main/scala/org/apache/spark/mllib/clustering/KMeans.scala ---
@@ -156,6 +156,26 @@ class KMeans private (
this
}
+ // Initial cluster centers can be provided as a KMeansModel object
rather than using the
+ // random or k-means|| initializationMode
+ private var initialModel: Option[KMeansModel] = None
+
+ /** Set the initial starting point, bypassing the random initialization
or k-means||
+ * The condition (model.k == this.k) must be met; failure will result
in an
+ * IllegalArgumentException.
+ */
+ def setInitialModel(model: KMeansModel): this.type = {
+ if (model.k == k) {
+ initialModel = Some(model)
+ } else {
+ throw new IllegalArgumentException("mismatched cluster count
(model.k != k)")
+ }
+ this
+ }
+
+ /** Return the user supplied initial KMeansModel, if supplied */
+ def getInitialModel: Option[KMeansModel] = initialModel
--- End diff --
Yes that was my intent. I don't know if there's a particular reason it
needs to be exposed.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]