r function to pmml success but not recognized in container -


here example of r script using couple of library

library(pmml) library(pmmltransformations) data(iris) irisbox <- wrapdata(iris) irisbox <- functionxform(irisbox,origfieldname="sepal.length",            newfieldname="sepal.length.transformed",            formulatext="ifelse(sepal.length>5,sepal.length*1.2, sepal.length*.8)") mod1 <- lm(sepal.length.transformed ~ petal.length, irisbox$data) pmml(mod1, transform = irisbox) 

the function works fine , create nice pmml output. however, ifelse statement not recognizable function in pmml 4_3. can recommend alternative above script generate pmml workable command?

i recognize discretizexform recommended in pmmltransformations package cumbersome reluctant use since has read breakpoints outside files.

the pmmltransformations package not know how handle "ifelse" r function, , passes through as-is. that's why resulting pmml document contains apply@function="ifelse" when should containing apply@function="if".

the pmml "if" built-in function able represent if-else branching logic:

implements if-then-else logic. else part optional. if else part absent , boolean value false missing value returned.

as solution, please consider switching r2pmml package, lets feature engineering inside formulas (as opposed "boxing" data.frame objects), including full support "ifelse" r function:

library("randomforest") library("r2pmml")  iris.rf = randomforest(species ~ ifelse(sepal.length>5,sepal.length*1.2, sepal.length*.8) + ., data = iris)  r2pmml(iris.rf, "iris.pmml") 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -