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


Java AttributeMetaData.setRole方法代码示例

本文整理汇总了Java中com.rapidminer.operator.ports.metadata.AttributeMetaData.setRole方法的典型用法代码示例。如果您正苦于以下问题:Java AttributeMetaData.setRole方法的具体用法?Java AttributeMetaData.setRole怎么用?Java AttributeMetaData.setRole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.rapidminer.operator.ports.metadata.AttributeMetaData的用法示例。

在下文中一共展示了AttributeMetaData.setRole方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setRoleMetaData

import com.rapidminer.operator.ports.metadata.AttributeMetaData; //导入方法依赖的package包/类
private void setRoleMetaData(ExampleSetMetaData metaData, String name, String targetRole) {
	AttributeMetaData amd = metaData.getAttributeByName(name);
	if (amd != null) {
		if (targetRole != null) {
			if (REGULAR_NAME.equals(targetRole)) {
				amd.setRegular();
			} else {
				AttributeMetaData oldRole = metaData.getAttributeByRole(targetRole);
				if (oldRole != null && oldRole != amd) {
					addError(new SimpleProcessSetupError(Severity.WARNING, this.getPortOwner(), "already_contains_role",
							targetRole));
					metaData.removeAttribute(oldRole);
				}
				amd.setRole(targetRole);
			}
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:19,代码来源:UserSpecificationDataGenerator.java


示例2: modifyMetaData

import com.rapidminer.operator.ports.metadata.AttributeMetaData; //导入方法依赖的package包/类
/**
 * Subclasses might override this method to define the meta data transformation performed by
 * this operator. The default implementation takes all attributes specified by the
 * {@link AttributeSubsetSelector} and passes them to
 * {@link #modifyAttributeMetaData(ExampleSetMetaData, AttributeMetaData)} and replaces them
 * accordingly.
 * 
 * @throws UndefinedParameterError
 */
@Override
protected ExampleSetMetaData modifyMetaData(ExampleSetMetaData exampleSetMetaData) throws UndefinedParameterError {
	ExampleSetMetaData subsetMetaData = attributeSelector.getMetaDataSubset(exampleSetMetaData,
			isSupportingAttributeRoles());
	checkSelectedSubsetMetaData(subsetMetaData);
	for (AttributeMetaData amd : subsetMetaData.getAllAttributes()) {
		Collection<AttributeMetaData> replacement = null;
		replacement = modifyAttributeMetaData(exampleSetMetaData, amd);
		if (replacement != null) {
			if (replacement.size() == 1) {
				AttributeMetaData replacementAttribute = replacement.iterator().next();
				replacementAttribute.setRole(exampleSetMetaData.getAttributeByName(amd.getName()).getRole());
			}
			exampleSetMetaData.removeAttribute(amd);
			exampleSetMetaData.addAllAttributes(replacement);
		}
	}
	return exampleSetMetaData;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:29,代码来源:PreprocessingOperator.java


示例3: setRoleMetaData

import com.rapidminer.operator.ports.metadata.AttributeMetaData; //导入方法依赖的package包/类
private void setRoleMetaData(ExampleSetMetaData metaData, String name, String targetRole) {
	AttributeMetaData amd = metaData.getAttributeByName(name);
	if (amd != null) {
		if (targetRole != null) {
			if (REGULAR_NAME.equals(targetRole)) {
				amd.setRegular();
			} else {
				AttributeMetaData oldRole = metaData.getAttributeByRole(targetRole);
				if (oldRole != null && oldRole != amd) {
					if (getCompatibilityLevel().compareTo(VERSION_BEFORE_KEEPING_SPECIAL_ATT_WHEN_IT_LOSE_ROLE) > 0) {
						oldRole.setRegular();
					} else {
						getInputPort().addError(
								new SimpleMetaDataError(Severity.WARNING, getInputPort(), "already_contains_role",
										targetRole));
						metaData.removeAttribute(oldRole);
					}
				}
				amd.setRole(targetRole);
			}
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:24,代码来源:ChangeAttributeRole.java


示例4: modifyMetaData

import com.rapidminer.operator.ports.metadata.AttributeMetaData; //导入方法依赖的package包/类
@Override
protected MetaData modifyMetaData(ExampleSetMetaData metaData) throws UndefinedParameterError {

	AttributeMetaData attributeByName = metaData.getAttributeByName(getParameterAsString(PARAMETER_ATTRIBUTE_NAME));
	if (attributeByName != null) {
		AttributeMetaData newAttribute = attributeByName.copy();
		newAttribute.setRole(null);
		if (isParameterSet(PARAMETER_NEW_NAME)) {
			newAttribute.setName(getParameterAsString(PARAMETER_NEW_NAME));
		} else {
			newAttribute.setName("copy(" + newAttribute.getName() + ")");
		}
		metaData.addAttribute(newAttribute);
	}
	return metaData;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:17,代码来源:AttributeCopy.java


示例5: modifyMetaData

import com.rapidminer.operator.ports.metadata.AttributeMetaData; //导入方法依赖的package包/类
@Override
protected MetaData modifyMetaData(ExampleSetMetaData metaData) {
	try {
		AttributeMetaData amd1 = metaData.getAttributeByName(getParameterAsString(PARAMETER_FIRST_ATTRIBUTE));
		AttributeMetaData amd2 = metaData.getAttributeByName(getParameterAsString(PARAMETER_SECOND_ATTRIBUTE));

		if (amd1 != null && amd2 != null) {
			String role1 = amd1.getRole();
			amd1.setRole(amd2.getRole());
			amd2.setRole(role1);
		}
	} catch (UndefinedParameterError e) {
	}
	return metaData;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:16,代码来源:ExchangeAttributeRoles.java


示例6: modifyMetaData

import com.rapidminer.operator.ports.metadata.AttributeMetaData; //导入方法依赖的package包/类
@Override
protected final MetaData modifyMetaData(ExampleSetMetaData inputMetaData) {
	ExampleSetMetaData workingMetaData = inputMetaData.clone();

	ExampleSetMetaData subsetAmd = attributeSelector.getMetaDataSubset(workingMetaData, false);

	// storing unused attributes and saving roles
	List<AttributeMetaData> unusedAttributes = new LinkedList<>();
	Iterator<AttributeMetaData> iterator = workingMetaData.getAllAttributes().iterator();
	while (iterator.hasNext()) {
		AttributeMetaData amd = iterator.next();
		String name = amd.getName();
		MetaDataInfo containsAttributeName = subsetAmd.containsAttributeName(name);

		if (subsetAmd.getAttributeSetRelation() == SetRelation.SUBSET && containsAttributeName == MetaDataInfo.NO
				|| subsetAmd.getAttributeSetRelation() != SetRelation.SUBSET
				&& containsAttributeName != MetaDataInfo.YES) {
			unusedAttributes.add(amd);
			iterator.remove();
		} else if (amd.isSpecial()) {
			amd.setRegular();
		}
	}

	// retrieving result
	ExampleSetMetaData resultMetaData = workingMetaData;
	try {
		resultMetaData = applyOnFilteredMetaData(workingMetaData);
	} catch (UndefinedParameterError e) {
	}

	// merge result with unusedAttributes: restore special types from original input
	Iterator<AttributeMetaData> r = resultMetaData.getAllAttributes().iterator();
	while (r.hasNext()) {
		AttributeMetaData newMetaData = r.next();
		AttributeMetaData oldMetaData = inputMetaData.getAttributeByName(newMetaData.getName());
		if (oldMetaData != null) {
			if (oldMetaData.isSpecial()) {
				String specialName = oldMetaData.getRole();
				newMetaData.setRole(specialName);
			}
		}
	}

	// add unused attributes again
	resultMetaData.addAllAttributes(unusedAttributes);
	return resultMetaData;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:49,代码来源:AbstractFilteredDataProcessing.java


示例7: getGeneratedMetaData

import com.rapidminer.operator.ports.metadata.AttributeMetaData; //导入方法依赖的package包/类
@Override
public ExampleSetMetaData getGeneratedMetaData() {
	if (attributeNamesDefinedByUser()) {
		loadMetaDataFromParameters();
		guessedValueTypes = true;
	}

	if (!guessedValueTypes) {
		return new ExampleSetMetaData();
	}

	ExampleSetMetaData metaData = new ExampleSetMetaData();

	for (AttributeColumn column : getActiveAttributeColumns()) {

		AttributeMetaData amd = new AttributeMetaData(column.getName(), column.getValueType());
		amd.setAnnotations(column.getAnnotations());

		String role = column.getRole();
		if (role.equals(AttributeColumn.REGULAR)) {
			role = null;
		}
		amd.setRole(role);

		MDInteger missings = new MDInteger(column.numberOfMissings);
		SetRelation relation = SetRelation.EQUAL;

		if (!isMetaDatafixed()) {
			relation = SetRelation.SUPERSET;
			missings.increaseByUnknownAmount();
		}
		if (Ontology.ATTRIBUTE_VALUE_TYPE.isA(column.getValueType(), Ontology.NUMERICAL)
				|| Ontology.ATTRIBUTE_VALUE_TYPE.isA(column.getValueType(), Ontology.DATE_TIME)) {
			amd.setValueRange(new Range(column.maxValue, column.maxValue), relation);
		} else {
			amd.setValueSet(column.valueSet, relation);
		}
		amd.setNumberOfMissingValues(missings);
		metaData.addAttribute(amd);
	}
	metaData.setNumberOfExamples(new MDInteger(getRowCountFromGuessing()));
	if (!isMetaDatafixed()) {
		metaData.getNumberOfExamples().increaseByUnknownAmount();
		metaData.attributesAreSuperset();
	}
	return metaData;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:48,代码来源:AbstractDataReader.java



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