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."));
}
}
}
}
}
}
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();
}
Aggregations