Java Code Examples for org.jpmml.converter.ContinuousFeature#toContinuousFeature()
The following examples show how to use
org.jpmml.converter.ContinuousFeature#toContinuousFeature() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Learner.java From jpmml-xgboost with GNU Affero General Public License v3.0 | 5 votes |
public Schema toXGBoostSchema(Schema schema){ Function<Feature, Feature> function = new Function<Feature, Feature>(){ @Override public Feature apply(Feature feature){ if(feature instanceof BinaryFeature){ BinaryFeature binaryFeature = (BinaryFeature)feature; return binaryFeature; } else { ContinuousFeature continuousFeature = feature.toContinuousFeature(); DataType dataType = continuousFeature.getDataType(); switch(dataType){ case INTEGER: case FLOAT: break; case DOUBLE: continuousFeature = continuousFeature.toContinuousFeature(DataType.FLOAT); break; default: throw new IllegalArgumentException("Expected integer, float or double data type, got " + dataType.value() + " data type"); } return continuousFeature; } } }; return schema.toTransformedSchema(function); }
Example 2
Source File: TensorFlowEncoder.java From jpmml-tensorflow with GNU Affero General Public License v3.0 | 4 votes |
public ContinuousFeature createContinuousFeature(SavedModel savedModel, NodeDef placeholder){ NodeDef cast = null; if(("Cast").equals(placeholder.getOp())){ cast = placeholder; placeholder = savedModel.getNodeDef(placeholder.getInput(0)); } DataField dataField = ensureContinuousDataField(savedModel, placeholder); ContinuousFeature result = new ContinuousFeature(this, dataField); if(cast != null){ Operation operation = savedModel.getOperation(cast.getName()); Output output = operation.output(0); result = result.toContinuousFeature(TypeUtil.getDataType(output)); } return result; }