use of org.dmg.pmml.OpType in project drools by kiegroup.
the class KiePMMLUtil method getTargetDataField.
/**
* Returns a model-specific <b>target</b> <code>DataField</code>
* @param model
* @return
*/
static Optional<DataField> getTargetDataField(final Model model) {
DataType targetDataType = getTargetDataType(model.getMiningFunction(), model.getMathContext());
OpType targetOpType = getTargetOpType(model.getMiningFunction());
if (targetDataType == null || targetOpType == null) {
return Optional.empty();
}
String cleanedName = model.getModelName().replaceAll("[^A-Za-z0-9]", "");
String fieldName = String.format(TARGETFIELD_TEMPLATE, cleanedName);
DataField toReturn = new DataField();
toReturn.setName(FieldName.create(fieldName));
toReturn.setOpType(targetOpType);
toReturn.setDataType(targetDataType);
return Optional.of(toReturn);
}
use of org.dmg.pmml.OpType in project drools by kiegroup.
the class KiePMMLUtilTest method getTargetOpType.
@Test
public void getTargetOpType() {
MiningFunction miningFunction = MiningFunction.REGRESSION;
OpType retrieved = KiePMMLUtil.getTargetOpType(miningFunction);
assertEquals(OpType.CONTINUOUS, retrieved);
miningFunction = MiningFunction.CLASSIFICATION;
retrieved = KiePMMLUtil.getTargetOpType(miningFunction);
assertEquals(OpType.CATEGORICAL, retrieved);
miningFunction = MiningFunction.CLUSTERING;
retrieved = KiePMMLUtil.getTargetOpType(miningFunction);
assertEquals(OpType.CATEGORICAL, retrieved);
List<MiningFunction> notMappedMiningFunctions = Arrays.asList(MiningFunction.ASSOCIATION_RULES, MiningFunction.MIXED, MiningFunction.SEQUENCES, MiningFunction.TIME_SERIES);
notMappedMiningFunctions.forEach(minFun -> assertNull(KiePMMLUtil.getTargetOpType(minFun)));
}
use of org.dmg.pmml.OpType in project drools by kiegroup.
the class RegressionCompilationDTO method isRegression.
public boolean isRegression() {
final DataField targetDataField = getTargetDataField();
final OpType targetOpType = targetDataField != null ? targetDataField.getOpType() : null;
return Objects.equals(MiningFunction.REGRESSION, getMiningFunction()) && (targetDataField == null || Objects.equals(OpType.CONTINUOUS, targetOpType));
}
use of org.dmg.pmml.OpType in project knime-core by knime.
the class PMMLStringConversionTranslator method createDerivedFields.
private DerivedField[] createDerivedFields() {
DATATYPE.Enum dataType = PMMLDataDictionaryTranslator.getPMMLDataType(m_parseType);
OPTYPE.Enum optype = PMMLDataDictionaryTranslator.getOptype(m_parseType);
int num = m_includeCols.size();
DerivedField[] derivedFields = new DerivedField[num];
for (int i = 0; i < num; i++) {
DerivedField df = DerivedField.Factory.newInstance();
String name = m_includeCols.get(i);
df.setDisplayName(name);
/* The field name must be retrieved before creating a new derived
* name for this derived field as the map only contains the
* current mapping. */
String fieldName = m_mapper.getDerivedFieldName(name);
df.setName(m_mapper.createDerivedFieldName(name));
df.setDataType(dataType);
df.setOptype(optype);
FieldRef fieldRef = df.addNewFieldRef();
fieldRef.setField(fieldName);
derivedFields[i] = df;
}
return derivedFields;
}
use of org.dmg.pmml.OpType in project knime-core by knime.
the class PMMLStringConversionTranslator method createDerivedFields.
private DerivedField[] createDerivedFields() {
DATATYPE.Enum dataType = PMMLDataDictionaryTranslator.getPMMLDataType(m_parseType);
OPTYPE.Enum optype = PMMLDataDictionaryTranslator.getOptype(m_parseType);
int num = m_includeCols.size();
DerivedField[] derivedFields = new DerivedField[num];
for (int i = 0; i < num; i++) {
DerivedField df = DerivedField.Factory.newInstance();
String name = m_includeCols.get(i);
df.setDisplayName(name);
/* The field name must be retrieved before creating a new derived
* name for this derived field as the map only contains the
* current mapping. */
String fieldName = m_mapper.getDerivedFieldName(name);
df.setName(m_mapper.createDerivedFieldName(name));
df.setDataType(dataType);
df.setOptype(optype);
FieldRef fieldRef = df.addNewFieldRef();
fieldRef.setField(fieldName);
derivedFields[i] = df;
}
return derivedFields;
}
Aggregations