本文整理匯總了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();
}
}
示例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)];
}