Friday, 15 June 2018

Collection classifier code for java

Naive Bayes classifier
naive Bayes classifiers are a family of simple "probabilistic classifiers" based on applying Bayes' theorem with strong (naive) independence assumptions between the features.
In the statistics and computer science literature, naive Bayes models are known under a variety of names, including simple Bayes and independence Bayes.All these names reference the use of Bayes' theorem in the classifier's decision rule, but naive Bayes is not (necessarily) a Bayesian method. Objects have features and may belong to a category. The classifier will try matching objects to their categories by looking at the objects' features.



Collection classifier

import java.util.*;

    public class CollectionClassifier2 {
         public static String classify(Collection c) {
         return (c instanceof Set ? "Set" :
         (c instanceof List ? "List" : "Unknown Collection"));
     }
    
         public static void main(String[] args) {
             Collection[] tests = new Collection[] {
             new HashSet(), // A Set
             new ArrayList(), // A List
             new HashMap().values() // Neither Set nor List
         };
        
         for (int i = 0; i < tests.length; i++)
         System.out.println(classify(tests[i]));
     }
}


http://en.wikipedia.org/wiki/Naive_Bayes_classifier#Probabilistic_model
https://github.com/ptnplanet/Java-Naive-Bayes-Classifier

0 comments:

Post a Comment