Package org.kie.pmml.compiler.api.utils
Class ModelUtils
java.lang.Object
org.kie.pmml.compiler.api.utils.ModelUtils
Class to provide common methods to interact with
Model, to convert org.dmn.pmml objects to
Kie ones, etc...-
Method Summary
Modifier and TypeMethodDescriptionconvertDataFieldIntervals(List<org.dmg.pmml.Interval> toConvert) convertDataFieldValues(List<org.dmg.pmml.Value> toConvert) static MiningFieldconvertToKieMiningField(org.dmg.pmml.MiningField toConvert, org.dmg.pmml.Field<?> field) Return aorg.kie.pmml.api.models.MiningFieldout of aorg.dmg.pmml.MiningFieldand relativeorg.dmg.pmml.DataFieldonesstatic List<MiningField>convertToKieMiningFieldList(org.dmg.pmml.MiningSchema toConvert, List<org.dmg.pmml.Field<?>> fields) Return aList<org.kie.pmml.api.models.MiningField&glt;out of aorg.dmg.pmml .MiningSchemaonestatic OutputFieldconvertToKieOutputField(org.dmg.pmml.OutputField toConvert, org.dmg.pmml.Field<?> field) Return aorg.kie.pmml.api.models.OutputFieldout of aorg.dmg.pmml.OutputFieldonestatic List<OutputField>convertToKieOutputFieldList(List<org.dmg.pmml.OutputField> toConvert, List<org.dmg.pmml.Field<?>> fields) Return aList<org.kie.pmml.api.models.OutputField>out of aList<org.dmg.pmml.OutputField>onestatic List<OutputField>convertToKieOutputFieldList(org.dmg.pmml.Output toConvert, List<org.dmg.pmml.Field<?>> fields) Return aList<org.kie.pmml.api.models.OutputField>out of aorg.dmg.pmml .Outputonestatic TargetFieldconvertToKieTargetField(org.dmg.pmml.Target toConvert) Return aorg.kie.pmml.api.models.TargetFieldout of aorg.dmg.pmml.Targetstatic List<TargetField>convertToKieTargetFieldList(org.dmg.pmml.Targets toConvert) Return aList<org.kie.pmml.api.models.TargetField>out of aorg.dmg.pmml .Targetsstatic TargetValueconvertToKieTargetValue(org.dmg.pmml.TargetValue toConvert) Return aorg.kie.pmml.api.models.TargetValueout of aorg.dmg.pmml .TargetValuestatic List<TargetValue>convertToKieTargetValueList(List<org.dmg.pmml.TargetValue> toConvert) Return aList<org.kie.pmml.api.models.TargetValue>out of aList<org.dmg.pmml.TargetValue>static StringgetBoxedClassName(org.dmg.pmml.DataType dataType) Retrieve the mapped class name of the givenDataType, eventually boxed (for primitive ones).static StringgetBoxedClassName(org.dmg.pmml.ParameterField parameterField) Retrieve the mapped class name of the givenParameterField, eventually boxed (for primitive ones) It returns ObjectParameterField.getDataType()is nullstatic DATA_TYPEgetDATA_TYPE(List<org.dmg.pmml.Field<?>> fields, String fieldName) DATA_TYPEof the given fieldstatic org.dmg.pmml.DataTypegetDataType(List<org.dmg.pmml.Field<?>> fields, String fieldName) DataTypeof the given field, first looked upon derivedFields and then in dataDictionarystatic List<org.dmg.pmml.DerivedField>getDerivedFields(org.dmg.pmml.TransformationDictionary transformationDictionary, org.dmg.pmml.LocalTransformations localTransformations) ReturnList<DerivedField>s from the givenTransformationDictionaryandLocalTransformationsstatic List<org.dmg.pmml.Field<?>>getFieldsFromDataDictionaryAndTransformationDictionary(org.dmg.pmml.DataDictionary dataDictionary, org.dmg.pmml.TransformationDictionary transformationDictionary) static List<org.dmg.pmml.Field<?>>getFieldsFromDataDictionaryTransformationDictionaryAndModel(org.dmg.pmml.DataDictionary dataDictionary, org.dmg.pmml.TransformationDictionary transformationDictionary, org.dmg.pmml.Model model) getObjectsFromArray(org.dmg.pmml.Array source) static OP_TYPEOP_TYPEmay be defined insideDataField,MiningFieldor both.getOpTypeFromFields(List<org.dmg.pmml.Field<?>> fields, String fieldName) ReturnOptional<OP_TYPE>of field with given fieldName fromDataDictionarygetOpTypeFromMiningFields(org.dmg.pmml.MiningSchema miningSchema, String fieldName) ReturnOptional<OP_TYPE>of field with given fieldName fromMiningSchemagetOpTypeFromTargets(org.dmg.pmml.Targets targets, String fieldName) ReturnOptional<OP_TYPE>of field with given fieldName fromTargetsstatic StringgetPrefixedName(QName qName) getRowDataMap(org.dmg.pmml.Row source) getTargetFieldName(List<org.dmg.pmml.Field<?>> fields, org.dmg.pmml.Model model) Return anOptionalwith the name of the field whose usageType isTARGETorPREDICTEDstatic List<KiePMMLNameOpType>getTargetFields(List<org.dmg.pmml.Field<?>> fields, org.dmg.pmml.Model model) Return aList<KiePMMLNameOpType>of target fields Please note that only predicted/targetMiningFieldare considered.getTargetFieldsTypeMap(List<org.dmg.pmml.Field<?>> fields, org.dmg.pmml.Model model) Returns aMap<String, DATA_TYPE>of target fields, where the key is the name of the field, and the value is the type of the field Please note that only predicted/targetMiningFieldare considered.static DATA_TYPEgetTargetFieldType(List<org.dmg.pmml.Field<?>> fields, org.dmg.pmml.Model model) Return theDATA_TYPEof the field whose usageType isTARGETorPREDICTED.
-
Method Details
-
getTargetFieldName
public static Optional<String> getTargetFieldName(List<org.dmg.pmml.Field<?>> fields, org.dmg.pmml.Model model) Return anOptionalwith the name of the field whose usageType isTARGETorPREDICTEDWhile the xsd schema does not strictly enforce this, it seems that by convention majority of models has only one target.
(see https://github.com/jpmml/jpmml-evaluator/issues/64 discussion)
- Parameters:
fields-model-- Returns:
-
getTargetFieldType
public static DATA_TYPE getTargetFieldType(List<org.dmg.pmml.Field<?>> fields, org.dmg.pmml.Model model) Return theDATA_TYPEof the field whose usageType isTARGETorPREDICTED. It throws exception if none of such fields are foundWhile the xsd schema does not strictly enforce this, it seems that by convention majority of models has only one target.
(see https://github.com/jpmml/jpmml-evaluator/issues/64 discussion)
- Parameters:
fields-model-- Returns:
-
getTargetFields
public static List<KiePMMLNameOpType> getTargetFields(List<org.dmg.pmml.Field<?>> fields, org.dmg.pmml.Model model) Return aList<KiePMMLNameOpType>of target fields Please note that only predicted/targetMiningFieldare considered.- Parameters:
fields-model-- Returns:
-
getTargetFieldsTypeMap
public static Map<String,DATA_TYPE> getTargetFieldsTypeMap(List<org.dmg.pmml.Field<?>> fields, org.dmg.pmml.Model model) Returns aMap<String, DATA_TYPE>of target fields, where the key is the name of the field, and the value is the type of the field Please note that only predicted/targetMiningFieldare considered.- Parameters:
fields-model-- Returns:
-
getOpType
public static OP_TYPE getOpType(List<org.dmg.pmml.Field<?>> fields, org.dmg.pmml.Model model, String targetFieldName) OP_TYPEmay be defined insideDataField,MiningFieldor both. In the latter case,MiningFieldoverrideDataFielddefinition- Parameters:
fields-model-targetFieldName-- Returns:
-
getOpTypeFromFields
public static Optional<OP_TYPE> getOpTypeFromFields(List<org.dmg.pmml.Field<?>> fields, String fieldName) ReturnOptional<OP_TYPE>of field with given fieldName fromDataDictionary- Parameters:
fields-fieldName-- Returns:
-
getOpTypeFromMiningFields
public static Optional<OP_TYPE> getOpTypeFromMiningFields(org.dmg.pmml.MiningSchema miningSchema, String fieldName) ReturnOptional<OP_TYPE>of field with given fieldName fromMiningSchema- Parameters:
miningSchema-fieldName-- Returns:
-
getOpTypeFromTargets
public static Optional<OP_TYPE> getOpTypeFromTargets(org.dmg.pmml.Targets targets, String fieldName) ReturnOptional<OP_TYPE>of field with given fieldName fromTargets- Parameters:
targets-fieldName-- Returns:
-
getDataType
public static org.dmg.pmml.DataType getDataType(List<org.dmg.pmml.Field<?>> fields, String fieldName) DataTypeof the given field, first looked upon derivedFields and then in dataDictionary- Parameters:
fields-fieldName-- Returns:
-
getDATA_TYPE
DATA_TYPEof the given field- Parameters:
fields-fieldName-- Returns:
-
getDerivedFields
public static List<org.dmg.pmml.DerivedField> getDerivedFields(org.dmg.pmml.TransformationDictionary transformationDictionary, org.dmg.pmml.LocalTransformations localTransformations) ReturnList<DerivedField>s from the givenTransformationDictionaryandLocalTransformations- Parameters:
transformationDictionary-localTransformations-- Returns:
-
getObjectsFromArray
-
convertToKieMiningFieldList
public static List<MiningField> convertToKieMiningFieldList(org.dmg.pmml.MiningSchema toConvert, List<org.dmg.pmml.Field<?>> fields) Return aList<org.kie.pmml.api.models.MiningField&glt;out of aorg.dmg.pmml .MiningSchemaone- Parameters:
toConvert-fields-- Returns:
-
convertToKieMiningField
public static MiningField convertToKieMiningField(org.dmg.pmml.MiningField toConvert, org.dmg.pmml.Field<?> field) Return aorg.kie.pmml.api.models.MiningFieldout of aorg.dmg.pmml.MiningFieldand relativeorg.dmg.pmml.DataFieldones- Parameters:
toConvert-field-- Returns:
-
convertToKieOutputFieldList
public static List<OutputField> convertToKieOutputFieldList(org.dmg.pmml.Output toConvert, List<org.dmg.pmml.Field<?>> fields) Return aList<org.kie.pmml.api.models.OutputField>out of aorg.dmg.pmml .Outputone- Parameters:
toConvert-- Returns:
-
convertToKieOutputFieldList
public static List<OutputField> convertToKieOutputFieldList(List<org.dmg.pmml.OutputField> toConvert, List<org.dmg.pmml.Field<?>> fields) Return aList<org.kie.pmml.api.models.OutputField>out of aList<org.dmg.pmml.OutputField>one- Parameters:
toConvert-- Returns:
-
convertToKieOutputField
public static OutputField convertToKieOutputField(org.dmg.pmml.OutputField toConvert, org.dmg.pmml.Field<?> field) Return aorg.kie.pmml.api.models.OutputFieldout of aorg.dmg.pmml.OutputFieldone- Parameters:
toConvert-field- - this may benull- Returns:
-
convertToKieTargetFieldList
Return aList<org.kie.pmml.api.models.TargetField>out of aorg.dmg.pmml .Targets- Parameters:
toConvert-- Returns:
-
convertToKieTargetField
Return aorg.kie.pmml.api.models.TargetFieldout of aorg.dmg.pmml.Target- Parameters:
toConvert-- Returns:
-
convertToKieTargetValueList
public static List<TargetValue> convertToKieTargetValueList(List<org.dmg.pmml.TargetValue> toConvert) Return aList<org.kie.pmml.api.models.TargetValue>out of aList<org.dmg.pmml.TargetValue>- Parameters:
toConvert-- Returns:
-
convertToKieTargetValue
Return aorg.kie.pmml.api.models.TargetValueout of aorg.dmg.pmml .TargetValue- Parameters:
toConvert-- Returns:
-
getBoxedClassName
Retrieve the mapped class name of the givenParameterField, eventually boxed (for primitive ones) It returns ObjectParameterField.getDataType()is null- Parameters:
parameterField-- Returns:
-
getBoxedClassName
Retrieve the mapped class name of the givenDataType, eventually boxed (for primitive ones). It returns Object if null- Parameters:
dataType-- Returns:
-
getFieldsFromDataDictionaryAndTransformationDictionary
public static List<org.dmg.pmml.Field<?>> getFieldsFromDataDictionaryAndTransformationDictionary(org.dmg.pmml.DataDictionary dataDictionary, org.dmg.pmml.TransformationDictionary transformationDictionary) -
getFieldsFromDataDictionaryTransformationDictionaryAndModel
public static List<org.dmg.pmml.Field<?>> getFieldsFromDataDictionaryTransformationDictionaryAndModel(org.dmg.pmml.DataDictionary dataDictionary, org.dmg.pmml.TransformationDictionary transformationDictionary, org.dmg.pmml.Model model) -
convertDataFieldValues
-
convertDataFieldIntervals
-
getRowDataMap
-
getPrefixedName
-