import java.io.*; import java.text.DecimalFormat; import java.util.HashMap; public class TestBys { public static void main(String[] args) throws IOException { Classifier classifier = new Classifier(); File file = new File("/home/zy/IdeaProjects/Test/a.txt"); classifier.study(file); Car car1 = new Car("vhigh","vhigh","2","2","small","low"); Car car2 = new Car("med","low","4","more","big","med"); Car car3=new Car("med","low","4","more","big","high"); System.out.println(classifier.classify(car1)); System.out.println(classifier.classify(car2)); System.out.println(classifier.classify(car3)); } } class Car{ String buy; String maint; String door; String persons; String safety; String lug_boot; public Car(String vhigh, String vhigh1, String s, String s1, String small, String low) { buy=vhigh; maint=vhigh1; door=s; persons=s1; safety=low; lug_boot=small; } } class Classifier{ DecimalFormat df=new DecimalFormat("0.0000"); DecimalFormat dff
模式识别-----贝叶斯算法(java实现)
最新推荐文章于 2021-03-14 08:44:53 发布