當前位置: 首頁>>代碼示例>>Java>>正文


Java MultiLabelLearner類代碼示例

本文整理匯總了Java中mulan.classifier.MultiLabelLearner的典型用法代碼示例。如果您正苦於以下問題:Java MultiLabelLearner類的具體用法?Java MultiLabelLearner怎麽用?Java MultiLabelLearner使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MultiLabelLearner類屬於mulan.classifier包,在下文中一共展示了MultiLabelLearner類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: run

import mulan.classifier.MultiLabelLearner; //導入依賴的package包/類
/**
 * Run the selected multi-label classification algorithm
 *
 * @param args Command line arguments
 */
private void run(String[] args) {
    List<Measure> measures;
    MultiLabelLearner classifier;
    MultipleEvaluation results = new MultipleEvaluation();
    long tIniTr = 0;
    long tIniTe = 0;
    long tTrain = 0;
    long tTest = 0;
    long tTotal = 0;
    long taux = 0;
    long taux2 = 0;

    readParameters(args);
    root = path + File.separator + dataset + "-";

    try {
        int numLabels = getNumberOfLabels();

        measures = getListMeasures(numLabels);
        classifier = getClassifier(numLabels);


        for(int fold = 1; fold <= folds; fold++) {
            if(debug) System.out.println("Fold " + fold);
            MultiLabelInstances
                    train = new MultiLabelInstances(root + fold + "tra.arff", xmlfile),
                    test  = new MultiLabelInstances(root + fold + "tst.arff", xmlfile);

            MultiLabelLearner cls = classifier.makeCopy();


            tIniTr = System.currentTimeMillis();


            cls.build(train);
            taux = System.currentTimeMillis();
            tTrain = (taux-tIniTr)/1 + tTrain;
            tIniTe = System.currentTimeMillis();
            Evaluator evaluator = new Evaluator();
            Evaluation evaluation;
            evaluation = evaluator.evaluate(cls, test, measures);
            taux2 = System.currentTimeMillis();
            tTest = (taux2-tIniTe)/1 + tTest;
            tTotal = (taux2-tIniTr)/1 + tTotal;
            if (debug) System.out.println(evaluation);
            results.addEvaluation(evaluation);
        }
        results.calculateStatistics();
        System.out.println(algorithm + "," + dataset + "," + results.toCSV().replace(",", ".").replace(";", ",").replace("\u00B1", ";") + tTrain + "," + tTest + "," + tTotal+ ",");
    } catch(Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:fcharte,項目名稱:SM-MLC,代碼行數:59,代碼來源:Main.java

示例2: getClassifier

import mulan.classifier.MultiLabelLearner; //導入依賴的package包/類
/**
 * Get the classifier to use from the parameters given
 *
 * @param numLabels Number of labels in the dataset
 * @return MultiLabelLearner with the classifier
 */
MultiLabelLearner getClassifier(int numLabels) {
    ArrayList<String> learnerName = new ArrayList<String>(10);
    learnerName.add("CLR");
    learnerName.add("MLkNN");
    learnerName.add("BPMLL");
    learnerName.add("BR-J48");
    learnerName.add("LP-J48");
    learnerName.add("IBLR-ML");
    learnerName.add("RAkEL-LP");
    learnerName.add("RAkEL-BR");
    learnerName.add("HOMER");
    learnerName.add("PS-J48");
    learnerName.add("EPS-J48");
    learnerName.add("CC-J48");
    learnerName.add("ECC-J48");
    learnerName.add("BRkNN");

    PrunedSets.Strategy pss= PrunedSets.Strategy.values()[0];
    //public static final BRkNN.ExtensionType ext = NONE;

    MultiLabelLearner[] learner = {
        new CalibratedLabelRanking(new J48()),
        new MLkNN(10, 1.0),
        new BPMLL(),
        new BinaryRelevance(new J48()),
        new LabelPowerset(new J48()),
        new IBLR_ML(),
        new RAkEL(new LabelPowerset(new J48())),
        new RAkEL(new BinaryRelevance(new J48())),
        new HOMER(new BinaryRelevance(new J48()),
                (numLabels < 4 ? numLabels : 4), Method.Random),
        new PrunedSets(new J48(),2,pss,2),
        new EnsembleOfPrunedSets(80, 10, 0.2, 2, pss, 2, new J48()),
        new ClassifierChain(new J48()),
        new EnsembleOfClassifierChains(new J48(), 10, true, false),
        new BRkNN(10)
    };

    return learner[learnerName.indexOf(algorithm)];
}
 
開發者ID:fcharte,項目名稱:SM-MLC,代碼行數:47,代碼來源:Main.java


注:本文中的mulan.classifier.MultiLabelLearner類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。