Github user yinxusen commented on the pull request:
https://github.com/apache/spark/pull/11116#issuecomment-184524570
@keypointt Please reformat other Java code files with 2-indent spaces, not
only the lines that I pointed out.
For re-using the example code, even though they are not identical, they are
very similar in functionalities of showing the usage of those classes. Take
`PowerIterationClusteringExample` as an example, other than rewriting the
previous example code with the code in the markdown file, I prefer to change it
as follows:
```scala
def run(params: Params) {
val conf = new SparkConf()
.setMaster("local")
.setAppName(s"PowerIterationClustering with $params")
val sc = new SparkContext(conf)
Logger.getRootLogger.setLevel(Level.WARN)
// $example on$
val circlesRdd = generateCirclesRdd(sc, params.k, params.numPoints)
val model = new PowerIterationClustering()
.setK(params.k)
.setMaxIterations(params.maxIterations)
.setInitializationMode("degree")
.run(circlesRdd)
val clusters =
model.assignments.collect().groupBy(_.cluster).mapValues(_.map(_.id))
val assignments = clusters.toList.sortBy { case (k, v) => v.length }
val assignmentsStr = assignments
.map { case (k, v) =>
s"$k -> ${v.sorted.mkString("[", ",", "]")}"
}.mkString(", ")
val sizesStr = assignments.map {
_._2.length
}.sorted.mkString("(", ",", ")")
println(s"Cluster assignments: $assignmentsStr\ncluster sizes:
$sizesStr")
// $example off$
sc.stop()
}
```
---
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]