Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/21081#discussion_r181840765
--- Diff:
mllib/src/test/scala/org/apache/spark/ml/clustering/KMeansSuite.scala ---
@@ -194,6 +195,34 @@ class KMeansSuite extends SparkFunSuite with
MLlibTestSparkContext with DefaultR
assert(e.getCause.getMessage.contains("Cosine distance is not
defined"))
}
+ test("KMean with Array input") {
+ val featuresColName = "array_model_features"
+
+ val arrayUDF = udf { (features: Vector) =>
+ features.toArray
+ }
+ val newdataset = dataset.withColumn(featuresColName,
arrayUDF(col("features")) )
+
+ val kmeans = new KMeans()
+ .setFeaturesCol(featuresColName)
+
+ assert(kmeans.getK === 2)
+ assert(kmeans.getFeaturesCol === featuresColName)
+ assert(kmeans.getPredictionCol === "prediction")
--- End diff --
No need to check this or the other Params which are not relevant to this
test
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]