Skip to content

Commit ea6c285

Browse files
committed
Replace the sample code with include_example
1 parent 25c0a60 commit ea6c285

File tree

1 file changed

+1
-20
lines changed

1 file changed

+1
-20
lines changed

docs/mllib-clustering.md

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -740,29 +740,10 @@ The implementation in MLlib has the following parameters:
740740

741741
<div class="codetabs">
742742
<div data-lang="scala" markdown="1">
743-
The following code snippets can be executed in `spark-shell`.
744-
745743
Refer to the [`BisectingKMeans` Scala docs](api/scala/index.html#org.apache.spark.mllib.clustering.BisectingKMeans) and [`BisectingKMeansModel` Scala docs](api/scala/index.html#org.apache.spark.mllib.clustering.BisectingKMeansModel) for details on the API.
746744

747-
{% highlight scala %}
748-
import org.apache.spark.mllib.clustering.{BisectingKMeans, BisectingKMeansModel}
749-
import org.apache.spark.mllib.linalg.Vectors
750-
751-
// Load and parse the data
752-
val data = sc.textFile("data/mllib/sample_bisecting_kmeans_data.txt")
753-
val parsedData = data.map(s => Vectors.dense(s.trim.split(',').map(_.toDouble)))
754-
755-
// Cluster the data into the tree clusters using BisectingKMeans
756-
val model = new BisectingKMeans().setK(3).run(parsedData)
757-
758-
// Output the compute cost and the cluster centers
759-
println(s"Compute Cost: ${model.computeCost(parsedData)}")
760-
model.clusterCenters.zipWithIndex.foreach { case (center, idx) =>
761-
println(s"Cluster Center ${idx}: ${center}")
762-
}
763-
{% endhighlight %}
745+
{% include_example scala/org/apache/spark/examples/mllib/BisectingKMeansExample.scala %}
764746
</div>
765-
766747
</div>
767748

768749
## Streaming k-means

0 commit comments

Comments
 (0)