當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。