jpmml / r2pmml

R library for converting R models to PMML
GNU Affero General Public License v3.0
73 stars 18 forks source link

Support for `kernlab::ksvm` models #1

Open vruusmann opened 9 years ago

vruusmann commented 9 years ago

The standard pmml package can convert ksvm objects that have been trained using the kernlab::ksvm function. Unfortunately, the converter implementation is rather limited, because it fails to handle ksvm objects that have been trained using alternative means.

For example, it is impossible to convert a ksvm object that was trained using the caret package:

library("caret")
library("kernlab")
library("pmml")

iris.ksvm = ksvm(Species ~ ., data = iris)
class(iris.ksvm)

ksvm.pmml = pmml(iris.ksvm, dataset = iris)

iris_x = iris[, c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width")]
iris_y = iris[, c("Species")]

iris.train = train(x = iris_x, y = iris_y, data = iris, method = "svmRadial")
class(iris.train$finalModel)

# Error in if (field$class[[1]][1] == "numeric") { :
#   argument is of length zero
train.pmml = pmml(iris.train$finalModel, dataset = iris)
vruusmann commented 9 years ago

Moved to jpmml/jpmml-converter/issues/1