package ‘pmml’ - universidad autónoma del estado de ... · pdf filepackage...

23
Package ‘pmml’ February 15, 2013 Type Package Title Generate PMML for various models Version 1.2.34 Date 2013-01-26 Author Graham Williams, Michael Hahsler (arules), Zementis Inc, Hemant Ishwaran, Udaya B. Kogalur, Rajarshi Guha Maintainer Graham Williams <[email protected]> Depends XML Suggests arules, nnet, rpart, randomSurvivalForest, randomForest,kernlab, survival License GPL (>= 2) Description The Predictive Modelling Markup Language (PMML) is a language for representing models, in an application independent way. Such models can then be loaded into other applications supporting PMML, including ADAPA from Zementis, Teradata Warehouse Miner and IBM’s DB2. The package provides a generic pmml function to generate pmml for an object. Using a S3 generic function the appropriate method for the class of the supplied object is dispatched. The package currently supports the export of PMML for linear regression, generalized linear regression, multinomial logistic regression, SVMs, rpart classification trees, randomSurvivalForest, randomForest, and kmeans clusters. This package is part of the Rattle toolkit. URL http://rattle.togaware.com/ Repository CRAN Date/Publication 2013-01-26 08:44:52 NeedsCompilation no 1

Upload: phamkhue

Post on 07-Mar-2018

219 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Package ‘pmml’ - Universidad Autónoma del Estado de ... · PDF filePackage ‘pmml’ February 15, 2013 Type Package Title Generate PMML for various models Version 1.2.34 Date

Package ‘pmml’February 15, 2013

Type Package

Title Generate PMML for various models

Version 1.2.34

Date 2013-01-26

Author Graham Williams, Michael Hahsler (arules), Zementis Inc, HemantIshwaran, Udaya B. Kogalur, Rajarshi Guha

Maintainer Graham Williams <[email protected]>

Depends XML

Suggests arules, nnet, rpart, randomSurvivalForest, randomForest,kernlab, survival

License GPL (>= 2)

Description The Predictive Modelling Markup Language (PMML) is alanguage for representing models, in an application independentway. Such models can then be loaded into other applicationssupporting PMML, including ADAPA from Zementis, TeradataWarehouse Miner and IBM’s DB2. The package provides a genericpmml function to generate pmml for an object. Using a S3generic function the appropriate method for the class of thesupplied object is dispatched. The package currently supportsthe export of PMML for linear regression, generalized linearregression, multinomial logistic regression, SVMs, rpartclassification trees, randomSurvivalForest, randomForest, andkmeans clusters. This package is part of the Rattle toolkit.

URL http://rattle.togaware.com/

Repository CRAN

Date/Publication 2013-01-26 08:44:52

NeedsCompilation no

1

Page 2: Package ‘pmml’ - Universidad Autónoma del Estado de ... · PDF filePackage ‘pmml’ February 15, 2013 Type Package Title Generate PMML for various models Version 1.2.34 Date

2 pmml

R topics documented:pmml . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2pmml.coxph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3pmml.glm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4pmml.hclust . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6pmml.kmeans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7pmml.ksvm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8pmml.lm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9pmml.multinom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11pmml.nnet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12pmml.randomForest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13pmml.rpart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15pmml.rsf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17pmml.rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19pmmlCanExport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20pmmlLocalTransformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21pmmltoc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

Index 23

pmml Generate PMML for an R object

Description

’pmml’ is a generic function implementing S3 methods used to produce the PMML (PredictiveModel Markup Language) representation of an R model. The PMML can then be imported intoother systems that accept PMML.

Usage

pmml(model, model.name="Rattle_Model", app.name="Rattle/PMML",description=NULL, copyright=NULL, transforms=NULL, dataset=NULL,...)

Arguments

model an object to be converted to PMML.

model.name a name to give to the model in the PMML.

app.name the name of the application that generated the PMML.

description a descriptive text for the header of the PMML.

copyright the copyright notice for the model.

transforms a coded list of transforms performed.

dataset the orginal training dataset, if available.

... further arguments passed to or from other methods.

Page 3: Package ‘pmml’ - Universidad Autónoma del Estado de ... · PDF filePackage ‘pmml’ February 15, 2013 Type Package Title Generate PMML for various models Version 1.2.34 Date

pmml.coxph 3

Details

The generated PMML can be imported into any PMML consuming application, such as TeradataWarehouse Miner and DB2. Generally, these applications convert the PMML into SQL for execu-tion across a database.

Author(s)

<[email protected]>

References

Package home page: http://rattle.togaware.com

PMML home page: http://www.dmg.org

See Also

pmml.rules, pmml.hclust, pmml.kmeans, pmml.ksvm, pmml.glm, pmml.lm, pmml.nnet, pmml.multinom,pmml.rpart, pmml.randomForest, pmml.rsf, pmmltoc.

Examples

# Build a simple lm model(iris.lm <- lm(Sepal.Length ~ ., data=iris))

# Convert to pmmlpmml(iris.lm)

pmml.coxph Generate PMML for a coxph object

Description

Generate the PMML (Predictive Model Markup Language) representation of a coxph object. ThePMML can then be imported into other systems that accept PMML.

Usage

## S3 method for class ’coxph’pmml(model, model.name="CoxPH_Survival_Regression_Model", app.name="Rattle/PMML",

description="CoxPH Survival Regression Model", copyright=NULL, transforms=NULL, ...)

Page 4: Package ‘pmml’ - Universidad Autónoma del Estado de ... · PDF filePackage ‘pmml’ February 15, 2013 Type Package Title Generate PMML for various models Version 1.2.34 Date

4 pmml.glm

Arguments

model a coxph object.

model.name a name to give to the model in the PMML.

app.name the name of the application that generated the PMML.

description a descriptive text for the header of the PMML.

copyright the copyright notice for the model.

transforms a coded list of transforms performed, such as a WrapData object from the pmml-Transformations package

... further arguments passed to or from other methods.

Details

The generated PMML can be imported into any PMML consuming application, such as Zementis’ADAPA.

Only numeric risk regression is supported currently.

Author(s)

<[email protected]>

References

Package home page: http://rattle.togaware.com

PMML home page: http://www.dmg.org

Zementis’ useful PMML convert: http://www.zementis.com/pmml_converters.htm

See Also

pmml.

pmml.glm Generate PMML for a glm (stats) object

Description

Generate the Predictive Model Markup Language (PMML) representation of a stats general linearregression object. In particular, this function gives the user the ability to save the geometry of ageneral regression as a PMML XML document.

Usage

## S3 method for class ’glm’pmml(model, model.name="General_Regression_Model", app.name="Rattle/PMML",

description="Generalized Linear Regression Model", copyright = NULL, transforms= NULL, ...)

Page 5: Package ‘pmml’ - Universidad Autónoma del Estado de ... · PDF filePackage ‘pmml’ February 15, 2013 Type Package Title Generate PMML for various models Version 1.2.34 Date

pmml.glm 5

Arguments

model the glm object contained in an object of class stats, as that contained in theobject returned by the function glm.

model.name a name to give to the model in the PMML.

app.name the name of the application that generated the PMML.

description a descriptive text for the header of the PMML.

copyright the copyright notice for the model.

transforms transforms.

... further arguments passed to or from other methods.

Details

The Predictive Model Markup Language is an XML based language which provides a way forapplications to define statistical and data mining models and to share models between PMML com-pliant applications. More information about PMML and the Data Mining Group can be found athttp://www.dmg.org.

Use of PMML and pmml.glm requires the XML package. Be aware that XML is a very verbosedata format. Reasonably sized trees and data sets can lead to extremely large text files. XML, whileachieving interoperability, is not an efficient data storage mechanism in this case.

This function is used to export the structure of a general regrssion model to other PMML compliantapplications, including graphics packages.

Value

An object of class XMLNode as that defined by the XML package. This represents the top level, orroot node, of the XML document and is of type PMML. It can be written to file with saveXML.

Author(s)

<[email protected]>

References

Dobson, A.J. (1990), /emphAn Introduction to Generalized Linear Models. London: Chapman andHall.

PMML home page: http://www.dmg.org

A. Guazzelli, W. Lin, T. Jena (2012), /emphPMML in Action: Unleashing the Power of OpenStandards for Data Mining and Predictive Analytics. CreativeSpace (Second Edition - Available onAmazon.com - http://www.amazon.com/dp/1470003244.

A. Guazzelli, M. Zeller, W. Lin, G. Williams (2009), /emphPMML: An Open Standard for SharingModels. The R journal, Volume 1/1, 60-65

See Also

pmml.

Page 6: Package ‘pmml’ - Universidad Autónoma del Estado de ... · PDF filePackage ‘pmml’ February 15, 2013 Type Package Title Generate PMML for various models Version 1.2.34 Date

6 pmml.hclust

pmml.hclust Generate PMML for a hclust object

Description

Generate a PMML representation for a hierarchical cluster object. The hclust object will be ap-proximated by k centroids and is converted into a PMML representation for kmeans clusters. ThePMML can then be imported into other systems that accept PMML.

Usage

## S3 method for class ’hclust’pmml(model, model.name="HClust_Model", app.name="Rattle/PMML",

description="Hierarchical cluster model", copyright=NULL,transforms=NULL, dataset=NULL, centers, ...)

Arguments

model a hclust object.

model.name a name to give to the model in the PMML.

app.name the name of the application that generated the PMML.

description a descriptive text for the header of the PMML.

copyright the copyright notice for the model.

transforms a coded list of transforms performed.

dataset the orginal training dataset, if available.

centers a list of means to represent the clusters.

... further arguments passed to or from other methods.

Author(s)

<[email protected]>

References

Package home page: http://rattle.togaware.com

PMML home page: http://www.dmg.org

See Also

pmml, hclust.

Page 7: Package ‘pmml’ - Universidad Autónoma del Estado de ... · PDF filePackage ‘pmml’ February 15, 2013 Type Package Title Generate PMML for various models Version 1.2.34 Date

pmml.kmeans 7

pmml.kmeans Generate PMML for a kmeans object

Description

Generate the PMML representation for a KMeans object (cluster). The kmeans object (a cluster de-scribed by k centroids) is converted into a PMML representation. The PMML can then be importedinto other systems that accept PMML.

Usage

## S3 method for class ’kmeans’pmml(model, model.name="KMeans_Model", app.name="Rattle/PMML",

description="KMeans cluster model", copyright=NULL,transforms=NULL, dataset=NULL,algorithm.name="KMeans: Hartigan and Wong", ...)

Arguments

model a kmeans object.

model.name a name to give to the model in the PMML.

app.name the name of the application that generated the PMML.

description a descriptive text for the header of the PMML.

copyright the copyright notice for the model.

transforms a coded list of transforms performed.

dataset not used for kmeans.

algorithm.name the variety of kmeans used.

... further arguments passed to or from other methods.

Author(s)

<[email protected]>

References

Package home page: http://rattle.togaware.com

PMML home page: http://www.dmg.org

See Also

pmml, kmeans.

Page 8: Package ‘pmml’ - Universidad Autónoma del Estado de ... · PDF filePackage ‘pmml’ February 15, 2013 Type Package Title Generate PMML for various models Version 1.2.34 Date

8 pmml.ksvm

Examples

ds <- rbind(matrix(rnorm(100, sd = 0.3), ncol = 2),matrix(rnorm(100, mean = 1, sd = 0.3), ncol = 2))

colnames(ds) <- c("Dimension1", "Dimension2")cl <- kmeans(ds, 2)pmml(cl)

pmml.ksvm Generate PMML for a ksvm object

Description

Generate the PMML representation for a ksvm object (SVM). The PMML can then be importedinto other systems that accept PMML. With this code, a PMML representation can be obtained forSVMs implementing classification (multi-class and binary) as well as regression.

Usage

## S3 method for class ’ksvm’pmml(model, model.name="SVM_model", app.name="Rattle/PMML",

description="Support Vector Machine PMML Model", copyright=NULL,transforms=NULL, dataset=NULL, weights=NULL, ...)

Arguments

model a ksvm object.

dataset the original dataset used to train the SVM model in ksvm - required since theksvm object does not appear to record information about the used categoricalvariables.

model.name a name to give to the model in the PMML.

app.name the name of the application that generated the PMML.

description a descriptive text for the header of the PMML.

copyright the copyright notice for the model.

transforms a coded list of transforms performed.

weights the weights used for building the model.

... further arguments passed to or from other methods.

Details

The generated PMML can be imported into any PMML consuming application that recognizesPMML 3.2. An example is ADAPA (Adaptive Decision and Predictive Analytics), a lightweightdecision engine with batch and real-time scoring of predictive models (also supporting neural net-works and linear and logistic regression).

Page 9: Package ‘pmml’ - Universidad Autónoma del Estado de ... · PDF filePackage ‘pmml’ February 15, 2013 Type Package Title Generate PMML for various models Version 1.2.34 Date

pmml.lm 9

Author(s)

<[email protected]>

References

Package home page: http://rattle.togaware.com

PMML home page: http://www.dmg.org

Zementis’ useful PMML convert: http://www.zementis.com/pmml_converters.htm

ADAPA home page: http://www.zementis.com/adapa.htm

See Also

pmml. ksvm.

Examples

# Train a support vector machine to perform classification.

require(kernlab)model <- ksvm(Species ~ ., data=iris)p <- pmml(model, dataset=iris)

# Save to file.

## Not run: saveXML(p, "iris_svm.xml")

pmml.lm Generate PMML for an lm object

Description

Generate the PMML (Predictive Model Markup Language) representation of an lm object. ThePMML can then be imported into other systems that accept PMML.

Usage

## S3 method for class ’lm’pmml(model, model.name="Linear_Regression_Model", app.name="Rattle/PMML",

description="Linear Regression Model", copyright=NULL,transforms=NULL, dataset=NULL, weights=NULL, ...)

Page 10: Package ‘pmml’ - Universidad Autónoma del Estado de ... · PDF filePackage ‘pmml’ February 15, 2013 Type Package Title Generate PMML for various models Version 1.2.34 Date

10 pmml.lm

Arguments

model an lm object.

model.name a name to give to the model in the PMML.

app.name the name of the application that generated the PMML.

description a descriptive text for the header of the PMML.

copyright the copyright notice for the model.

transforms a coded list of transforms performed.

dataset the orginal training dataset, if available.

weights the weights used for building the model.

... further arguments passed to or from other methods.

Details

The generated PMML can be imported into any PMML consuming application, such as Zementis’ADAPA.

Currently, the resultant PMML document will not encode interaction terms.

Only numeric regression is supported currently. Generalised linear models (logistic regression) arenot yet supported.

Author(s)

<[email protected]>

References

Package home page: http://rattle.togaware.com

PMML home page: http://www.dmg.org

Zementis’ useful PMML convert: http://www.zementis.com/pmml_converters.htm

See Also

pmml.

Examples

# Build a simple lm model

(iris.lm <- lm(Sepal.Length ~ ., data=iris))

# Convert to pmml

pmml(iris.lm)

Page 11: Package ‘pmml’ - Universidad Autónoma del Estado de ... · PDF filePackage ‘pmml’ February 15, 2013 Type Package Title Generate PMML for various models Version 1.2.34 Date

pmml.multinom 11

pmml.multinom Generate PMML for a multinomial (multinom) object

Description

Generate the Predictive Model Markup Language (PMML) representation of a nnet multinomialobject. In particular, this function gives the user the ability to save a multinomial regression objectas a PMML XML document.

Usage

## S3 method for class ’multinom’pmml(model, model.name="multinom_Model", app.name="Rattle/PMML",

description="Multinomial Logistic Model", copyright = NULL, transforms = NULL, ...)

Arguments

model the multinom object contained in an object of class nnet, as that contained inthe object returned by the function multinom.

model.name a name to give to the model in the PMML.

app.name the name of the application that generated the PMML.

description a descriptive text for the header of the PMML.

copyright the copyright notice for the model.

transforms transforms.

... further arguments passed to or from other methods.

Details

The Predictive Model Markup Language is an XML based language which provides a way forapplications to define statistical and data mining models and to share models between PMML com-pliant applications. More information about PMML and the Data Mining Group can be found athttp://www.dmg.org.

Use of PMML and pmml.multinom requires the XML package. Be aware that XML is a veryverbose data format. Reasonably sized trees and data sets can lead to extremely large text files.XML, while achieving interoperability, is not an efficient data storage mechanism in this case.

This function is used to export the structure of the multinomial logistoc regression model to otherPMML compliant applications.

Value

An object of class XMLNode as that defined by the XML package. This represents the top level, orroot node, of the XML document and is of type PMML. It can be written to file with saveXML.

Author(s)

<[email protected]>

Page 12: Package ‘pmml’ - Universidad Autónoma del Estado de ... · PDF filePackage ‘pmml’ February 15, 2013 Type Package Title Generate PMML for various models Version 1.2.34 Date

12 pmml.nnet

References

Venables, W.N. and Ripley, B.D. (2002) /emphModern Applied Statistics with S. Fourth edition.Springer.

PMML home page: http://www.dmg.org

A. Guazzelli, W. Lin, T. Jena (2012), /emphPMML in Action: Unleashing the Power of OpenStandards for Data Mining and Predictive Analytics. CreativeSpace (Second Edition - Available onAmazon.com - http://www.amazon.com/dp/1470003244.

A. Guazzelli, M. Zeller, W. Lin, G. Williams (2009), /emphPMML: An Open Standard for SharingModels. The R journal, Volume 1/1, 60-65

See Also

pmml.

pmml.nnet Generate PMML for a nnet object

Description

Generate the PMML representation for a nnet object (Neural Network). The nnet object is convertedinto a PMML representation. The PMML can then be imported into other systems that acceptPMML. With this code, a PMML representation can be obtained for Neural Networks implementingclassification (multi-class and binary) as well as regression.

Usage

## S3 method for class ’nnet’pmml(model, model.name="NeuralNet_model", app.name="Rattle/PMML",

description="Neural Network PMML Model", copyright=NULL,transforms=NULL, ...)

Arguments

model a nnet object.

model.name a name to give to the model in the PMML.

app.name the name of the application that generated the PMML.

description a descriptive text for the header of the PMML.

copyright the copyright notice for the model.

transforms a coded list of transforms performed.

... further arguments passed to or from other methods.

Page 13: Package ‘pmml’ - Universidad Autónoma del Estado de ... · PDF filePackage ‘pmml’ February 15, 2013 Type Package Title Generate PMML for various models Version 1.2.34 Date

pmml.randomForest 13

Details

The generated PMML can be imported into any PMML consuming application that recognizesPMML 3.2. An example is ADAPA. ADAPA (Adaptive Decision and Predictive Analytics) is alightweight decision engine that offers at its core batch and real-time scoring of predictive modelsas well as fast execution of business rules. ADAPA supports an extensive collection of PMMLelements, including the following predictive techniques: 1) Neural Networks (Backprogagation andNeural Gas); 2) Support Vector Machines; 3) Linear and Logistic Regression as well as all generalregression PMML models: a) Multinomial Logistic; b) General Linear; 3) Ordinal Multinomial; 4)Simple Regression; and 5) Generalized Linear Model. ADAPA provides a reliable and fast way tomanage, deploy, and execute a multitude of models and decision strategies.

Author(s)

<[email protected]>

References

Package home page: http://rattle.togaware.com

PMML home page: http://www.dmg.org

Zementis’ useful PMML convert: http://www.zementis.com/pmml_converters.htm

ADAPA home page: http://www.zementis.com/adapa.htm

See Also

pmml.

pmml.randomForest Generate PMML for a Random Forest (randomForest) object

Description

Generate the Predictive Model Markup Language (PMML) representation of a randomForest for-est object. In particular, this function gives the user the ability to save the geometry of a forest as aPMML XML document.

Usage

## S3 method for class ’randomForest’pmml(model, model.name="randomForest_Model",

app.name="Rattle/PMML",description="Random Forest Tree Model",copyright = NULL,transforms = NULL, ...)

Page 14: Package ‘pmml’ - Universidad Autónoma del Estado de ... · PDF filePackage ‘pmml’ February 15, 2013 Type Package Title Generate PMML for various models Version 1.2.34 Date

14 pmml.randomForest

Arguments

model the forest object contained in an object of class randomForest, as that con-tained in the object returned by the function randomForest.

model.name a name to give to the model in the PMML.

app.name the name of the application that generated the PMML.

description a descriptive text for the header of the PMML.

copyright the copyright notice for the model.

transforms transforms to represent within the PMML.

... further arguments passed to or from other methods.

Details

The Predictive Model Markup Language is an XML based language which provides a way forapplications to define statistical and data mining models and to share models between PMML com-pliant applications. More information about PMML and the Data Mining Group can be found athttp://www.dmg.org.

Use of PMML and pmml.randomForest requires the XML package. Be aware that XML is a veryverbose data format. Reasonably sized trees and data sets can lead to extremely large text files.XML, while achieving interoperability, is not an efficient data storage mechanism in this case.

This function is used to export the structure of the forest to other PMML compliant applications,including graphics packages that are capable of printing binary trees.

Value

An object of class XMLNode as that defined by the XML package. This represents the top level, orroot node, of the XML document and is of type PMML. It can be written to file with saveXML.

Author(s)

<[email protected]>

References

Breiman, L. (2001), /emphRandom Forests, Machine Learning 45(1),5-32

PMML home page: http://www.dmg.org

A. Guazzelli, W. Lin, T. Jena (2012), /emphPMML in Action: Unleashing the Power of OpenStandards for Data Mining and Predictive Analytics. CreativeSpace (Second Edition - Available onAmazon.com - http://www.amazon.com/dp/1470003244.

A. Guazzelli, M. Zeller, W. Lin, G. Williams (2009), /emphPMML: An Open Standard for SharingModels. The R journal, Volume 1/1, 60-65

See Also

pmml.

Page 15: Package ‘pmml’ - Universidad Autónoma del Estado de ... · PDF filePackage ‘pmml’ February 15, 2013 Type Package Title Generate PMML for various models Version 1.2.34 Date

pmml.rpart 15

Examples

# Build a simple randomForest model

library(randomForest)(iris.rf <- randomForest(Species ~ ., data=iris, ntree=2))

# Convert to pmml

pmml(iris.rf)

pmml.rpart Generate PMML for an rpart object

Description

Generate the PMML (Predictive Model Markup Language) representation of an rpart object (clas-sification tree). The rpart object (currently expected to be a classification tree) is converted into aPMML representation. The PMML can then be imported into other systems that accept PMML.

Usage

## S3 method for class ’rpart’pmml(model, model.name="RPart_Model", app.name="Rattle/PMML",

description="RPart Decision Tree Model", copyright=NULL,transforms=NULL, dataset=NULL, ...)

Arguments

model an rpart object.

model.name a name to give to the model in the PMML.

app.name the name of the application that generated the PMML.

description a descriptive text for the header of the PMML.

copyright the copyright notice for the model.

transforms a coded list of transforms performed.

dataset the orginal training dataset, if available.

... further arguments passed to or from other methods.

Details

The generated PMML can be imported into any PMML consuming application, such as TeradataWarehouse Miner and DB2. Generally, these applications convert the PMML into SQL for execu-tion across a database.

Teradata, for example, generates a single SELECT statement to implement a decision tree. In theExamples section below, we use the rpart example to build a model stored in the variable fit. Asegment of the PMML for this model is:

Page 16: Package ‘pmml’ - Universidad Autónoma del Estado de ... · PDF filePackage ‘pmml’ February 15, 2013 Type Package Title Generate PMML for various models Version 1.2.34 Date

16 pmml.rpart

<Node score="absent" recordCount="81"><True/><Node score="absent" recordCount="62"><SimplePredicate field="Start" operator="greaterOrEqual"

value="8.5"/><Node score="absent" recordCount="29"><SimplePredicate field="Start" operator="greaterOrEqual"

value="14.5"/></Node><Node score="absent" recordCount="33"><SimplePredicate field="Start" operator="lessThan"

value="14.5"/><Node score="absent" recordCount="12"><SimplePredicate field="Age" operator="lessThan"

value="55"/></Node><Node score="absent" recordCount="21"><SimplePredicate field="Age" operator="greaterOrEqual"

value="55"/><Node score="absent" recordCount="14"><SimplePredicate field="Age" operator="greaterOrEqual"

value="111"/></Node><Node score="present" recordCount="7"><SimplePredicate field="Age" operator="lessThan"

value="111"/></Node></Node></Node>

</Node><Node score="present" recordCount="19"><SimplePredicate field="Start" operator="lessThan"

value="8.5"/></Node></Node>

The resulting SQL from Teradata includes:

CREATE TABLE "MyScores" AS (SELECT "UserID",(CASE WHEN _node = 0 THEN ’absent’

WHEN _node = 1 THEN ’absent’WHEN _node = 2 THEN ’absent’WHEN _node = 3 THEN ’present’WHEN _node = 4 THEN ’present’ELSE NULL END)

(VARCHAR(8)) AS "Kyphosis"FROM(SELECT "UserID",

Page 17: Package ‘pmml’ - Universidad Autónoma del Estado de ... · PDF filePackage ‘pmml’ February 15, 2013 Type Package Title Generate PMML for various models Version 1.2.34 Date

pmml.rsf 17

(CASE WHEN ("Start" >= 8.5) AND ("Start" >= 14.5)THEN 0WHEN ("Start" >= 8.5) AND ("Start" < 14.5)

AND ("Age" < 55)THEN 1

WHEN ("Start" >= 8.5) AND ("Start" < 14.5)AND ("Age" >= 55) AND ("Age" >= 111)THEN 2WHEN ("Start" >= 8.5) AND ("Start" < 14.5)AND ("Age" >= 55) AND ("Age" < 111)THEN 3WHEN ("Start" < 8.5)THEN 4

ELSE -1 END) AS _nodeFROM "MyData" WHERE _node IS NOT NULL) AWHERE "Kyphosis" IS NOT NULL)

WITH DATA UNIQUE PRIMARY INDEX ("UserID");

Author(s)

<[email protected]>

References

Package home page: http://rattle.togaware.com

PMML home page: http://www.dmg.org

Zementis’ useful PMML convert: http://www.zementis.com/pmml_converters.htm

See Also

pmml.

Examples

library(rpart)(iris.rpart <- rpart(Species ~ ., data=iris))pmml(iris.rpart)

pmml.rsf Generate PMML for a Random Survival Forest (rsf) object

Description

Generate the Predictive Model Markup Language (PMML) representation of a randomSurvival-Forest forest object. In particular, this function gives the user the ability to save the geometry of aforest as a PMML XML document.

Page 18: Package ‘pmml’ - Universidad Autónoma del Estado de ... · PDF filePackage ‘pmml’ February 15, 2013 Type Package Title Generate PMML for various models Version 1.2.34 Date

18 pmml.rsf

Usage

## S3 method for class ’rsf’pmml(model,

model.name="rsfForest_Model",app.name="Rattle/PMML",description="Random Survival Forest Tree Model",copyright=NULL,transforms=NULL,...)

Arguments

model the forest object contained in an object of class randomSurvivalForest, asthat contained in the object returned by the function rsf with the parameter“forest=TRUE”.

model.name a name to give to the model in the PMML.

app.name the name of the application that generated the PMML.

description a descriptive text for the header of the PMML.

copyright the copyright notice for the model.

transforms transforms to represent within the PMML.

... further arguments passed to or from other methods.

Details

The Predictive Model Markup Language is an XML based language which provides a way forapplications to define statistical and data mining models and to share models between PMML com-pliant applications. More information about PMML and the Data Mining Group can be found athttp://www.dmg.org.

Use of PMML and pmml.rsf requires the XML package. Be aware that XML is a very verbosedata format. Reasonably sized trees and data sets can lead to extremely large text files. XML, whileachieving interoperability, is not an efficient data storage mechanism in this case.

This function is used to export the geometry of the forest to other PMML compliant applications,including graphics packages that are capable of printing binary trees. In addition, the user may wishto save the geometry of the forest for later retrieval and prediction on new data sets using pmml.rsftogether with pmml_to_rsf.

Value

An object of class XMLNode as that defined by the XML package. This represents the top level, orroot node, of the XML document and is of type PMML. It can be written to file with saveXML.

Author(s)

<[email protected]>

Page 19: Package ‘pmml’ - Universidad Autónoma del Estado de ... · PDF filePackage ‘pmml’ February 15, 2013 Type Package Title Generate PMML for various models Version 1.2.34 Date

pmml.rules 19

References

H. Ishwaran and Udaya B. Kogalur (2006). Random Survival Forests. Cleveland Clinic TechnicalReport.

A. Guazzelli, M. Zeller, W. Lin, G. Williams (2009), /emphPMML: An Open Standard for SharingModels. The R journal, Volume 1/1, 60-65

PMML home page: http://www.dmg.org

See Also

pmml.

Examples

# Until the rsf package is updated, do not run this.# library(randomSurvivalForest)# data(veteran, package = "randomSurvivalForest")# veteran.out <- rsf(Survrsf(time, status)~.,# data = veteran,# ntree = 5,# forest = TRUE)# veteran.forest <- veteran.out$forest# pmml(veteran.forest)

pmml.rules Generate PMML for arules objects

Description

Generate the PMML (Predictive Model Markup Language) representation of a rules or an item-set object from package arules. The PMML can then be imported into other systems that acceptPMML.

Usage

## S3 method for class ’rules’pmml(model, model.name="arules_Model",

app.name="Rattle/PMML",description="arules association rules model", copyright=NULL, ...)

## S3 method for class ’itemsets’pmml(model, model.name="arules_Model",

app.name="Rattle/PMML",description="arules frequent itemsets model", copyright=NULL, ...)

Page 20: Package ‘pmml’ - Universidad Autónoma del Estado de ... · PDF filePackage ‘pmml’ February 15, 2013 Type Package Title Generate PMML for various models Version 1.2.34 Date

20 pmmlCanExport

Arguments

model an rules or itemsets object.

model.name a name to give to the model in the PMML.

app.name the name of the application that generated the PMML.

description a descriptive text for the header of the PMML.

copyright the copyright notice for the model.

... further arguments passed to or from other methods.

Details

The generated PMML can be imported into any PMML consuming application.

Author(s)

Michael Hahsler (<[email protected]>)

References

Package arules home page: http://r-forge.r-project.org/projects/arules

Package home page: http://rattle.togaware.com

PMML home page: http://www.dmg.org

See Also

pmml.

pmmlCanExport Can this installation export PMML variables (particularly trans-forms).

Description

This function is designed to be overriden by other pacakges that implement pmml export, particu-larly of transforms.

Usage

pmmlCanExport(vname)

Arguments

vname a variable name to check whether it is exportable.

Author(s)

<[email protected]>

Page 21: Package ‘pmml’ - Universidad Autónoma del Estado de ... · PDF filePackage ‘pmml’ February 15, 2013 Type Package Title Generate PMML for various models Version 1.2.34 Date

pmmlLocalTransformations 21

See Also

pmml.

pmmlLocalTransformations

Handle transforms for pmml export.

Description

Generate and return a LocalTransformations element.

Usage

pmmlLocalTransformations(field, transforms=NULL, LTelement=NULL)

Arguments

field field$name is a vector of strings, and includes target; field$class is indexed byfields$name.

transforms transforms.

LTelement local transform element.

Details

Generate and return a LocalTransformations element that incldues each supplied field.

Author(s)

<[email protected]>, Zementis Inc.

References

PMML home page: http://www.dmg.org

See Also

pmml.

Page 22: Package ‘pmml’ - Universidad Autónoma del Estado de ... · PDF filePackage ‘pmml’ February 15, 2013 Type Package Title Generate PMML for various models Version 1.2.34 Date

22 pmmltoc

pmmltoc Generate C code from a PMML object - dummy function

Description

This is a dummy function that does nothing. Plugins for Rattle are starting to appear which imple-ment this for specific environments. This is experimental.

Usage

pmmltoc(p, name=NULL, includePMML=TRUE, includeMetaData=TRUE, exportClass=TRUE)

Arguments

p pmml.

name a name to give to the model in the C code.

includePMML include the actual PMML as comments.includeMetaData

include model information as comments.

exportClass whether to export class or probability.

Author(s)

<[email protected]>

See Also

pmml.

Page 23: Package ‘pmml’ - Universidad Autónoma del Estado de ... · PDF filePackage ‘pmml’ February 15, 2013 Type Package Title Generate PMML for various models Version 1.2.34 Date

Index

∗Topic interfacepmml, 2pmml.coxph, 3pmml.glm, 4pmml.hclust, 6pmml.kmeans, 7pmml.ksvm, 8pmml.lm, 9pmml.multinom, 11pmml.nnet, 12pmml.randomForest, 13pmml.rpart, 15pmml.rsf, 17pmml.rules, 19pmmlCanExport, 20pmmltoc, 22

∗Topic survivalpmml.rsf, 17

∗Topic treepmml.glm, 4pmml.multinom, 11pmml.randomForest, 13pmml.rpart, 15pmml.rsf, 17

hclust, 6

kmeans, 7ksvm, 9

pmml, 2, 4–7, 9, 10, 12–14, 17, 19–22pmml.coxph, 3pmml.glm, 3, 4pmml.hclust, 3, 6pmml.itemsets (pmml.rules), 19pmml.kmeans, 3, 7pmml.ksvm, 3, 8pmml.lm, 3, 9pmml.multinom, 3, 11pmml.nnet, 3, 12

pmml.randomForest, 3, 13pmml.rpart, 3, 15pmml.rsf, 3, 17pmml.rules, 3, 19pmmlCanExport, 20pmmlLocalTransformations, 21pmmltoc, 3, 22

23