Parsing a PMML Document

I am using the jpmml library to parse a PMML document (an XML document with a PMML root element). I can parse some elements, but not all. Here I cannot parse the CategoricalPredictor attribute inside the RegressionTable element. Code for parsing CategoricalPredictor :

RegressionTable regressionTable = new RegressionTable(intercept); List<CategoricalPredictor> categoricalPredictor=regressionTable.getCategoricalPredictors(); /*Categorical predictors*/ System.out.println("Categorical Predictors:"); for(CategoricalPredictor c : categoricalPredictor){ System.out.println("Name :"+c.getName()+",\tValue :"+c.getValue()+ ",\tCoefficient :"+c.getCoefficient()); System.out.println(); } 

With this code, I get nothing but categorical predictors: as a conclusion.

What should I do to get it? Your efforts will be noticeable. Thanks in advance.

+4
source share
1 answer

You call RegressionTable#getCategoricalPredictors() on a newly created instance of RegressionTable . The receiver returns an empty List , which is the expected behavior.

If you want to work with an existing instance of RegressionTable , you need to load it from the PMML file like this:

 PMML pmml = ... RegressionModelManager regressionManager = new RegressionModelManager(pmml); RegressionModel model = regressionManager.getModel(); List<RegressionTable> modelTables = model.getRegressionTables(); for(RegressionTable regressionTable : regressionTables){ ... } 
+1
source

All Articles