本文整理汇总了Java中com.rapidminer.example.table.NominalMapping.clear方法的典型用法代码示例。如果您正苦于以下问题:Java NominalMapping.clear方法的具体用法?Java NominalMapping.clear怎么用?Java NominalMapping.clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.rapidminer.example.table.NominalMapping
的用法示例。
在下文中一共展示了NominalMapping.clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mergeValues
import com.rapidminer.example.table.NominalMapping; //导入方法依赖的package包/类
private void mergeValues(ExampleSet exampleSet, Attribute attribute, String firstValue, String secondValue)
throws OperatorException {
Attribute newAttribute = AttributeFactory.createAttribute(attribute, "merged");
// clone is necessary here!
NominalMapping mapping = (NominalMapping) attribute.getMapping().clone();
mapping.clear();
newAttribute.setMapping(mapping);
exampleSet.getExampleTable().addAttribute(newAttribute);
exampleSet.getAttributes().addRegular(newAttribute);
double first = attribute.getMapping().mapString(firstValue);
double second = attribute.getMapping().mapString(secondValue);
String firstPlusSecondString = firstValue + "_" + secondValue;
Iterator<Example> reader = exampleSet.iterator();
while (reader.hasNext()) {
Example example = reader.next();
double value = example.getValue(attribute);
if (Double.isNaN(value)) {
example.setValue(newAttribute, Double.NaN);
} else if (value == first || value == second) {
example.setValue(newAttribute, newAttribute.getMapping().mapString(firstPlusSecondString));
} else {
example.setValue(newAttribute,
newAttribute.getMapping().mapString(attribute.getMapping().mapIndex((int) value)));
}
checkForStop();
}
exampleSet.getAttributes().remove(attribute);
newAttribute.setName(attribute.getName());
}
示例2: mergeValues
import com.rapidminer.example.table.NominalMapping; //导入方法依赖的package包/类
private void mergeValues(ExampleSet exampleSet, Attribute attribute, String firstValue, String secondValue) throws OperatorException {
Attribute newAttribute = AttributeFactory.createAttribute(attribute, "merged");
// clone is necessary here!
NominalMapping mapping = (NominalMapping) attribute.getMapping().clone();
mapping.clear();
newAttribute.setMapping(mapping);
exampleSet.getExampleTable().addAttribute(newAttribute);
exampleSet.getAttributes().addRegular(newAttribute);
double first = attribute.getMapping().mapString(firstValue);
double second = attribute.getMapping().mapString(secondValue);
String firstPlusSecondString = firstValue + "_" + secondValue;
Iterator<Example> reader = exampleSet.iterator();
while (reader.hasNext()) {
Example example = reader.next();
double value = example.getValue(attribute);
if (Double.isNaN(value)) {
example.setValue(newAttribute, Double.NaN);
} else if ((value == first) || (value == second))
example.setValue(newAttribute, newAttribute.getMapping().mapString(firstPlusSecondString));
else
example.setValue(newAttribute, newAttribute.getMapping().mapString(attribute.getMapping().mapIndex((int) value)));
checkForStop();
}
exampleSet.getAttributes().remove(attribute);
newAttribute.setName(attribute.getName());
}