本文整理汇总了Java中org.dmg.pmml.DerivedField.getExpression方法的典型用法代码示例。如果您正苦于以下问题:Java DerivedField.getExpression方法的具体用法?Java DerivedField.getExpression怎么用?Java DerivedField.getExpression使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.dmg.pmml.DerivedField
的用法示例。
在下文中一共展示了DerivedField.getExpression方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fillPreProcessingSteps
import org.dmg.pmml.DerivedField; //导入方法依赖的package包/类
protected void fillPreProcessingSteps(DerivedField[] derivedFields) {
int derivedFieldIndex = derivedFields.length - 1;
// don't start at the beginning, we might have a pre processing step there already from the mining field
for (int preProcessingStepIndex = preProcessingSteps.length - derivedFields.length; preProcessingStepIndex < preProcessingSteps
.length;
preProcessingStepIndex++) {
DerivedField derivedField = derivedFields[derivedFieldIndex];
if (derivedField.getExpression() != null) {
handleExpression(preProcessingStepIndex, derivedField);
} else {
throw new UnsupportedOperationException("So far only Apply implemented.");
}
derivedFieldIndex--;
}
}
示例2: handleExpression
import org.dmg.pmml.DerivedField; //导入方法依赖的package包/类
private void handleExpression(int preProcessingStepIndex, DerivedField derivedField) {
if (derivedField.getExpression() instanceof Apply) {
for (Expression expression : ((Apply) derivedField.getExpression()).getExpressions()) {
if (expression instanceof Apply) {
if (((Apply) expression).getFunction().equals("isMissing")) {
// now find the value that is supposed to replace the missing value
for (Expression expression2 : ((Apply) derivedField.getExpression()).getExpressions()) {
if (expression2 instanceof Constant) {
String missingValue = ((Constant) expression2).getValue();
preProcessingSteps[preProcessingStepIndex] = new MissingValuePreProcess(derivedField, missingValue);
break;
}
}
} else {
throw new UnsupportedOperationException("So far only if isMissing implemented.");
}
}
}
} else if (derivedField.getExpression() instanceof NormContinuous) {
preProcessingSteps[preProcessingStepIndex] = new NormContinousPreProcess((NormContinuous) derivedField
.getExpression(), derivedField.getName().getValue());
} else {
throw new UnsupportedOperationException("So far only Apply expression implemented.");
}
}
示例3: getReferencedFieldName
import org.dmg.pmml.DerivedField; //导入方法依赖的package包/类
private static String getReferencedFieldName(DerivedField derivedField) {
String referencedField = null;
if (derivedField.getExpression() != null) {
if (derivedField.getExpression() instanceof Apply) {
// TODO throw uoe in case the function is not "if missing" - much more to implement!
for (Expression expression : ((Apply) derivedField.getExpression()).getExpressions()) {
if (expression instanceof FieldRef) {
referencedField = ((FieldRef) expression).getField().getValue();
}
}
} else if (derivedField.getExpression() instanceof NormContinuous) {
referencedField = ((NormContinuous) derivedField.getExpression()).getField().getValue();
} else {
throw new UnsupportedOperationException("So far only Apply expression implemented.");
}
} else {
// there is a million ways in which derived fields can reference other fields.
// need to implement them all!
throw new UnsupportedOperationException("So far only implemented if function for derived fields.");
}
if (referencedField == null) {
throw new UnsupportedOperationException("could not find raw field name. Maybe this derived field references another derived " +
"field? Did not implement that yet.");
}
return referencedField;
}
示例4: assertTransformedFeature
import org.dmg.pmml.DerivedField; //导入方法依赖的package包/类
void assertTransformedFeature(Transformer transformer, String function){
SkLearnEncoder encoder = new SkLearnEncoder();
DataField dataField = encoder.createDataField(FieldName.create("x"));
Feature inputFeature = new WildcardFeature(encoder, dataField);
Feature outputFeature = Iterables.getOnlyElement(transformer.encodeFeatures(Collections.singletonList(inputFeature), encoder));
assertNotSame(inputFeature, outputFeature);
DerivedField derivedField = (DerivedField)encoder.getField(outputFeature.getName());
Apply apply = (Apply)derivedField.getExpression();
assertEquals(function, apply.getFunction());
}