本文整理汇总了Java中com.rapidminer.operator.learner.meta.HierarchicalMultiClassModel.Node类的典型用法代码示例。如果您正苦于以下问题:Java Node类的具体用法?Java Node怎么用?Java Node使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Node类属于com.rapidminer.operator.learner.meta.HierarchicalMultiClassModel包,在下文中一共展示了Node类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeModel
import com.rapidminer.operator.learner.meta.HierarchicalMultiClassModel.Node; //导入依赖的package包/类
/**
* This method will first create a working label column and after this run through the tree
* recursivly.
*/
private void computeModel(HierarchicalMultiClassModel.Node rootNode, ExampleSet exampleSet, Attribute originalLabel)
throws OperatorException {
// create working label with copy of original label values
exampleSet.getAttributes().setSpecialAttribute(originalLabel, "label_original");
Attribute workingLabel = AttributeFactory.createAttribute(originalLabel.getName() + "_working",
originalLabel.getValueType());
exampleSet.getExampleTable().addAttribute(workingLabel);
exampleSet.getAttributes().addRegular(workingLabel);
exampleSet.getAttributes().setLabel(workingLabel);
// create partition for recursive learning
int[] partitions = new int[exampleSet.size()];
int i = 0;
int lastLeafId = -1;
for (Example example : exampleSet) {
double value = example.getValue(originalLabel);
example.setValue(workingLabel, value);
partitions[i] = (int) value;
if (partitions[i] > lastLeafId) {
lastLeafId = partitions[i];
}
i++;
}
AtomicInteger nonLeafCounter = new AtomicInteger(lastLeafId);
setParitionIdRecursivly(rootNode, nonLeafCounter, lastLeafId, workingLabel);
// recursively walk through hierarchy and learn
computeModelRecursivly(rootNode, partitions, nonLeafCounter.get(), exampleSet);
// remove working_label again
exampleSet.getAttributes().remove(workingLabel);
exampleSet.getAttributes().setLabel(originalLabel);
exampleSet.getExampleTable().removeAttribute(workingLabel);
}
示例2: setParitionIdRecursivly
import com.rapidminer.operator.learner.meta.HierarchicalMultiClassModel.Node; //导入依赖的package包/类
/**
* This will set the partition id by either taking the mapping value of the original label
* mapping if the node is a leaf, or the next free integer available after the highest entry in
* the mapping.
*/
private void setParitionIdRecursivly(Node node, AtomicInteger nonLeafCounter, int maxLeafId, Attribute workingLabel) {
if (node.isLeaf()) {
node.setPartitionId(workingLabel.getMapping().mapString(node.getClassName()));
} else {
for (Node child : node.getChildren()) {
setParitionIdRecursivly(child, nonLeafCounter, maxLeafId, workingLabel);
node.setPartitionId(nonLeafCounter.incrementAndGet());
}
}
}
示例3: computeModel
import com.rapidminer.operator.learner.meta.HierarchicalMultiClassModel.Node; //导入依赖的package包/类
/**
* This method will first create a working label column and after this run through the tree recursivly.
*/
private void computeModel(HierarchicalMultiClassModel.Node rootNode, ExampleSet exampleSet, Attribute originalLabel) throws OperatorException {
// create working label with copy of original label values
exampleSet.getAttributes().setSpecialAttribute(originalLabel, "label_original");
Attribute workingLabel = AttributeFactory.createAttribute(originalLabel.getName() + "_working", originalLabel.getValueType());
exampleSet.getExampleTable().addAttribute(workingLabel);
exampleSet.getAttributes().addRegular(workingLabel);
exampleSet.getAttributes().setLabel(workingLabel);
// create partition for recursive learning
int[] partitions = new int[exampleSet.size()];
int i = 0;
int lastLeafId = -1;
for (Example example : exampleSet) {
double value = example.getValue(originalLabel);
example.setValue(workingLabel, value);
partitions[i] = (int) value;
if (partitions[i] > lastLeafId)
lastLeafId = partitions[i];
i++;
}
AtomicInteger nonLeafCounter = new AtomicInteger(lastLeafId);
setParitionIdRecursivly(rootNode, nonLeafCounter, lastLeafId, workingLabel);
// recursively walk through hierarchy and learn
computeModelRecursivly(rootNode, partitions, nonLeafCounter.get(), exampleSet);
// remove working_label again
exampleSet.getAttributes().remove(workingLabel);
exampleSet.getAttributes().setLabel(originalLabel);
exampleSet.getExampleTable().removeAttribute(workingLabel);
}
示例4: setParitionIdRecursivly
import com.rapidminer.operator.learner.meta.HierarchicalMultiClassModel.Node; //导入依赖的package包/类
/**
* This will set the partition id by either taking the mapping value of the original label mapping if the node is a leaf,
* or the next free integer available after the highest entry in the mapping.
*/
private void setParitionIdRecursivly(Node node, AtomicInteger nonLeafCounter, int maxLeafId, Attribute workingLabel) {
if (node.isLeaf()) {
node.setPartitionId(workingLabel.getMapping().mapString(node.getClassName()));
} else {
for (Node child: node.getChildren()) {
setParitionIdRecursivly(child, nonLeafCounter, maxLeafId, workingLabel);
node.setPartitionId(nonLeafCounter.incrementAndGet());
}
}
}