Search Java Code Snippets


  Help us in improving the repository. Add new snippets through 'Submit Code Snippet ' link.





#Java - Code Snippets for '#Org.apache.spark.mllib.clustering.PowerIterationClusteringModel' - 1 code snippet(s) found

 Sample 1. Code Sample / Example / Snippet of org.apache.spark.mllib.clustering.PowerIterationClusteringModel

  public static void main(String[] args) {

SparkConf sparkConf = new SparkConf().setAppName("JavaPowerIterationClusteringExample");

JavaSparkContext sc = new JavaSparkContext(sparkConf);



@SuppressWarnings("unchecked")

JavaRDD<Tuple3<Long, Long, Double>> similarities = sc.parallelize(Lists.newArrayList(

new Tuple3<Long, Long, Double>(0L, 1L, 0.9),

new Tuple3<Long, Long, Double>(1L, 2L, 0.9),

new Tuple3<Long, Long, Double>(2L, 3L, 0.9),

new Tuple3<Long, Long, Double>(3L, 4L, 0.1),

new Tuple3<Long, Long, Double>(4L, 5L, 0.9)));



PowerIterationClustering pic = new PowerIterationClustering()

.setK(2)

.setMaxIterations(10);

PowerIterationClusteringModel model = pic.run(similarities);



for (PowerIterationClustering.Assignment a: model.assignments().toJavaRDD().collect()) {

System.out.println(a.id() + " -> " + a.cluster());

}



sc.stop();

}


   Like      Feedback      org.apache.spark.mllib.clustering.PowerIterationClusteringModel



Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner