Imprimindo o ClusterID e seus elementos usando o Spark KMeans.

Eu tenho este programa que imprime o algoritmo MSSE of Kmeans no apache-spark. Existem 20 clusters gerados. Estou tentando imprimir o clusterID e os elementos que foram atribuídos ao respectivo clusterID. Como faço um loop sobre o clusterID para imprimir os elementos.

Obrigado pessoal !!

           val sc = new SparkContext("local", "KMeansExample","/usr/local/spark/", List("target/scala-2.10/kmeans_2.10-1.0.jar"))
            // Load and parse the data
            val data = sc.textFile("kmeans.csv")
         val parsedData = data.map( s => Vectors.dense(s.split(',').map(_.toDouble)))

        // Cluster the data into two classes using KMeans
        val numIterations = 20
        val numClusters = 20
        val clusters = KMeans.train(parsedData, numClusters, numIterations)
        val clusterCenters = clusters.clusterCenters map (_.toArray)
        println("The Cluster Centers are = " + clusterCenters)
        // Evaluate clustering by computing Within Set Sum of Squared Errors
        val WSSSE = clusters.computeCost(parsedData)
        println("Within Set Sum of Squared Errors = " + WSSSE)

questionAnswers(1)

yourAnswerToTheQuestion