use of org.dmg.pmml.tree.TreeModel in project drools by kiegroup.
the class TreeModelImplementationProviderTest method getKiePMMLModel.
@Test
public void getKiePMMLModel() {
TreeModel treeModel = (TreeModel) pmml.getModels().get(0);
final CommonCompilationDTO<TreeModel> compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml, treeModel, new HasClassLoaderMock());
final KiePMMLTreeModel retrieved = PROVIDER.getKiePMMLModel(compilationDTO);
assertNotNull(retrieved);
assertTrue(retrieved instanceof Serializable);
}
use of org.dmg.pmml.tree.TreeModel in project drools by kiegroup.
the class KiePMMLTreeModelFactoryTest method getKiePMMLTreeModel.
@Test
public void getKiePMMLTreeModel() {
CommonCompilationDTO<TreeModel> source = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml1, treeModel1, new HasClassLoaderMock());
KiePMMLTreeModel retrieved = KiePMMLTreeModelFactory.getKiePMMLTreeModel(TreeCompilationDTO.fromCompilationDTO(source));
assertNotNull(retrieved);
source = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml2, treeModel2, new HasClassLoaderMock());
retrieved = KiePMMLTreeModelFactory.getKiePMMLTreeModel(TreeCompilationDTO.fromCompilationDTO(source));
assertNotNull(retrieved);
}
use of org.dmg.pmml.tree.TreeModel in project drools by kiegroup.
the class KiePMMLTreeModelFactoryTest method getKiePMMLTreeModelSourcesMap.
@Test
public void getKiePMMLTreeModelSourcesMap() {
CommonCompilationDTO<TreeModel> source = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml1, treeModel1, new HasClassLoaderMock());
Map<String, String> retrieved = KiePMMLTreeModelFactory.getKiePMMLTreeModelSourcesMap(TreeCompilationDTO.fromCompilationDTO(source));
assertNotNull(retrieved);
source = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml2, treeModel2, new HasClassLoaderMock());
retrieved = KiePMMLTreeModelFactory.getKiePMMLTreeModelSourcesMap(TreeCompilationDTO.fromCompilationDTO(source));
assertNotNull(retrieved);
}
use of org.dmg.pmml.tree.TreeModel in project jpmml-r by jpmml.
the class GBMConverter method encodeTreeModel.
private TreeModel encodeTreeModel(MiningFunction miningFunction, RGenericVector tree, RGenericVector c_splits, Schema schema) {
Node root = encodeNode(0, True.INSTANCE, tree, c_splits, new FlagManager(), new CategoryManager(), schema);
TreeModel treeModel = new TreeModel(miningFunction, ModelUtil.createMiningSchema(schema.getLabel()), root).setSplitCharacteristic(TreeModel.SplitCharacteristic.MULTI_SPLIT);
return treeModel;
}
use of org.dmg.pmml.tree.TreeModel in project jpmml-r by jpmml.
the class GBMConverter method encodeModel.
@Override
public MiningModel encodeModel(Schema schema) {
RGenericVector gbm = getObject();
RDoubleVector initF = gbm.getDoubleElement("initF");
RGenericVector trees = gbm.getGenericElement("trees");
RGenericVector c_splits = gbm.getGenericElement("c.splits");
RGenericVector distribution = gbm.getGenericElement("distribution");
RStringVector distributionName = distribution.getStringElement("name");
Schema segmentSchema = schema.toAnonymousRegressorSchema(DataType.DOUBLE);
List<TreeModel> treeModels = new ArrayList<>();
for (int i = 0; i < trees.size(); i++) {
RGenericVector tree = trees.getGenericValue(i);
TreeModel treeModel = encodeTreeModel(MiningFunction.REGRESSION, tree, c_splits, segmentSchema);
treeModels.add(treeModel);
}
MiningModel miningModel = encodeMiningModel(distributionName, treeModels, initF.asScalar(), schema);
return miningModel;
}
Aggregations