当前位置: 首页>>代码示例>>Java>>正文


Java Node类代码示例

本文整理汇总了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);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:41,代码来源:HierarchicalMultiClassLearner.java

示例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());
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:16,代码来源:HierarchicalMultiClassLearner.java

示例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);
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:37,代码来源:HierarchicalMultiClassLearner.java

示例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());
		}
	}
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:15,代码来源:HierarchicalMultiClassLearner.java


注:本文中的com.rapidminer.operator.learner.meta.HierarchicalMultiClassModel.Node类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。