当前位置: 首页>>代码示例>>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;未经允许,请勿转载。