Github user yanboliang commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19676#discussion_r155913190
  
    --- Diff: 
examples/src/main/java/org/apache/spark/examples/ml/JavaKMeansExample.java ---
    @@ -51,9 +52,17 @@ public static void main(String[] args) {
         KMeans kmeans = new KMeans().setK(2).setSeed(1L);
         KMeansModel model = kmeans.fit(dataset);
     
    -    // Evaluate clustering by computing Within Set Sum of Squared Errors.
    -    double WSSSE = model.computeCost(dataset);
    -    System.out.println("Within Set Sum of Squared Errors = " + WSSSE);
    +    // Make predictions
    +    Dataset<Row> predictions = model.transform(dataset);
    +
    +    // Evaluate clustering by computing Silhouette score
    +    ClusteringEvaluator evaluator = new ClusteringEvaluator()
    +      .setFeaturesCol("features")
    +      .setPredictionCol("prediction")
    --- End diff --
    
    We use default values here, so it's not necessary to set them explicitly. 
We should keep examples as simple as possible. Thanks.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to