Write SVM object to file

DESCRIPTION:

This function exports an SVM object (trained by svm) to two specified files. One is in the format that the function 'svm_load_model' of libsvm can read. The other is for scaling data, containing a data with centers and scales for all variables.

USAGE:

write.svm(object, svm.file, scale.file)

ARGUMENTS:

object
Object of class "svm", created by svm.
svm.file
filename to export the svm object to.
scale.file
filename to export the scaling data of the svm object to.

DETAILS:

This function is useful when SVM models trained in R shall be used in other environments. The SVM model is saved in the standard format of libsvm. The scaling data is written to a separate file because scaling data is not included in the standard format of libsvm. The format of the scaling data file is a n times 2 matrix: the n-th row corresponds to the n-th dimension of the data, the colums being formed of the corresponding mean and scale.

AUTHOR(S):

Tomomi TAKASHINA (based on 'predict.svm' by David Meyer) mailto:t.takashina@computer.org

SEE ALSO:

EXAMPLES:

attach(iris.df)

## classification mode
# default with factor response:
model <- svm (Species~., data=iris.df)

# export SVM object to file
write.svm(model, svm.file = "iris-classifier.svm", scale.file = "iris-classifier.scale")

# read scale file
# the n-th row is corresponding to n-th dimension. The 1st column contains the
# center value, the 2nd column is the scale value.

read.table("iris-classifier.scale",sep=",")