當前位置: 首頁>>代碼示例>>Java>>正文


Java NominalMapping.setMapping方法代碼示例

本文整理匯總了Java中com.rapidminer.example.table.NominalMapping.setMapping方法的典型用法代碼示例。如果您正苦於以下問題:Java NominalMapping.setMapping方法的具體用法?Java NominalMapping.setMapping怎麽用?Java NominalMapping.setMapping使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.rapidminer.example.table.NominalMapping的用法示例。


在下文中一共展示了NominalMapping.setMapping方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: replaceValue

import com.rapidminer.example.table.NominalMapping; //導入方法依賴的package包/類
/**
 * Replaces the given real value by the new one. Please note that this method will only work for
 * nominal attributes.
 */
public static void replaceValue(Attribute attribute, String oldValue, String newValue) {
	if (!attribute.isNominal()) {
		throw new RuntimeException("Example-Tools: replaceValue is only supported for nominal attributes.");
	}
	NominalMapping mapping = attribute.getMapping();
	int oldIndex = mapping.getIndex(oldValue);
	if (oldIndex < 0) {
		throw new RuntimeException(
				"Example-Tools: replaceValue cannot be performed since old value was not defined in the attribute.");
	}
	mapping.setMapping(newValue, oldIndex);
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:17,代碼來源:Tools.java

示例2: remap

import com.rapidminer.example.table.NominalMapping; //導入方法依賴的package包/類
private void remap(Attributes attributes) {
	for (String attributeName : affectedAttributeNames) {
		Attribute attr = attributes.get(attributeName);
		if (attr.isNominal()) {
			NominalMapping mapping = attr.getMapping();
			List<String> mappingValues = mapping.getValues();

			for (String string : mappingValues) {
				String replacement = replace(string);
				int oldRepr = mapping.getIndex(string);
				// Nothing to replace
				if (replacement.equals(string)) {
					continue;
				}
				// Replacement already present in mapping -> Replace in example set
				else if (mappingValues.contains(replacement)) {
					for (Example example : exampleSet) {
						double oldValue = example.getValue(attr);
						if (Tools.isEqual(oldRepr, oldValue)) {
							int newRepr = mapping.getIndex(replacement);
							example.setValue(attr, newRepr);
						}
					}
				}
				// Replacement not present in mapping -> Replace in mapping
				else {
					mapping.setMapping(replacement, oldRepr);
				}
			}

		}
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:34,代碼來源:Dictionary.java

示例3: replaceValue

import com.rapidminer.example.table.NominalMapping; //導入方法依賴的package包/類
/** Replaces the given real value by the new one. Please note that this method will only 
 *  work for nominal attributes. */
public static void replaceValue(Attribute attribute, String oldValue, String newValue) {
	if (!attribute.isNominal())
		throw new RuntimeException("Example-Tools: replaceValue is only supported for nominal attributes.");
	NominalMapping mapping = attribute.getMapping();
	int oldIndex = mapping.getIndex(oldValue);
	if (oldIndex < 0)
		throw new RuntimeException("Example-Tools: replaceValue cannot be performed since old value was not defined in the attribute.");
	mapping.setMapping(newValue, oldIndex);
}
 
開發者ID:rapidminer,項目名稱:rapidminer-5,代碼行數:12,代碼來源:Tools.java

示例4: remap

import com.rapidminer.example.table.NominalMapping; //導入方法依賴的package包/類
private void remap(Attributes attributes) {
	for (String attributeName: affectedAttributeNames) {
		Attribute attr = attributes.get(attributeName);
		if (attr.isNominal()) {
			NominalMapping mapping = attr.getMapping();
			for (String string : mapping.getValues()) {
				int index = mapping.getIndex(string);
				mapping.setMapping(replace(string), index);
			}
		}
	}
}
 
開發者ID:rapidminer,項目名稱:rapidminer-5,代碼行數:13,代碼來源:Dictionary.java

示例5: remap

import com.rapidminer.example.table.NominalMapping; //導入方法依賴的package包/類
/**
 * Remaps the attributes in the exampleSet or writes into the exampleSet if a remapping is not
 * possible.
 */
private void remap(ExampleSet exampleSet) throws ProcessStoppedException {
	Attributes attributes = exampleSet.getAttributes();
	OperatorProgress progress = null;
	if (getShowProgress() && getOperator() != null && getOperator().getProgress() != null) {
		progress = getOperator().getProgress();
		progress.setTotal(affectedAttributeNames.length);
	}
	int progressCounter = 0;

	for (String attributeName : affectedAttributeNames) {
		Attribute attr = attributes.get(attributeName);
		if (attr.isNominal()) {
			NominalMapping mapping = attr.getMapping();
			List<String> mappingValues = mapping.getValues();

			for (String string : mappingValues) {
				String replacement = replace(string);
				int oldRepr = mapping.getIndex(string);
				// Nothing to replace
				if (replacement.equals(string)) {
					continue;
				}
				// Replacement already present in mapping -> Replace in example set
				else if (mappingValues.contains(replacement)) {
					for (Example example : exampleSet) {
						double oldValue = example.getValue(attr);
						if (Tools.isEqual(oldRepr, oldValue)) {
							int newRepr = mapping.getIndex(replacement);
							example.setValue(attr, newRepr);
						}
					}
				}
				// Replacement not present in mapping -> Replace in mapping
				else {
					mapping.setMapping(replacement, oldRepr);
				}
			}

		}
		if (progress != null && ++progressCounter % OPERATOR_PROGRESS_STEPS == 0) {
			progress.setCompleted(progressCounter);
		}
	}
}
 
開發者ID:rapidminer,項目名稱:rapidminer-studio,代碼行數:49,代碼來源:Dictionary.java


注:本文中的com.rapidminer.example.table.NominalMapping.setMapping方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。