use of org.kie.api.definition.type.FactType in project drools by kiegroup.
the class DiscretizeFieldsTest method testDiscretize.
@Test
public void testDiscretize() throws Exception {
FactType age = getKbase().getFactType(packageName, "Age");
FactType cat = getKbase().getFactType(packageName, "AgeCategories");
assertNotNull(getKSession().getEntryPoint("in_Age"));
getKSession().getEntryPoint("in_Age").insert(-1);
getKSession().fireAllRules();
checkFirstDataFieldOfTypeStatus(age, true, true, null, -1);
checkFirstDataFieldOfTypeStatus(cat, true, false, null, "infant");
this.refreshKSession();
getKSession().getEntryPoint("in_Age").insert(1);
getKSession().fireAllRules();
checkFirstDataFieldOfTypeStatus(age, true, false, null, 1);
checkFirstDataFieldOfTypeStatus(cat, true, false, null, "infant");
this.refreshKSession();
getKSession().getEntryPoint("in_Age").insert(9);
getKSession().fireAllRules();
checkFirstDataFieldOfTypeStatus(age, true, false, null, 9);
checkFirstDataFieldOfTypeStatus(cat, true, false, null, "young");
this.refreshKSession();
getKSession().getEntryPoint("in_Age").insert(30);
getKSession().fireAllRules();
checkFirstDataFieldOfTypeStatus(age, true, false, null, 30);
checkFirstDataFieldOfTypeStatus(cat, true, false, null, "mature");
this.refreshKSession();
getKSession().getEntryPoint("in_Age").insert(90);
getKSession().fireAllRules();
checkFirstDataFieldOfTypeStatus(age, true, false, null, 90);
checkFirstDataFieldOfTypeStatus(cat, true, false, null, "ancient");
this.refreshKSession();
getKSession().getEntryPoint("in_Age").insert(3000);
getKSession().fireAllRules();
checkFirstDataFieldOfTypeStatus(age, true, false, null, 3000);
checkFirstDataFieldOfTypeStatus(cat, true, false, null, "ancient");
this.refreshKSession();
getKSession().getEntryPoint("in_Age").insert(19);
getKSession().fireAllRules();
checkFirstDataFieldOfTypeStatus(age, true, false, null, 19);
checkFirstDataFieldOfTypeStatus(cat, true, false, null, "ancient");
checkGeneratedRules();
}
use of org.kie.api.definition.type.FactType in project drools by kiegroup.
the class LinearNormalizedFieldsTest method testDerivedTypesLinearNormInterpolation.
@Test
public void testDerivedTypesLinearNormInterpolation() throws Exception {
// new PMML4Wrapper().getPmml().getTransformationDictionary().getDerivedField().get(0).getNormContinuous().getOutliers().value()
FactType age = getKbase().getFactType(packageName, "Age");
FactType age1 = getKbase().getFactType(packageName, "Age_norm");
getKSession().getEntryPoint("in_Age").insert(30);
getKSession().fireAllRules();
checkFirstDataFieldOfTypeStatus(age, true, false, null, 30);
checkFirstDataFieldOfTypeStatus(age1, true, false, null, 0.375);
refreshKSession();
getKSession().getEntryPoint("in_Age").insert(90);
getKSession().fireAllRules();
checkFirstDataFieldOfTypeStatus(age, true, false, null, 90);
checkFirstDataFieldOfTypeStatus(age1, true, false, null, 1.5);
checkGeneratedRules();
}
use of org.kie.api.definition.type.FactType in project drools by kiegroup.
the class LinearNormalizedFieldsTest method testDerivedTypesLinearNormMapMissing.
@Test
public void testDerivedTypesLinearNormMapMissing() throws Exception {
// new PMML4Wrapper().getPmml().getTransformationDictionary().getDerivedField().get(0).getNormContinuous().getOutliers().value()
FactType age = getKbase().getFactType(packageName, "Age");
FactType age1 = getKbase().getFactType(packageName, "Age_norm");
FactType age2 = getKbase().getFactType(packageName, "Age_norm2");
FactType age3 = getKbase().getFactType(packageName, "Age_norm3");
assertNotNull(getKSession().getEntryPoint("in_Age"));
assertNull(getKSession().getEntryPoint("in_Age_mis"));
assertNull(getKSession().getEntryPoint("in_Age_norm"));
// value is "missing" for age, so should be mapped by the mapMissingTo policy
getKSession().getEntryPoint("in_Age").insert(-1);
getKSession().fireAllRules();
checkFirstDataFieldOfTypeStatus(age, true, true, null, -1);
checkFirstDataFieldOfTypeStatus(age1, true, false, null, 0.0);
checkFirstDataFieldOfTypeStatus(age2, true, false, null, -931.0);
checkFirstDataFieldOfTypeStatus(age3, true, false, null, 789.0);
checkGeneratedRules();
}
use of org.kie.api.definition.type.FactType in project drools by kiegroup.
the class NormDiscreteFieldsTest method testNormDiscrete.
@Test
public void testNormDiscrete() throws Exception {
FactType fld = getKbase().getFactType(packageName, "CatField");
FactType val1 = getKbase().getFactType(packageName, "IsValue1");
FactType val2 = getKbase().getFactType(packageName, "IsValue2");
assertNotNull(getKSession().getEntryPoint("in_CatField"));
// value is "missing" for age, so should be mapped by the mapMissingTo policy
getKSession().getEntryPoint("in_CatField").insert("Value1");
getKSession().fireAllRules();
checkFirstDataFieldOfTypeStatus(fld, true, false, null, "Value1");
checkFirstDataFieldOfTypeStatus(val1, true, false, null, 1.0);
checkFirstDataFieldOfTypeStatus(val2, true, false, null, 0.0);
refreshKSession();
getKSession().getEntryPoint("in_CatField").insert("Value2");
getKSession().fireAllRules();
checkFirstDataFieldOfTypeStatus(fld, true, false, null, "Value2");
checkFirstDataFieldOfTypeStatus(val1, true, false, null, 0.0);
checkFirstDataFieldOfTypeStatus(val2, true, false, null, 1.0);
refreshKSession();
getKSession().getEntryPoint("in_CatField").insert("Value3");
getKSession().fireAllRules();
checkFirstDataFieldOfTypeStatus(fld, true, false, null, "Value3");
checkFirstDataFieldOfTypeStatus(val1, true, false, null, 0.0);
checkFirstDataFieldOfTypeStatus(val2, true, false, null, 0.0);
refreshKSession();
getKSession().getEntryPoint("in_CatField").insert("Value0");
getKSession().fireAllRules();
checkFirstDataFieldOfTypeStatus(fld, false, true, null, "Value0");
checkFirstDataFieldOfTypeStatus(val1, true, false, null, 2.0);
checkFirstDataFieldOfTypeStatus(val2, true, false, null, 2.0);
refreshKSession();
checkGeneratedRules();
}
use of org.kie.api.definition.type.FactType in project drools by kiegroup.
the class UserDefinedFunctionsTest method testFunctionsNested.
@Test
public void testFunctionsNested() throws Exception {
setKSession(getModelSession(source1, VERBOSE));
setKbase(getKSession().getKieBase());
FactType userAge1 = getKbase().getFactType(packageName, "UserAge");
getKSession().getEntryPoint("in_Age").insert(10.0);
getKSession().fireAllRules();
System.out.println(reportWMObjects(getKSession()));
checkFirstDataFieldOfTypeStatus(userAge1, true, false, null, 130.0);
checkGeneratedRules();
}
Aggregations