use of org.dmg.pmml.pmml_4_2.descr.RegressionModel in project drools by kiegroup.
the class PMML4Compiler method checkBuildingResources.
private static KieBase checkBuildingResources(PMML pmml) throws IOException {
KieServices ks = KieServices.Factory.get();
KieContainer kieContainer = ks.getKieClasspathContainer();
if (registry == null) {
initRegistry();
}
String chosenKieBase = null;
for (Object o : pmml.getAssociationModelsAndBaselineModelsAndClusteringModels()) {
if (o instanceof NaiveBayesModel) {
if (!naiveBayesLoaded) {
for (String ntempl : NAIVE_BAYES_TEMPLATES) {
prepareTemplate(ntempl);
}
naiveBayesLoaded = true;
}
chosenKieBase = chosenKieBase == null ? "PMML-Bayes" : "PMML";
}
if (o instanceof NeuralNetwork) {
if (!neuralLoaded) {
for (String ntempl : NEURAL_TEMPLATES) {
prepareTemplate(ntempl);
}
neuralLoaded = true;
}
chosenKieBase = chosenKieBase == null ? "PMML-Neural" : "PMML";
}
if (o instanceof ClusteringModel) {
if (!clusteringLoaded) {
for (String ntempl : CLUSTERING_TEMPLATES) {
prepareTemplate(ntempl);
}
clusteringLoaded = true;
}
chosenKieBase = chosenKieBase == null ? "PMML-Cluster" : "PMML";
}
if (o instanceof SupportVectorMachineModel) {
if (!svmLoaded) {
for (String ntempl : SVM_TEMPLATES) {
prepareTemplate(ntempl);
}
svmLoaded = true;
}
chosenKieBase = chosenKieBase == null ? "PMML-SVM" : "PMML";
}
if (o instanceof TreeModel) {
if (!treeLoaded) {
for (String ntempl : TREE_TEMPLATES) {
prepareTemplate(ntempl);
}
treeLoaded = true;
}
chosenKieBase = chosenKieBase == null ? "PMML-Tree" : "PMML";
}
if (o instanceof RegressionModel) {
if (!simpleRegLoaded) {
for (String ntempl : SIMPLEREG_TEMPLATES) {
prepareTemplate(ntempl);
}
simpleRegLoaded = true;
}
chosenKieBase = chosenKieBase == null ? "PMML-Regression" : "PMML";
}
if (o instanceof Scorecard) {
if (!scorecardLoaded) {
for (String ntempl : SCORECARD_TEMPLATES) {
prepareTemplate(ntempl);
}
scorecardLoaded = true;
}
chosenKieBase = chosenKieBase == null ? "PMML-Scorecard" : "PMML";
}
}
if (chosenKieBase == null) {
chosenKieBase = "PMML-Base";
}
return kieContainer.getKieBase(chosenKieBase);
}
use of org.dmg.pmml.pmml_4_2.descr.RegressionModel in project drools by kiegroup.
the class PMML4Compiler method checkBuildingResources.
private static KieBase checkBuildingResources(PMML pmml) throws IOException {
KieServices ks = KieServices.Factory.get();
KieContainer kieContainer = ks.getKieClasspathContainer();
if (registry == null) {
initRegistry();
}
String chosenKieBase = null;
for (Object o : pmml.getAssociationModelsAndBaselineModelsAndClusteringModels()) {
if (o instanceof NaiveBayesModel) {
if (!naiveBayesLoaded) {
for (String ntempl : NAIVE_BAYES_TEMPLATES) {
prepareTemplate(ntempl);
}
naiveBayesLoaded = true;
}
chosenKieBase = chosenKieBase == null ? "KiePMML-Bayes" : "KiePMML";
}
if (o instanceof NeuralNetwork) {
if (!neuralLoaded) {
for (String ntempl : NEURAL_TEMPLATES) {
prepareTemplate(ntempl);
}
neuralLoaded = true;
}
chosenKieBase = chosenKieBase == null ? "KiePMML-Neural" : "KiePMML";
}
if (o instanceof ClusteringModel) {
if (!clusteringLoaded) {
for (String ntempl : CLUSTERING_TEMPLATES) {
prepareTemplate(ntempl);
}
clusteringLoaded = true;
}
chosenKieBase = chosenKieBase == null ? "KiePMML-Cluster" : "KiePMML";
}
if (o instanceof SupportVectorMachineModel) {
if (!svmLoaded) {
for (String ntempl : SVM_TEMPLATES) {
prepareTemplate(ntempl);
}
svmLoaded = true;
}
chosenKieBase = chosenKieBase == null ? "KiePMML-SVM" : "KiePMML";
}
if (o instanceof TreeModel) {
if (!treeLoaded) {
for (String ntempl : TREE_TEMPLATES) {
prepareTemplate(ntempl);
}
treeLoaded = true;
}
chosenKieBase = chosenKieBase == null ? "KiePMML-Tree" : "KiePMML";
}
if (o instanceof RegressionModel) {
if (!simpleRegLoaded) {
for (String ntempl : SIMPLEREG_TEMPLATES) {
prepareTemplate(ntempl);
}
simpleRegLoaded = true;
}
chosenKieBase = chosenKieBase == null ? "KiePMML-Regression" : "KiePMML";
}
if (o instanceof Scorecard) {
if (!scorecardLoaded) {
for (String ntempl : SCORECARD_TEMPLATES) {
prepareTemplate(ntempl);
}
scorecardLoaded = true;
}
chosenKieBase = chosenKieBase == null ? "KiePMML-Scorecard" : "KiePMML";
}
}
if (chosenKieBase == null) {
chosenKieBase = "KiePMML-Base";
}
return kieContainer.getKieBase(chosenKieBase);
}
use of org.dmg.pmml.pmml_4_2.descr.RegressionModel in project drools by kiegroup.
the class PMML4ModelFactory method getModels.
public List<PMML4Model> getModels(PMML4Unit owner) {
List<PMML4Model> pmml4Models = new ArrayList<>();
owner.getRawPMML().getAssociationModelsAndBaselineModelsAndClusteringModels().forEach(serializable -> {
if (serializable instanceof Scorecard) {
Scorecard sc = (Scorecard) serializable;
ScorecardModel model = new ScorecardModel(sc.getModelName(), sc, null, owner);
pmml4Models.add(model);
} else if (serializable instanceof RegressionModel) {
RegressionModel rm = (RegressionModel) serializable;
Regression model = new Regression(rm.getModelName(), rm, null, owner);
pmml4Models.add(model);
} else if (serializable instanceof TreeModel) {
TreeModel tm = (TreeModel) serializable;
Treemodel model = new Treemodel(tm.getModelName(), tm, null, owner);
pmml4Models.add(model);
} else if (serializable instanceof MiningModel) {
MiningModel mm = (MiningModel) serializable;
Miningmodel model = new Miningmodel(mm.getModelName(), mm, null, owner);
pmml4Models.add(model);
}
});
return pmml4Models;
}
use of org.dmg.pmml.pmml_4_2.descr.RegressionModel in project drools by kiegroup.
the class PMML4ModelFactory method getModel.
public PMML4Model getModel(Segment segment, MiningSegmentation segmentation) {
PMML4Model model = null;
if (segment.getMiningModel() != null) {
MiningModel mm = segment.getMiningModel();
model = new Miningmodel(mm.getModelName(), mm, segmentation.getOwner(), null);
} else if (segment.getRegressionModel() != null) {
RegressionModel rm = segment.getRegressionModel();
model = new Regression(rm.getModelName(), rm, segmentation.getOwner(), null);
} else if (segment.getScorecard() != null) {
Scorecard sc = segment.getScorecard();
model = new ScorecardModel(sc.getModelName(), sc, segmentation.getOwner(), null);
} else if (segment.getTreeModel() != null) {
TreeModel tm = segment.getTreeModel();
model = new Treemodel(tm.getModelName(), tm, segmentation.getOwner(), null);
}
return model;
}
Aggregations