public static void main(String[] args) throws Exception {
		List<Classifier> classifiers = new ArrayList<Classifier>();
		//classifiers.add(new J48());
		//classifiers.add(new NaiveBayes());
		LibSVM svm = new LibSVM();
		svm.setOptions(new String[] { "-B" });
		//classifiers.add(svm);
		BayesNet bayesnet = new BayesNet();
		
		for (String s: bayesnet.getSearchAlgorithm().getOptions())
			System.out.println(s);
		K2 k2 = new K2();
		k2.setMaxNrOfParents(10);
		bayesnet.setSearchAlgorithm(k2);
		for (String s: bayesnet.getSearchAlgorithm().getOptions())
			System.out.println(s);
		classifiers.add(bayesnet);
		classifiers.add(new BayesNet());

		Results r = new Results();
		r.buildStructure("f1.csv");

		int numAuthors = 100;
		int numTexts = 100;
		Data data = r.buildData(numAuthors, numTexts);

		for (Classifier classifier : classifiers) {
			BufferedWriter out = new BufferedWriter(new FileWriter("f1"
					+ classifier.getClass().getSimpleName() + "AUTHOR"
					+ numAuthors + "TEXT" + numTexts + ".dat"));
			classifier.buildClassifier(data.train);
			int ok = 0;
			int bad = 0;
			int[] places = new int[numAuthors + 1];
			for (int i = 0; i < data.test.numInstances(); ++i) {
				Instance instance = data.test.instance(i);
				double[] distribution = classifier
						.distributionForInstance(instance);
				// System.out.println(instance.classValue());
				// System.out.println(getAuthor(data.test, instance));
				// System.out.println(getWeight(distribution, instance));

				// System.out.println(i + " " + distribution.length);
				int place = getPlace(distribution, instance, numAuthors);
				++places[place];
				// System.out.println();
				if (place < numAuthors * 0.2)
					++ok;
				else
					++bad;
			}
			System.out.println(ok + " " + bad + " " + (double) ok / (bad + ok));

			// dystrbuanta
			int temp = 0;
			int sum = 0;
			double[] cum = new double[numAuthors + 1];
			for (int i = 0; i < places.length; ++i) {
				cum[i] = places[i] + temp;
				temp += places[i];
				sum += places[i];
			}
			for (int i = 0; i < places.length; ++i) {
				cum[i] /= sum;
				out.write("" + i + "\t" + cum[i] + "\n");
			}
			out.close();
		}
	}