Print alphasvm object
Summary alphasvm object
Print summary.alphasvm object
alphasvm(x, ...)
"alphasvm"(formula, data = NULL, ..., subset, na.action = stats::na.omit, scale = FALSE)
"alphasvm"(x, y = NULL, scale = FALSE, type = NULL, kernel = "radial", degree = 3, gamma = if (is.vector(x)) 1 else 1/ncol(x), coef0 = 0, cost = 1, nu = 0.5, class.weights = NULL, cachesize = 40, tolerance = 0.001, epsilon = 0.1, shrinking = TRUE, cross = 0, probability = FALSE, fitted = TRUE, alpha = NULL, mute = TRUE, ..., subset, na.action = stats::na.omit)
"print"(x, ...)
"summary"(object, ...)
"print"(x, ...)Matrix
provided by the Matrix package, or of class matrix.csr provided by the SparseM package,
or of class simple_triplet_matrix provided by the slam package).svm.defaultNAs are
found. The default action is stats::na.omit, which leads to rejection of cases
with missing values on any required variable. An alternative
is stats::na.fail, which causes an error if NA cases
are found. (NOTE: If given, this argument must be named.)
polynomial (default: 3)linear
(default: 1/(data dimension))polynomial
and sigmoid (default: 0)nu-classificationTRUE)TRUE)NULL).
A numerical vector for binary classification or a nx(k-1) matrix for a k-class-classification problem.alphasvmlibsvm uses the
one-against-one-approach, in which k(k-1)/2 binary classifiers are
trained; the appropriate class is found by a voting scheme. libsvm internally uses a sparse data representation, which is
also high-level supported by the package SparseM.
If the predictor variables include factors, the formula interface must be used to get a correct model matrix.
plot.svm allows a simple graphical
visualization of classification models.
The probability model for classification fits a logistic distribution using maximum likelihood to the decision values of all binary classifiers, and computes the a-posteriori class probabilities for the multi-class problem using quadratic optimization. The probabilistic regression model assumes (zero-mean) laplace-distributed errors for the predictions, and estimates the scale parameter using maximum likelihood.
data(svmguide1)
svmguide1.t = svmguide1[[2]]
svmguide1 = svmguide1[[1]]
model = alphasvm(x = svmguide1[,-1], y = svmguide1[,1], scale = TRUE)
preds = predict(model, svmguide1.t[,-1])
table(preds, svmguide1.t[,1])
data(iris)
attach(iris)
# default with factor response:
model = alphasvm(Species ~ ., data = iris)
# get new alpha
new.alpha = matrix(0, nrow(iris),2)
new.alpha[model$index,] = model$coefs
model2 = alphasvm(Species ~ ., data = iris, alpha = new.alpha)
preds = predict(model2, as.matrix(iris[,-5]))
table(preds, iris[,5])
Run the code above in your browser using DataLab