pmml_prcomp | R Documentation |
Extract one principal component from a prcomp object together with the centering and scaling information and generate the PMML representation.
pmml_prcomp(model, j = 1, ...)
model |
A prcomp object. |
j |
Index of the eigenvector for which the PMML will be created. Per default, the PMML will be constructed based on the eigenvector of the first principal component. |
... |
Further arguments passed to |
In general, each principal component represents a linear combination of the
original input values. Therefore, the information of a single principal
component can be expressed as a linear function and as such be represented as
a linear model in PMML. pmml_prcomp()
extracts one eigenvector
from a prcomp object together with the centering and scaling information if
they are present. At first, it leverages FunctionXform()
from
pmmlTransformations to add the centering and scaling information to an
empty WrapData object. Even though this step is a kind of dirty hack, it is the
only option to capture the centering and scaling as pre-processing steps in
the PMML later. Next, a "minimal", artifical lm object is created based on
the coefficients of the selected principal component. "minimal" in the way
that all information is present which pmml.lm()
from pmml needs
to create a valid PMML. In a final step the pre-processing steps and
the "minimal" lm object are passed to pmml.lm()
to create the PMML.
An object of class XMLNode which is of type PMML.
iris <- iris[, -5]
pc_iris <- prcomp(iris, center = FALSE, scale. = FALSE)
pmml_prcomp(pc_iris)
pc_iris <- prcomp(iris, center = TRUE, scale. = TRUE)
pmml_prcomp(pc_iris, 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.