本文整理汇总了Java中org.dmg.pmml.DerivedField.getName方法的典型用法代码示例。如果您正苦于以下问题:Java DerivedField.getName方法的具体用法?Java DerivedField.getName怎么用?Java DerivedField.getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.dmg.pmml.DerivedField
的用法示例。
在下文中一共展示了DerivedField.getName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareInputField
import org.dmg.pmml.DerivedField; //导入方法依赖的package包/类
static
private FieldName prepareInputField(FunctionExpression.Argument argument, OpType opType, DataType dataType, RExpEncoder encoder){
Expression expression = argument.getExpression();
if(expression instanceof FieldRef){
FieldRef fieldRef = (FieldRef)expression;
return fieldRef.getField();
} else
if(expression instanceof Apply){
Apply apply = (Apply)expression;
DerivedField derivedField = encoder.createDerivedField(FieldName.create((argument.formatExpression()).trim()), opType, dataType, apply);
return derivedField.getName();
} else
{
throw new IllegalArgumentException();
}
}
示例2: encodeFeature
import org.dmg.pmml.DerivedField; //导入方法依赖的package包/类
static
public Feature encodeFeature(Feature feature, Object missingValue, Object replacementValue, MissingValueTreatmentMethod missingValueTreatmentMethod, SkLearnEncoder encoder){
TypeDefinitionField field = encoder.getField(feature.getName());
if(field instanceof DataField){
MissingValueDecorator missingValueDecorator = new MissingValueDecorator()
.setMissingValueReplacement(ValueUtil.formatValue(replacementValue))
.setMissingValueTreatment(missingValueTreatmentMethod);
if(missingValue != null){
missingValueDecorator.addValues(ValueUtil.formatValue(missingValue));
}
encoder.addDecorator(feature.getName(), missingValueDecorator);
return feature;
} else
if(field instanceof DerivedField){
Expression expression = feature.ref();
if(missingValue != null){
expression = PMMLUtil.createApply("equal", expression, PMMLUtil.createConstant(missingValue));
} else
{
expression = PMMLUtil.createApply("isMissing", expression);
}
expression = PMMLUtil.createApply("if", expression, PMMLUtil.createConstant(replacementValue), feature.ref());
DerivedField derivedField = encoder.createDerivedField(FeatureUtil.createName("imputer", feature), expression);
DataType dataType = derivedField.getDataType();
switch(dataType){
case INTEGER:
case FLOAT:
case DOUBLE:
return new ContinuousFeature(encoder, derivedField);
default:
return new Feature(encoder, derivedField.getName(), derivedField.getDataType()){
@Override
public ContinuousFeature toContinuousFeature(){
throw new UnsupportedOperationException();
}
};
}
} else
{
throw new IllegalArgumentException();
}
}
示例3: resolveChained
import org.dmg.pmml.DerivedField; //导入方法依赖的package包/类
@Test
public void resolveChained() throws Exception {
PMML pmml = ResourceUtil.unmarshal(ChainedSegmentationTest.class);
FieldDependencyResolver resolver = new FieldDependencyResolver();
resolver.applyTo(pmml);
final
Map<Field, Set<Field>> dependencies = resolver.getDependencies();
Visitor visitor = new AbstractVisitor(){
@Override
public VisitorAction visit(DataField dataField){
checkFields(Collections.<FieldName>emptySet(), dependencies.get(dataField));
return super.visit(dataField);
}
@Override
public VisitorAction visit(DerivedField derivedField){
Set<Field> fields = dependencies.get(derivedField);
FieldName name = derivedField.getName();
if("x1_squared".equals(name.getValue())){
checkFields(FieldNameUtil.create("x1"), fields);
} else
if("x1_cubed".equals(name.getValue())){
checkFields(FieldNameUtil.create("x1", "x1_squared"), fields);
} else
if("x2_squared".equals(name.getValue()) || "x2_cubed".equals(name.getValue())){
checkFields(FieldNameUtil.create("x2"), fields);
} else
{
throw new AssertionError();
}
return super.visit(derivedField);
}
@Override
public VisitorAction visit(OutputField outputField){
checkFields(Collections.<FieldName>emptySet(), dependencies.get(outputField));
return super.visit(outputField);
}
};
visitor.applyTo(pmml);
}
示例4: resolveNested
import org.dmg.pmml.DerivedField; //导入方法依赖的package包/类
@Test
public void resolveNested() throws Exception {
PMML pmml = ResourceUtil.unmarshal(NestedSegmentationTest.class);
FieldDependencyResolver resolver = new FieldDependencyResolver();
resolver.applyTo(pmml);
final
Map<Field, Set<Field>> dependencies = resolver.getDependencies();
Visitor visitor = new AbstractVisitor(){
@Override
public VisitorAction visit(DerivedField derivedField){
Set<Field> fields = dependencies.get(derivedField);
FieldName name = derivedField.getName();
if("x12".equals(name.getValue())){
checkFields(FieldNameUtil.create("x1", "x2"), fields);
} else
if("x123".equals(name.getValue())){
checkFields(FieldNameUtil.create("x12", "x3"), fields);
} else
if("x1234".equals(name.getValue())){
checkFields(FieldNameUtil.create("x123", "x4"), fields);
} else
if("x12345".equals(name.getValue())){
checkFields(FieldNameUtil.create("x1234", "x5"), fields);
} else
{
throw new AssertionError();
}
return super.visit(derivedField);
}
};
visitor.applyTo(pmml);
}
示例5: addDerivedField
import org.dmg.pmml.DerivedField; //导入方法依赖的package包/类
public void addDerivedField(DerivedField derivedField){
FieldName name = derivedField.getName();
checkName(name);
this.derivedFields.put(name, derivedField);
}