Model Composition
 PMML3.2 Menu Home PMML Notice and License Changes Conformance Interoperability General Structure Header Data Dictionary Mining Schema Transformations Statistics Taxomony Targets Output Functions Built-in Functions Model Composition Model Verification Association Rules Cluster Models General Regression Naive Bayes Neural Network Regression Ruleset Sequences Text Models Trees Vector Machine

## PMML 3.2 - Model Composition: Sequences of Models and Model Selection

Model Composition allows the combination of simple models into a single composite PMML model. There are two main variants:
1. Model sequencing: two or more models are combined into a sequence where the results of one model are used as input in another model.
2. Model selection: one of many models can be selected based on decision rules.
PMML supports the combination of decision trees and simple regression models. More general variants would be possible and may be defined in future versions of PMML.

### Sample scenarios

Model sequencing and selection in PMML covers a variety of scenarios such as the following examples:
• A logistic regression model may require non-trivial rules for replacing missing values like
if Age is missing
if Occupation is "Student" then Age := 20
else if Occupation is "Retired" then Age := 70
else Age := 40
These preprocessing rules can be defined by a simple decision tree model that is put into a sequence with the regression model.

• A common method for optimizing prediction models is the combination of segmentation and regression. Data are grouped into segments and for each segment there may be different regression equations. If the segmentation can be expressed by decision rules then this kind of segment based regression can be implemented by a decision tree where any leaf node in the tree can contain an embedded regression model.

• Prediction results may have to be combined with a cost or profit matrix before a decision can be derived. A mailing campaign model may use tree classification to determine response probabilities per customer and channel. The cost matrix can be appended as a regression model that applies cost weighting factors to different channels, e.g., high cost for phone and low cost for email. The final decision is then based on the outcome of the regression model.

• A voting scheme that merges results from multiple models can also be implemented by model composition in PMML. For example, there may be an ensemble of four classification models A, B, C, and D for the same target with values "yes" and "no". The final classification result may be defined as the average of the results from A, B, C, and D. The average can be computed by a regression model with equations
pyes = 0.25*pAyes + 0.25*pByes + 0.25*pCyes + 0.25*pDyes
pno = 0.25*pAno + 0.25*pBno + 0.25*pCno + 0.25*pDno
where pXyes stands for the probability of class "yes" and pXno stands for the probability of class "no" in the model X.

### XML Schema

Model composition uses three syntactical concepts
1. The essential elements of a predictive model are captured in elements that can be included in other models.
2. Embedded models can define new fields, similar to derived fields.
3. The leaf nodes in a decision tree can contain another predictive model.
For example, using a sequence of models, a field could be defined by a regression equation. This field is then used as an ordinary input field in a decision tree. The basic idea is that we capture the essential elements of a model, in this example from a regression model, and use them to define new fields. That is similar to defining a derived field.

#### Mining models and their corresponding embedded elements

The first steps in making models reusable in other models is the definition of 'model expression' elements that can be embedded in another model. PMML defines the two elements Regression and DecisionTree.
RegressionModel Regression RegressionTable(s)
TreeModel DecisionTree Node(s)

EmbeddedModel does not contain a MiningSchema. There is only one MiningSchema at the top-level.

 ``` ```
Model selection is enabled by allowing an EmbeddedModel within a tree Node.

The element Regression contains the essential elements of a RegressionModel:

 ``` ```
ResultFields are elements that define named results, see below.

The element DecisionTree contains the essential elements of a TreeModel:

 ``` ```

Regression and DecisionTree can exclusively be used to build a model using the MiningModel model type:

 ``` ```

The element ResultField is very similar to OutputField and DerivedField

 ``` ```

### Model Sequencing for Input Transformations

The following example demonstrates how a regression equation can be used to define an input transformation in another model which happens to be a TreeModel.
 ```
female1 male0 ```

Remarks:

• The submodels comprising a sequence are ordered in such a way that each is defined after any other submodels on which it depends.
• The prediction from the last submodel defined is taken as the prediction for the composite model.

### Model selection

Model selection in PMML allows for combining multiple 'embedded models', aka model expressions, into the decision logic that selects one of the models depending on the current input values.

The following example shows how regression elements are used within the nodes of a decision tree:

 ```
female1 male0 ```
 e-mail info at dmg.org