本文整理汇总了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)];
}