/** * Constructor. * * @throws Exception If the algorithm cannot be executed. */ public C45(String trainfn, String testfn) throws Exception { try { // starts the time long startTime = System.currentTimeMillis(); /* Sets the options of the execution from text file*/ setOptions(trainfn, testfn); /* Initializes the dataset. */ Attributes.clearAll(); modelDataset = new Dataset(modelFileName, true); trainDataset = new Dataset(trainFileName, false); testDataset = new Dataset(testFileName, false); priorsProbabilities = new double[modelDataset.numClasses()]; priorsProbabilities(); marginCounts = new double[marginResolution + 1]; // generate the tree generateTree(modelDataset); // printTrain(); // printTest(); // printResult(); } catch (Exception e) { System.err.println(e.getMessage()); System.exit(-1); } }