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

    https://github.com/apache/spark/pull/11844#discussion_r62798712
  
    --- Diff: 
examples/src/main/java/org/apache/spark/examples/ml/JavaBisectingKMeansExample.java
 ---
    @@ -48,26 +43,19 @@ public static void main(String[] args) {
           .getOrCreate();
     
         // $example on$
    -    List<Row> data = Arrays.asList(
    -      RowFactory.create(Vectors.dense(0.1, 0.1, 0.1)),
    -      RowFactory.create(Vectors.dense(0.3, 0.3, 0.25)),
    -      RowFactory.create(Vectors.dense(0.1, 0.1, -0.1)),
    -      RowFactory.create(Vectors.dense(20.3, 20.1, 19.9)),
    -      RowFactory.create(Vectors.dense(20.2, 20.1, 19.7)),
    -      RowFactory.create(Vectors.dense(18.9, 20.0, 19.7))
    -    );
    -
    -    StructType schema = new StructType(new StructField[]{
    -      new StructField("features", new VectorUDT(), false, 
Metadata.empty()),
    -    });
    -
    -    Dataset<Row> dataset = spark.createDataFrame(data, schema);
    +    // Loads data.
    +    Dataset<Row> dataset = 
spark.read().format("libsvm").load("data/mllib/sample_kmeans_data.txt");
     
    -    BisectingKMeans bkm = new BisectingKMeans().setK(2);
    +    // Trains a bisecting k-means model.
    +    BisectingKMeans bkm = new BisectingKMeans().setK(2).setSeed(1);
         BisectingKMeansModel model = bkm.fit(dataset);
     
    -    System.out.println("Compute Cost: " + model.computeCost(dataset));
    +    // Evaluate clustering.
    +    double cost = model.computeCost(dataset);
    +    System.out.println("Compute Cost: " + cost);
    --- End diff --
    
    Good idea. I will do it.


---
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]

Reply via email to