use of org.kie.pmml.api.enums.OP_TYPE in project drools by kiegroup.
the class KiePMMLLoadedModelUtilsTest method getOpTypeFromDataFieldExisting.
@Test
public void getOpTypeFromDataFieldExisting() throws Exception {
pmmlModel = KiePMMLUtil.load(getFileInputStream(NO_TARGET_SOURCE), NO_TARGET_SOURCE);
final OP_TYPE retrieved = getOpType(getFieldsFromDataDictionary(pmmlModel.getDataDictionary()), pmmlModel.getModels().get(0), TEMPERATURE_FIELD);
assertNotNull(retrieved);
assertEquals(CONTINUOUS, retrieved);
}
use of org.kie.pmml.api.enums.OP_TYPE in project drools by kiegroup.
the class KiePMMLLoadedModelUtilsTest method getOpTypeFromMiningFieldExisting.
@Test
public void getOpTypeFromMiningFieldExisting() throws Exception {
pmmlModel = KiePMMLUtil.load(getFileInputStream(ONE_MINING_TARGET_SOURCE), ONE_MINING_TARGET_SOURCE);
final OP_TYPE retrieved = getOpType(getFieldsFromDataDictionary(pmmlModel.getDataDictionary()), pmmlModel.getModels().get(0), OUTLOOK_FIELD);
assertNotNull(retrieved);
assertEquals(CATEGORICAL, retrieved);
}
use of org.kie.pmml.api.enums.OP_TYPE in project drools by kiegroup.
the class RegressionModelImplementationProvider method validateClassification.
private void validateClassification(final List<Field<?>> fields, final RegressionModel toValidate) {
final String categoricalTargeName = getCategoricalTargetName(fields, toValidate);
final OP_TYPE opType = getOpType(fields, toValidate, categoricalTargeName);
switch(opType) {
case CATEGORICAL:
validateClassificationCategorical(fields, toValidate, categoricalTargeName);
break;
case ORDINAL:
validateClassificationOrdinal(toValidate);
break;
default:
throw new KiePMMLException("Invalid target type " + opType);
}
}
use of org.kie.pmml.api.enums.OP_TYPE in project drools by kiegroup.
the class InstanceFactoriesTestCommon method commonVerifyKiePMMLDefineFunction.
static void commonVerifyKiePMMLDefineFunction(KiePMMLDefineFunction toVerify, DefineFunction source) {
assertNotNull(toVerify);
assertEquals(source.getName(), toVerify.getName());
DATA_TYPE expectedDataType = DATA_TYPE.byName(source.getDataType().value());
assertEquals(expectedDataType, toVerify.getDataType());
OP_TYPE expectedOpType = OP_TYPE.byName(source.getOpType().value());
assertEquals(expectedOpType, toVerify.getOpType());
commonVerifyKiePMMLExpression(toVerify.getKiePMMLExpression(), source.getExpression());
List<ParameterField> sourcesParameterFields = source.getParameterFields();
List<KiePMMLParameterField> toVerifyList = toVerify.getParameterFields();
assertEquals(sourcesParameterFields.size(), toVerifyList.size());
sourcesParameterFields.forEach(paramSource -> {
Optional<KiePMMLParameterField> parameterToVerify = toVerifyList.stream().filter(param -> param.getName().equals(paramSource.getName().getValue())).findFirst();
assertTrue(parameterToVerify.isPresent());
commonVerifyKiePMMLParameterField(parameterToVerify.get(), paramSource);
});
}
use of org.kie.pmml.api.enums.OP_TYPE in project drools by kiegroup.
the class InstanceFactoriesTestCommon method commonVerifyKiePMMLDerivedField.
static void commonVerifyKiePMMLDerivedField(KiePMMLDerivedField toVerify, DerivedField source) {
assertNotNull(toVerify);
assertEquals(source.getName().getValue(), toVerify.getName());
DATA_TYPE expectedDataType = DATA_TYPE.byName(source.getDataType().value());
assertEquals(expectedDataType, toVerify.getDataType());
OP_TYPE expectedOpType = OP_TYPE.byName(source.getOpType().value());
assertEquals(expectedOpType, toVerify.getOpType());
String expectedDisplayName = "Display-" + source.getName().getValue();
assertEquals(expectedDisplayName, toVerify.getDisplayName());
commonVerifyKiePMMLExpression(toVerify.getKiePMMLExpression(), source.getExpression());
}
Aggregations