PMML General Structure
PMML2.0 Menu

Home


PMML Notice and License

General Structure

Header

Data
Dictionary


Mining
Schema


Data Flow

Transformations

Statistics

Conformance

Taxomony

Trees

Regression

General
Regression


Cluster
Models


Association Rules

Neural
Network


Naive
Bayes


Sequences

PMML 2.0 -- General Structure of a PMML Document

PMML uses XML to represent mining models. The structure of the models is described by a DTD which is called the PMML DTD. One or more mining models can be contained in a PMML document. A PMML document is an XML document with a root element of type PMML.The general stucture of a PMML document is:


   <?xml version="1.0"?>
   <!DOCTYPE PMML 
             PUBLIC "PMML 2.0" 
             "https://www.dmg.org/v2-0/pmml_v2_0.dtd">
   <PMML  version="2.0">
   ...
   </PMML>

A PMML document is not required to have a DOCTYPE declaration. If there is one then a PMML document must not depend on external parameters, that is we assume the default attribute standalone="yes" in the <?xml?> statement. Although a PMML document must be valid with respect to the PMML DTD, a document must not require a validating parser, which would load external entities. In addition to being a valid XML document, a valid PMML document must obey a number of further rules which are described at various places in the PMML specification. See also the conformance rules for valid PMML documents, producers, and consumers.

The root element of a PMML document must have type PMML.


   <!ENTITY % A-PMML-MODEL '(TreeModel | 
                             NeuralNetwork | 
                             ClusteringModel | 
                             RegressionModel |
                             GeneralRegressionModel |
                             NaiveBayesModels | 
                             AssociationModel |
                             SequenceModel )' >

   <!ELEMENT PMML ( Header, 
                    MiningBuildTask?, 
                    DataDictionary, 
                    TransformationDictionary?,
                    (%A-PMML-MODEL;)*, 
                    Extension* )>
   <!ATTLIST PMML 
        version    CDATA    #REQUIRED
   >

   <!ELEMENT MiningBuildTask (Extension*) >

A PMML document can contain more than one model. If the application system provides a means of selecting models by name and if the PMML consumer specifies a model name, then that model is used; otherwise the first model is used.

A PMML 2.0 compliant system is not required to provide model selection by name.

The list of mining models in a PMML document may even be empty. The document can be used to carry the initial metadata before an actual model is computed. A PMML document containing no model is not meant to be useful for a PMML consumer.

For PMML version 2.0 the attribute version must have the value 2.0

The element MiningBuildTask can contain any XML value describing the configuration of the training run that produced the model instance. This information is not directly needed in a PMML consumer, but in many cases it is helpful for maintenance and for visualization of the model. The particular content structure of MiningBuildTask is not defined by PMML 2.0. Though, this element would be the natural container for task specifications as defined by other mining standards, e.g., in SQL or Java.

The fields in the DataDictionary and in the TransformationDictionary taken together are identified by unique names. Other elements in the models can refer to these fields by name. Multiple models on one PMML document can share the same fields in the TransformationDictionary. Nevertheless, a model can also define its 'own' derived fields. Various models use DerivedField elements directly in the definition of the model. For example, DerivedField's appear inline in the input layer of neural networks.

Certain types of PMML models such as neural networks or logistic regression can be used for different purposes. That is, some instances implement prediction of numeric values, while others can be used for classification. Therefore, PMML defines four different mining functions. Each model has an attribute 'functionName' which specifies the mining function.


   <ENTITY % MINING-FUNCTION '(associationRules |
                               sequences |
                               classification |
                               regression |
                               clustering )' >

For all PMML models the structure of the top-level model element is similar to the template of XModel as below


   <!ELEMENT XModel (Extension*, MiningSchema,
                     ModelStats?, ..., Extension* ) >
   <!ATTLIST XModel
        modelName           CDATA                 #IMPLIED
        functionName        %MINING-FUNCTION;     #REQUIRED
        algorithmName       CDATA                 #IMPLIED
   >

   <!ELEMENT MiningSchema   (MiningField+) >
   <!ELEMENT ModelStats     (UnivariateStats+) >

The non-empty list of mining fields define a mining schema. The univariate statistics contain global statistics on (a subset of the) mining fields. Other model specific elements follow after ModelStats in the content of XModel. For a list of models that have been defined in PMML 2.0 see the entity A-PMML-MODEL above.

modelName: the value in modelName identifies the model with a unique name in the context of the PMML file. This attribute is not required. Users reading models of a PMML file are free to manage model's naming at their discretion.

functionName and algorithmName describe the kind of mining model, e.g., whether it is intended to be used for clustering or for classification. The algorithm name can be any description for the specific algorithm that produced the model. This attribute is for information only.

The naming conventions for PMML are: ElementNames in mixed case, first uppercase. The attributeNames are in mixed case, first lowercase. The enumConstants in mixed case, first lowercase. The ENTITY-NAMES are all uppercase. The character '-' is used less often in order to avoid confusion with mathematical notation.

Extension Mechanism

The PMML DTD contains a mechanism for extending the content of a model. Extension elements are included in the content defintition of many element types. These extension elements have a content model of ANY allowing considerable freedom in the nature of the extensions. One use of the extension mechanism could be to associate display information for a particular tool.


   <!ELEMENT Extension ANY>
   <!ATTLIST Extension
         extender         CDATA           #IMPLIED
         name             CDATA           #IMPLIED
         value            CDATA           #IMPLIED
   >

The extension data should be part of the content within the elements of type Extension. Nevertheless, the attribute name can be used to specify the kind of the extension. E.g., an Extension for storing special set of statistical indicators could be written as <Extension extender="foo.com" name="StatsMomentum">...</Extension>. If you know HTML tags you will notice a similarity to the attributes name and content of the META tag.

With XML 1.0 one can add attribute declarations to given elements, without changing an external DTD. An XML parser may give a warning but a document which uses the additional attributes can be valid. That is, if the standard PMML DTD contains an element TreeNode then a document may declare additional attributes on TreeNode. PMML adopts this rule but attribute names must have prefix 'x-' in order to make an extension obvious. The same convention is used for vendor specific element types which can be contained in an Extension element; the tag name must start with 'X-'.

This convention also helps to avoid conflicts with possible future extensions to standard PMML. If a document uses local namespaces, then the name of the namespace should not start with 'PMML' or 'DMG' or any variant of these names with lowercase characters. They are reserved for future use in PMML.

An extended PMML document could look like


   <?xml version="1.0" >
   <!DOCTYPE PMML 
             PUBLIC "https://www.dmg.org/v2-0/pmml_v2_0.dtd"
   [  <!ELEMENT X-MyNodeExtension ( ...... ) >   .....
      <!ATTLIST TreeNode  x-myAttr  CDATA >
   ]>
   ...
   <XXModel
       <TreeNode  x-myAttr="xxx" >
           <Extension>
              <X-MyNodeExtension>...</X-MyNodeExtension>
           </Extension>
       </TreeNode>
   </XXModel>

Basic data types and entities:

The definition


        <!ENTITY  % NUMBER  "CDATA" > 

is commonly used for distinguishing numeric values from other data. Numbers may have a leading sign, fractions, and an exponent. In addition to NUMBER there are a couple of more specific definitions:


        <!ENTITY  % INT-NUMBER  "CDATA"> 

An INT-NUMBER must be an integer, no fractions or exponent.

        <!ENTITY  % REAL-NUMBER  "CDATA"> 

A REAL-NUMBER can be any number covers C/C++ types 'float','long', 'double'. Scientific notation, eg 1.23e4, is allowed.


        <!ENTITY  % PROB-NUMBER  "CDATA"> 

A PROB-NUMBER is a REAL-NUMBER between 0.0 and 1.0 usually describing a probability.


        <!ENTITY  % PERCENTAGE-NUMBER  "CDATA"> 

A PERCENTAGE-NUMBER is a REAL-NUMBER between 0.0 and 100.0.

Note that these entities do not enforce the XML parser to check the data types.However they still define requirements for a valid PMML document.

Many elements contain references to input fields. PMML does not use IDREF to represent field names because field names are not necessarily valid XML identifiers. However, given the definition


        <!ENTITY % FIELD-NAME  "CDATA"> 
then references to input fields will be obvious from the DTD syntax. Note that a model can refer to two kinds of input fields. One is the set of MiningField's in the MiningSchema. The other is the set of DerivedField's in the TransformationDictionary.

PMML uses the character '.' as decimal point in the representation of REAL-NUMBER values.

Compact arrays of values

Instances of mining models often contain sets with a large number of values. The type Array is defined as container structure which implements arrays of numbers and strings in a fairly compact way.


        <!ELEMENT Array (#PCDATA) >
        <!ATTLIST Array 
             n               %INT-NUMBER;                #IMPLIED 
             type            ( int | real | string )     #IMPLIED
        >

The content of 'Array' is a blank separated sequence of values, multible blanks are as good as one blank. The attribute 'n' determines the number of elements in the sequence. If n is given it must match the number of values in the content, otherwise the PMML document is invalid. The attribute 'type' indicates the data types of values in the array. This attribute is optional because in many cases the data type is implied from the context where the array is used. String values may be enclosed within double quotes ", which are not considered to be part of the value. If a string value contains the " character, then it must be escaped by a backslash character \, that's the same escaping mechanism as used in C/C++.

Examples:


        <Array n="3" type="int"> 1 22 3
        </Array>
        <Array n="3" type="string">
        ab  "a b"   "with \"quotes\" "
        </Array>
The second array contains the three strings 'ab', 'a b', and 'with "quotes" '.

If there is a value for the length attribute n then the number of entries in the content must match this value; otherwise the PMML document is not valid. Similar to the entities for different types of numbers we define entities for arrays which should have a specific content type. Again, these entities just map to a single XML markup.


        <!ENTITY  % NUM-ARRAY  "Array"> 

A NUM-ARRAY is an array of numbers.

The following entities define arrays which contain integers, reals, or strings.


        <!ENTITY  % INT-ARRAY  "Array">

        <!ENTITY  % REAL-ARRAY  "Array">

        <!ENTITY  % STRING-ARRAY  "Array"> 
e-mail info at dmg.org