Search Java Code Snippets


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





Java - Code Samples

 Sample 1. Code Sample / Example / Snippet of org.apache.spark.mllib.fpm.AssociationRules

  public static void main(String[] args) {



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

JavaSparkContext sc = new JavaSparkContext(sparkConf);



JavaRDD<FPGrowth.FreqItemset<String>> freqItemsets = sc.parallelize(Arrays.asList(

new FreqItemset<String>(new String[] {"a"}, 15L),

new FreqItemset<String>(new String[] {"b"}, 35L),

new FreqItemset<String>(new String[] {"a", "b"}, 12L)

));



AssociationRules arules = new AssociationRules()

.setMinConfidence(0.8);

JavaRDD<AssociationRules.Rule<String>> results = arules.run(freqItemsets);



for (AssociationRules.Rule<String> rule : results.collect()) {

System.out.println(

rule.javaAntecedent() + " => " + rule.javaConsequent() + ", " + rule.confidence());

}

}


   Like      Feedback      org.apache.spark.mllib.fpm.AssociationRules



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