Search in sources :

Example 11 with Scorecard

use of org.dmg.pmml.pmml_4_2.descr.Scorecard in project drools by kiegroup.

the class ScoringStrategiesTest method testScoringExtension.

@Test
public void testScoringExtension() throws Exception {
    PMML pmmlDocument;
    ScorecardCompiler scorecardCompiler = new ScorecardCompiler(INTERNAL_DECLARED_TYPES);
    if (scorecardCompiler.compileFromExcel(PMMLDocumentTest.class.getResourceAsStream("/scoremodel_scoring_strategies.xls"))) {
        pmmlDocument = scorecardCompiler.getPMMLDocument();
        assertNotNull(pmmlDocument);
        String drl = scorecardCompiler.getDRL();
        assertNotNull(drl);
        for (Object serializable : pmmlDocument.getAssociationModelsAndBaselineModelsAndClusteringModels()) {
            if (serializable instanceof Scorecard) {
                Scorecard scorecard = (Scorecard) serializable;
                assertEquals("Sample Score", scorecard.getModelName());
                Extension extension = ScorecardPMMLUtils.getExtension(scorecard.getExtensionsAndCharacteristicsAndMiningSchemas(), ScorecardPMMLExtensionNames.SCORECARD_SCORING_STRATEGY);
                assertNotNull(extension);
                assertEquals(extension.getValue(), AggregationStrategy.AGGREGATE_SCORE.toString());
                return;
            }
        }
    }
    fail();
}
Also used : Extension(org.dmg.pmml.pmml_4_2.descr.Extension) PMML(org.dmg.pmml.pmml_4_2.descr.PMML) Scorecard(org.dmg.pmml.pmml_4_2.descr.Scorecard) Test(org.junit.Test)

Example 12 with Scorecard

use of org.dmg.pmml.pmml_4_2.descr.Scorecard 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;
}
Also used : TreeModel(org.kie.dmg.pmml.pmml_4_2.descr.TreeModel) MiningModel(org.kie.dmg.pmml.pmml_4_2.descr.MiningModel) PMML4Model(org.kie.pmml.pmml_4_2.PMML4Model) Scorecard(org.kie.dmg.pmml.pmml_4_2.descr.Scorecard) RegressionModel(org.kie.dmg.pmml.pmml_4_2.descr.RegressionModel)

Aggregations

Scorecard (org.dmg.pmml.pmml_4_2.descr.Scorecard)8 PMML (org.dmg.pmml.pmml_4_2.descr.PMML)7 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)3 Characteristics (org.dmg.pmml.pmml_4_2.descr.Characteristics)3 Extension (org.dmg.pmml.pmml_4_2.descr.Extension)3 KieServices (org.kie.api.KieServices)3 KieContainer (org.kie.api.runtime.KieContainer)3 RegressionModel (org.kie.dmg.pmml.pmml_4_2.descr.RegressionModel)3 Scorecard (org.kie.dmg.pmml.pmml_4_2.descr.Scorecard)3 TreeModel (org.kie.dmg.pmml.pmml_4_2.descr.TreeModel)3 Attribute (org.dmg.pmml.pmml_4_2.descr.Attribute)2 Characteristic (org.dmg.pmml.pmml_4_2.descr.Characteristic)2 Output (org.dmg.pmml.pmml_4_2.descr.Output)2 MiningModel (org.kie.dmg.pmml.pmml_4_2.descr.MiningModel)2 PMML4Model (org.kie.pmml.pmml_4_2.PMML4Model)2 Map (java.util.Map)1 ClusteringModel (org.dmg.pmml.pmml_4_2.descr.ClusteringModel)1 MiningField (org.dmg.pmml.pmml_4_2.descr.MiningField)1 MiningSchema (org.dmg.pmml.pmml_4_2.descr.MiningSchema)1