use of org.kie.api.definition.type.FactType in project drools by kiegroup.
the class NeuralNetworkTest method testIris.
@Test
public void testIris() throws Exception {
setKSession(getModelSession(source2, VERBOSE));
setKbase(getKSession().getKieBase());
// init model
getKSession().fireAllRules();
Assert.assertEquals(21, getNumAssertedSynapses());
getKSession().getEntryPoint("in_PetalLen").insert(2.2);
getKSession().getEntryPoint("in_PetalWid").insert(4.1);
getKSession().getEntryPoint("in_SepalLen").insert(2.3);
getKSession().getEntryPoint("in_SepalWid").insert(1.8);
getKSession().fireAllRules();
// System.err.println(reportWMObjects(getKSession()));
FactType t7 = getKbase().getFactType(packageName, "Test_MLP_7");
FactType t8 = getKbase().getFactType(packageName, "Test_MLP_8");
FactType t9 = getKbase().getFactType(packageName, "Test_MLP_9");
FactType s1 = getKbase().getFactType(packageName, "Cspecies_virginica");
Assert.assertEquals(0.001, truncN(getDoubleFieldValue(t7), 3), 1e-4);
Assert.assertEquals(0.282, truncN(getDoubleFieldValue(t8), 3), 1e-4);
Assert.assertEquals(0.716, truncN(getDoubleFieldValue(t9), 3), 1e-4);
// Assert.assertEquals("virginica",
// getFieldValue("Cspecies_virginica", "Test_MLP"));
// Assert.assertEquals("Test_setosa",
// getFieldValue("Cspecies_setosa", "Test_MLP"));
// Assert.assertEquals("Test_versicolor",
// getFieldValue("Cspecies_versicolor", "Test_MLP"));
checkFirstDataFieldOfTypeStatus(getKbase().getFactType(packageName, "SpecSetosa"), true, false, "Test_MLP", 0.001111);
checkFirstDataFieldOfTypeStatus(getKbase().getFactType(packageName, "SpecVirgin"), true, false, "Test_MLP", 0.716639);
checkFirstDataFieldOfTypeStatus(getKbase().getFactType(packageName, "SpecVersic"), true, false, "Test_MLP", 0.282249);
checkFirstDataFieldOfTypeStatus(getKbase().getFactType(packageName, "SpecOut"), true, false, "Test_MLP", "virginica");
checkGeneratedRules();
}
use of org.kie.api.definition.type.FactType in project drools by kiegroup.
the class NeuralNetworkTest method testOverride.
@Test
public void testOverride() throws Exception {
setKSession(getModelSession(source3, VERBOSE));
setKbase(getKSession().getKieBase());
getKSession().fireAllRules();
getKSession().getEntryPoint("in_Feat1").insert(2.2);
getKSession().fireAllRules();
getKSession().getEntryPoint("in_Feat2").insert(5);
getKSession().fireAllRules();
// System.err.println(reportWMObjects(getKSession()));
FactType out1 = getKbase().getFactType("org.kie.pmml.pmml_4_2.test", "Out1");
FactType out2 = getKbase().getFactType("org.kie.pmml.pmml_4_2.test", "Out2");
FactType nump = getKbase().getFactType("org.kie.pmml.pmml_4_2.test", "Feat2");
assertEquals(1, getKSession().getObjects(new ClassObjectFilter(out1.getFactClass())).size());
assertEquals(1, getKSession().getObjects(new ClassObjectFilter(out2.getFactClass())).size());
assertEquals(2, getKSession().getObjects(new ClassObjectFilter(nump.getFactClass())).size());
getKSession().getEntryPoint("in_Feat1").insert(2.5);
getKSession().getEntryPoint("in_Feat2").insert(6);
getKSession().fireAllRules();
// System.err.println(reportWMObjects(getKSession()));
assertEquals(1, getKSession().getObjects(new ClassObjectFilter(out1.getFactClass())).size());
assertEquals(1, getKSession().getObjects(new ClassObjectFilter(out2.getFactClass())).size());
assertEquals(2, getKSession().getObjects(new ClassObjectFilter(nump.getFactClass())).size());
checkGeneratedRules();
}
use of org.kie.api.definition.type.FactType in project drools by kiegroup.
the class UserDefinedFunctionsTest method testFunctions0Overwrite.
@Test
public void testFunctions0Overwrite() throws Exception {
setKSession(getModelSession(source0, VERBOSE));
setKbase(getKSession().getKieBase());
FactType userAge1 = getKbase().getFactType(packageName, "UserAge");
getKSession().getEntryPoint("in_Age").insert(8.4);
getKSession().fireAllRules();
getKSession().getEntryPoint("in_Age").insert(2.2);
getKSession().fireAllRules();
System.out.println(reportWMObjects(getKSession()));
checkFirstDataFieldOfTypeStatus(userAge1, true, false, null, 22.0);
checkGeneratedRules();
}
use of org.kie.api.definition.type.FactType in project drools by kiegroup.
the class UserDefinedFunctionsTest method testFunctions3.
@Test
public void testFunctions3() throws Exception {
setKSession(getModelSession(source3, VERBOSE));
setKbase(getKSession().getKieBase());
FactType userAge3 = getKbase().getFactType(packageName, "UserAge3");
getKSession().getEntryPoint("in_Age").insert(10);
getKSession().fireAllRules();
checkFirstDataFieldOfTypeStatus(userAge3, true, false, null, 10);
checkGeneratedRules();
}
use of org.kie.api.definition.type.FactType in project drools by kiegroup.
the class UserDefinedFunctionsTest method testFunctions1.
@Test
public void testFunctions1() throws Exception {
setKSession(getModelSession(source3, true));
setKbase(getKSession().getKieBase());
FactType userAge1 = getKbase().getFactType(packageName, "UserAge1");
getKSession().getEntryPoint("in_Age").insert(10);
getKSession().fireAllRules();
checkFirstDataFieldOfTypeStatus(userAge1, true, false, null, 22.0);
checkGeneratedRules();
}
Aggregations