wrap_svm: S3 wrapper for e1071 SVM

View source: R/wrap_svm.R

wrap_svmR Documentation

S3 wrapper for e1071 SVM

Description

Fits an 'e1071' support vector machine with a consistent interface. Supports classification and regression.

Usage

wrap_svm(x, y, ...)

## S3 method for class 'wrap_svm'
predict(object, newx, type = c("class", "prob"), ...)

## S3 method for class 'wrap_svm'
print(x, ...)

Arguments

x

A matrix or data.frame of features.

y

A factor or character vector for classification, numeric for regression.

...

Additional arguments passed to [e1071::svm()]. 'probability = TRUE' is set automatically for classification; do not override this if you need 'type = "prob"' predictions.

object

A fitted 'wrap_svm' object.

newx

A matrix or data.frame of new observations.

type

'"class"' (default) for class labels, '"prob"' for a probability matrix. Ignored for regression.

Value

An object of class 'wrap_svm' with fields:

fit

The fitted svm model.

levels

Class levels (NULL for regression).

task

"classification" or "regression".

Examples


X <- as.matrix(iris[, 1:4])
y <- iris$Species
mod <- wrap_svm(X, y, kernel = "radial")
predict(mod, newx = X, type = "class")
predict(mod, newx = X, type = "prob")


X <- as.matrix(iris[, 1:4])
y <- iris$Species
mod <- wrap_svm(X, y, kernel = "radial")
predict(mod, newx = X, type = "class")
predict(mod, newx = X, type = "prob")


mlS3 documentation built on April 29, 2026, 1:08 a.m.