#Java - Code Snippets for '#.Cluster' - 4 code snippet(s) found |
|
Sample 1. Code Sample / Example / Snippet of org.apache.spark.mllib.clustering.DistributedLDAModel | |
|
DistributedLDAModel ldaModel = (DistributedLDAModel)new LDA().setK(3).run(corpus);
System.out.println("Learned topics (as distributions over vocab of " + ldaModel.vocabSize() + " words):");
Matrix topics = ldaModel.topicsMatrix(); for (int topic = 0; topic < 3; topic++) {
|
|
Like Feedback org.apache.spark.mllib.clustering.DistributedLDAModel |
|
|
Sample 2. Code Sample / Example / Snippet of org.apache.spark.mllib.clustering.PowerIterationClustering | |
|
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.PowerIterationClustering |
|
|
Sample 3. 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 |
|
|
Sample 4. Code Sample / Example / Snippet of com.datastax.driver.core.Cluster | |
|
public CassandraSchema(String host, String keyspace, SchemaPlus parentSchema, String name) {
super();
this.keyspace = keyspace;
try {
Cluster cluster = Cluster.builder().addContactPoint(host).build();
this.session = cluster.connect(keyspace);
} catch (Exception e) {
throw new RuntimeException(e);
}
this.parentSchema = parentSchema;
this.name = name;
Hook.TRIMMED.add(new Function<RelNode, Void>() {
public Void apply(RelNode node) {
CassandraSchema.this.addMaterializedViews();
return null;
}
});
}
|
|
Like Feedback com.datastax.driver.core.Cluster |
|
|