Search in sources :

Example 6 with Characteristics

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

the class ExcelScorecardValidator method validateWeights.

private void validateWeights() {
    for (Object obj : scorecard.getExtensionsAndCharacteristicsAndMiningSchemas()) {
        if (obj instanceof Characteristics) {
            Characteristics characteristics = (Characteristics) obj;
            for (Characteristic characteristic : characteristics.getCharacteristics()) {
                for (Attribute attribute : characteristic.getAttributes()) {
                    String newCellRef = createDataTypeCellRef(ScorecardPMMLUtils.getExtensionValue(attribute.getExtensions(), "cellRef"), 2);
                    String weight = ScorecardPMMLUtils.getExtensionValue(attribute.getExtensions(), ScorecardPMMLExtensionNames.CHARACTERTISTIC_WEIGHT);
                    if (StringUtils.isEmpty(weight) || !isDouble(weight)) {
                        parseErrors.add(new ScorecardError(newCellRef, "Attribute is missing weight or specified weight is not a double."));
                    }
                }
            }
        }
    }
}
Also used : Characteristics(org.dmg.pmml.pmml_4_2.descr.Characteristics) Attribute(org.dmg.pmml.pmml_4_2.descr.Attribute) Characteristic(org.dmg.pmml.pmml_4_2.descr.Characteristic) ScorecardError(org.drools.scorecards.ScorecardError)

Example 7 with Characteristics

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

the class ScorecardReasonCodeTest method testReasonCodes.

@Test
public void testReasonCodes() throws Exception {
    final ScorecardCompiler scorecardCompiler = new ScorecardCompiler(INTERNAL_DECLARED_TYPES);
    boolean compileResult = scorecardCompiler.compileFromExcel(PMMLDocumentTest.class.getResourceAsStream("/scoremodel_reasoncodes.xls"));
    if (!compileResult) {
        assertErrors(scorecardCompiler);
    }
    final PMML pmmlDocument = scorecardCompiler.getPMMLDocument();
    for (Object serializable : pmmlDocument.getAssociationModelsAndBaselineModelsAndClusteringModels()) {
        if (serializable instanceof Scorecard) {
            for (Object obj : ((Scorecard) serializable).getExtensionsAndCharacteristicsAndMiningSchemas()) {
                if (obj instanceof Characteristics) {
                    Characteristics characteristics = (Characteristics) obj;
                    assertEquals(4, characteristics.getCharacteristics().size());
                    for (Characteristic characteristic : characteristics.getCharacteristics()) {
                        for (Attribute attribute : characteristic.getAttributes()) {
                            assertNotNull(attribute.getReasonCode());
                        }
                    }
                    return;
                }
            }
        }
    }
    fail();
}
Also used : Characteristics(org.dmg.pmml.pmml_4_2.descr.Characteristics) Attribute(org.dmg.pmml.pmml_4_2.descr.Attribute) Characteristic(org.dmg.pmml.pmml_4_2.descr.Characteristic) PMML(org.dmg.pmml.pmml_4_2.descr.PMML) Scorecard(org.dmg.pmml.pmml_4_2.descr.Scorecard) Test(org.junit.Test)

Aggregations

Characteristics (org.dmg.pmml.pmml_4_2.descr.Characteristics)7 Characteristic (org.dmg.pmml.pmml_4_2.descr.Characteristic)6 Attribute (org.dmg.pmml.pmml_4_2.descr.Attribute)5 ScorecardError (org.drools.scorecards.ScorecardError)4 Scorecard (org.dmg.pmml.pmml_4_2.descr.Scorecard)3 PMML (org.dmg.pmml.pmml_4_2.descr.PMML)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 Extension (org.dmg.pmml.pmml_4_2.descr.Extension)1 MiningField (org.dmg.pmml.pmml_4_2.descr.MiningField)1 MiningSchema (org.dmg.pmml.pmml_4_2.descr.MiningSchema)1 Output (org.dmg.pmml.pmml_4_2.descr.Output)1 ScorecardPMMLGenerator (org.drools.scorecards.pmml.ScorecardPMMLGenerator)1 Import (org.kie.soup.project.datamodel.imports.Import)1