本文整理汇总了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);
}
示例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);
}
}
}
}
}
示例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);
}
示例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);
}
}
}
}
示例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);
}
}
}