Description Usage Arguments Value Examples
Create and train SVM model object.
1 2 3 4 5 6 7 8 9 10 11 12 | SVM(x, ...)
## S3 method for class 'formula'
SVM(formula, data, ...)
## Default S3 method:
SVM(x, y, core = "libsvm", kernel = "linear",
prep = "none", transductive.learning = FALSE,
transductive.posratio = -1, C = 1, gamma = if (is.vector(x)) 1 else
1/ncol(x), coef0 = 0, degree = 3, class.weights = NULL,
example.weights = NULL, cache_size = 100, tol = 0.001, max.iter = -1,
verbosity = 4, class.type = "one.versus.all", svm.options = "", ...)
|
x |
Training data without labels in one of the following formats:
|
... |
other arguments not used by this method. |
formula |
Can be passed with |
data |
Can be passed instead of |
y |
Labels in one of the followinf formts: |
core |
Support Vector Machine library to use in traning, available are:
|
kernel |
Kernel type as string, available are:
|
prep |
Preprocess method as string, available are: |
transductive.learning |
Option got SVM model to deduce missing labels from the dataset,
default: |
transductive.posratio |
Fraction of unlabeled examples to be classified into the positive class as float from [0,1], default: the ratio of positive and negative examples in the training data |
C |
Cost/complexity parameter, default: |
gamma |
Parameter for |
coef0 |
For |
degree |
For |
class.weights |
Named vector with weight fir each class, default: |
example.weights |
Vector of the same length as training data with weights for each traning example,
default: |
cache_size |
Cache memory size in MB, default: |
tol |
Tolerance of termination criterion, default: |
max.iter |
Depending on library:
|
verbosity |
How verbose should the process be, as integer from [1,6], default: |
class.type |
Multiclass algorithm type as string,
available are: |
svm.options |
enables to pass all svmlight command lines arguments for more advanced options, for details see http://svmlight.joachims.org/ |
SVM model object
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | ## Not run:
# train SVM from data in x and labels in y
svm <- SVM(x, y, core="libsvm", kernel="linear", C=1)
# train SVM using a dataset with both data and lables and a formula pointing to labels
formula <- target ~ .
svm <- SVM(formula, data, core="svmlight", kernel="rbf", gamma=1e3)
# train a model with 2eSVM algorithm
data(svm_breast_cancer_dataset)
ds <- svm.breastcancer.dataset
svm.2e <- SVM(x=ds[,-1], y=ds[,1], core="libsvm", kernel="linear", prep = "2e", C=10);
# more at \url{http://r.gmum.net/samples/svm.2e.html}
# train SVM on a multiclass data set
data(iris)
# with "one vs rest" strategy
svm.ova <- SVM(Species ~ ., data=iris, class.type="one.versus.all", verbosity=0)
# or with "one vs one" strategy
svm.ovo <- SVM(x=iris[,1:4], y=iris[,5], class.type="one.versus.one", verbosity=0)
# we can use svmlights sample weighting feature, suppose we have weights vector
# with a weight for every sample in the traning data
weighted.svm <- SVM(formula=y~., data=df, core="svmlight", kernel="rbf", C=1.0,
gamma=0.5, example.weights=weights)
# svmlight alows us to determine missing labels from a dataset
# suppose we have a labels y with missing labels marked as zeros
svm.transduction <- SVM(x, y, transductive.learning=TRUE, core="svmlight")
# for more in-depth examples visit \url{http://r.gmum.net/getting_started.html}
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.