List of usage examples for weka.classifiers.mi MIBoost MIBoost
MIBoost
From source file:tutorial.exampleMIMLBinaryRelevance.java
License:Open Source License
public static void main(String[] args) { try {// ww w . j av a 2 s . c o m // String arffFileNameTrain = Utils.getOption("f", args); // String arffFileNameTest = Utils.getOption("g",args); // String xmlFileName = Utils.getOption("x", args); String arffFileNameTrain = "data" + File.separator + "miml_text_data_random_80train.arff"; String arffFileNameTest = "data" + File.separator + "miml_text_data_random_20test.arff"; String xmlFileName = "data" + File.separator + "miml_text_data.xml"; // Parameter checking if (arffFileNameTrain.isEmpty()) { System.out.println("Arff pathName must be specified."); showUse(); } if (arffFileNameTest.isEmpty()) { System.out.println("Arff pathName must be specified."); showUse(); } if (xmlFileName.isEmpty()) { System.out.println("Xml pathName must be specified."); showUse(); } // Loads the dataset System.out.println("Loading the dataset...."); MIMLInstances mimlTrain = new MIMLInstances(arffFileNameTrain, xmlFileName); MIMLInstances mimlTest = new MIMLInstances(arffFileNameTest, xmlFileName); Classifier baseLearner = new MIBoost(); MIMLBinaryRelevance MIMLBR = new MIMLBinaryRelevance(baseLearner); MIMLBR.setDebug(true); MIMLBR.build(mimlTrain); // Evaluates a single instance Bag bag = mimlTrain.getBag(1); MultiLabelOutput prediction = MIMLBR.makePrediction(bag); System.out.println("\nPrediction on a single instance:\n\t" + prediction.toString()); // Performs a cross validation evaluation Evaluator evalCV = new Evaluator(); MultipleEvaluation resultsCV; int numFolds = 2; System.out.println("\nPerforming " + numFolds + "-fold cross-validation:\n"); resultsCV = evalCV.crossValidate(MIMLBR, mimlTrain, numFolds); System.out.println("\nResults on cross validation evaluation:\n" + resultsCV); // Performs a train-test evaluation Evaluator evalTT = new Evaluator(); System.out.println("\nPerforming train-test evaluation:\n"); Evaluation resultsTT = evalTT.evaluate(MIMLBR, mimlTest, mimlTrain); System.out.println("\nResults on train test evaluation:\n" + resultsTT); System.out.println("The program has finished."); } catch (IndexOutOfBoundsException ioobe) { System.err.println("Exception: Incorrect index of Bag."); } catch (Exception e) { e.printStackTrace(); } }