本文整理汇总了Java中org.dmg.pmml.OutputField类的典型用法代码示例。如果您正苦于以下问题:Java OutputField类的具体用法?Java OutputField怎么用?Java OutputField使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OutputField类属于org.dmg.pmml包,在下文中一共展示了OutputField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doGetOutputFieldsForPMMLStream
import org.dmg.pmml.OutputField; //导入依赖的package包/类
private List<MLModelField> doGetOutputFieldsForPMMLStream(String pmmlContents) throws SAXException, JAXBException {
List<MLModelField> fieldNames = new ArrayList<>();
PMMLManager pmmlManager = new PMMLManager(IOUtil.unmarshal(new ByteArrayInputStream(pmmlContents.getBytes())));
Evaluator modelEvaluator = (ModelEvaluator<?>) pmmlManager.getModelManager(null, ModelEvaluatorFactory.getInstance());
modelEvaluator.getPredictedFields().forEach((f) -> fieldNames.add(getModelField(modelEvaluator.getDataField(f))));
modelEvaluator.getOutputFields().forEach((f) -> {
OutputField outputField = modelEvaluator.getOutputField(f);
ResultFeatureType resultFeatureType = outputField.getFeature();
if (resultFeatureType != ResultFeatureType.PREDICTED_VALUE &&
resultFeatureType != ResultFeatureType.PREDICTED_DISPLAY_VALUE) {
fieldNames.add(getModelField(outputField));
}
});
return fieldNames;
}
示例2: doGetOutputFieldsForPMMLStream
import org.dmg.pmml.OutputField; //导入依赖的package包/类
private List<MLModelField> doGetOutputFieldsForPMMLStream(String pmmlContents) throws SAXException, JAXBException, UnsupportedEncodingException {
List<MLModelField> fieldNames = new ArrayList<>();
PMMLManager pmmlManager = new PMMLManager(IOUtil.unmarshal(new ByteArrayInputStream(pmmlContents.getBytes("UTF-8"))));
Evaluator modelEvaluator = (ModelEvaluator<?>) pmmlManager.getModelManager(null, ModelEvaluatorFactory.getInstance());
modelEvaluator.getPredictedFields().forEach((f) -> fieldNames.add(getModelField(modelEvaluator.getDataField(f))));
modelEvaluator.getOutputFields().forEach((f) -> {
OutputField outputField = modelEvaluator.getOutputField(f);
ResultFeatureType resultFeatureType = outputField.getFeature();
if (resultFeatureType != ResultFeatureType.PREDICTED_VALUE &&
resultFeatureType != ResultFeatureType.PREDICTED_DISPLAY_VALUE) {
fieldNames.add(getModelField(outputField));
}
});
return fieldNames;
}
示例3: registerOutputFields
import org.dmg.pmml.OutputField; //导入依赖的package包/类
@Override
public List<OutputField> registerOutputFields(Label label, SparkMLEncoder encoder){
T model = getTransformer();
String predictionCol = model.getPredictionCol();
OutputField predictedField = ModelUtil.createPredictedField(FieldName.create(predictionCol), DataType.STRING, OpType.CATEGORICAL);
Feature feature = new Feature(encoder, predictedField.getName(), predictedField.getDataType()){
@Override
public ContinuousFeature toContinuousFeature(){
throw new UnsupportedOperationException();
}
};
encoder.putOnlyFeature(predictionCol, feature);
return Collections.singletonList(predictedField);
}
示例4: registerOutputFields
import org.dmg.pmml.OutputField; //导入依赖的package包/类
@Override
public List<OutputField> registerOutputFields(Label label, SparkMLEncoder encoder){
List<OutputField> result = super.registerOutputFields(label, encoder);
MiningFunction miningFunction = getMiningFunction();
switch(miningFunction){
case CLASSIFICATION:
CategoricalLabel categoricalLabel = (CategoricalLabel)label;
result = new ArrayList<>(result);
result.addAll(ModelUtil.createProbabilityFields(DataType.DOUBLE, categoricalLabel.getValues()));
break;
default:
break;
}
return result;
}
示例5: createPredictedOutput
import org.dmg.pmml.OutputField; //导入依赖的package包/类
static
public Output createPredictedOutput(FieldName name, OpType opType, DataType dataType, Transformation... transformations){
List<OutputField> outputFields = new ArrayList<>();
OutputField outputField = new OutputField(name, dataType)
.setOpType(opType)
.setResultFeature(ResultFeature.PREDICTED_VALUE)
.setFinalResult(false);
outputFields.add(outputField);
for(Transformation transformation : transformations){
outputField = new OutputField(transformation.getName(outputField.getName()), transformation.getDataType(outputField.getDataType()))
.setOpType(transformation.getOpType(outputField.getOpType()))
.setResultFeature(ResultFeature.TRANSFORMED_VALUE)
.setFinalResult(transformation.isFinalResult())
.setExpression(transformation.createExpression(new FieldRef(outputField.getName())));
outputFields.add(outputField);
}
return new Output(outputFields);
}
示例6: toContinuousFeature
import org.dmg.pmml.OutputField; //导入依赖的package包/类
@Override
public ContinuousOutputFeature toContinuousFeature(){
PMMLEncoder encoder = ensureEncoder();
Output output = getOutput();
OutputField outputField = OutputUtil.getOutputField(output, getName());
DataType dataType = outputField.getDataType();
switch(dataType){
case INTEGER:
case FLOAT:
case DOUBLE:
break;
default:
throw new UnsupportedOperationException();
}
outputField.setOpType(OpType.CONTINUOUS);
return new ContinuousOutputFeature(encoder, output, outputField.getName(), outputField.getDataType());
}
示例7: getOutputField
import org.dmg.pmml.OutputField; //导入依赖的package包/类
static
public OutputField getOutputField(Output output, FieldName name){
if(output.hasOutputFields()){
List<OutputField> outputFields = output.getOutputFields();
for(OutputField outputField : outputFields){
if((name).equals(outputField.getName())){
return outputField;
}
}
}
return null;
}
示例8: visit
import org.dmg.pmml.OutputField; //导入依赖的package包/类
@Override
public VisitorAction visit(OutputField outputField){
ResultFeature resultFeature = outputField.getResultFeature();
switch(resultFeature){
case TRANSFORMED_VALUE:
case DECISION:
{
String segmentId = outputField.getSegmentId();
if(segmentId != null){
outputField.setValue(filter(outputField.getValue()));
}
}
break;
default:
break;
}
return super.visit(outputField);
}
示例9: resolveField
import org.dmg.pmml.OutputField; //导入依赖的package包/类
static
private Field resolveField(FieldName name, MiningModelEvaluationContext context){
while(context != null){
OutputField outputField = context.getOutputField(name);
if(outputField != null){
return outputField;
}
DerivedField localDerivedField = context.getLocalDerivedField(name);
if(localDerivedField != null){
return localDerivedField;
}
context = context.getParent();
}
return null;
}
示例10: getEntityId
import org.dmg.pmml.OutputField; //导入依赖的package包/类
static
private String getEntityId(Object object, OutputField outputField){
HasEntityId hasEntityId = TypeUtil.cast(HasEntityId.class, object);
int rank = outputField.getRank();
if(rank <= 0){
throw new InvalidAttributeException(outputField, PMMLAttributes.OUTPUTFIELD_RANK, rank);
} // End if
if(rank > 1){
HasEntityIdRanking hasEntityIdRanking = TypeUtil.cast(HasEntityIdRanking.class, object);
OutputField.RankOrder rankOrder = outputField.getRankOrder();
switch(rankOrder){
case DESCENDING:
break;
default:
throw new UnsupportedAttributeException(outputField, rankOrder);
}
return getElement(hasEntityIdRanking.getEntityIdRanking(), rank);
}
return hasEntityId.getEntityId();
}
示例11: registerOutputFields
import org.dmg.pmml.OutputField; //导入依赖的package包/类
@Override
public List<OutputField> registerOutputFields(Label label, SparkMLEncoder encoder){
MultilayerPerceptronClassificationModel model = getTransformer();
List<OutputField> result = super.registerOutputFields(label, encoder);
if(!(model instanceof HasProbabilityCol)){
CategoricalLabel categoricalLabel = (CategoricalLabel)label;
result = new ArrayList<>(result);
result.addAll(ModelUtil.createProbabilityFields(DataType.DOUBLE, categoricalLabel.getValues()));
}
return result;
}
示例12: createAffinityField
import org.dmg.pmml.OutputField; //导入依赖的package包/类
static
public OutputField createAffinityField(FieldName name, DataType dataType, String value){
OutputField outputField = new OutputField(name, dataType)
.setOpType(OpType.CONTINUOUS)
.setResultFeature(ResultFeature.AFFINITY)
.setValue(value);
return outputField;
}
示例13: createAffinityFields
import org.dmg.pmml.OutputField; //导入依赖的package包/类
static
public List<OutputField> createAffinityFields(final DataType dataType, List<? extends Entity> entities){
Function<Entity, OutputField> function = new Function<Entity, OutputField>(){
@Override
public OutputField apply(Entity entity){
return createAffinityField(dataType, entity.getId());
}
};
return Lists.newArrayList(Lists.transform(entities, function));
}
示例14: createEntityIdField
import org.dmg.pmml.OutputField; //导入依赖的package包/类
static
public OutputField createEntityIdField(FieldName name){
OutputField outputField = new OutputField(name, DataType.STRING)
.setOpType(OpType.CATEGORICAL)
.setResultFeature(ResultFeature.ENTITY_ID);
return outputField;
}
示例15: createPredictedField
import org.dmg.pmml.OutputField; //导入依赖的package包/类
static
public OutputField createPredictedField(FieldName name, DataType dataType, OpType opType){
OutputField outputField = new OutputField(name, dataType)
.setOpType(opType)
.setResultFeature(ResultFeature.PREDICTED_VALUE);
return outputField;
}