train.svm: train.svm

View source: R/train.R

train.svmR Documentation

train.svm

Description

Provides a wrapping function for the svm.

Usage

train.svm(formula, data, ..., subset, na.action = na.omit, scale = TRUE)

Arguments

formula

a symbolic description of the model to be fit.

data

an optional data frame containing the variables in the model. By default the variables are taken from the environment which ‘svm’ is called from.

...

additional parameters for the low level fitting function svm.default

subset

An index vector specifying the cases to be used in the training sample. (NOTE: If given, this argument must be named.)

na.action

A function to specify the action to be taken if NAs are found. The default action is na.omit, which leads to rejection of cases with missing values on any required variable. An alternative is na.fail, which causes an error if NA cases are found. (NOTE: If given, this argument must be named.)

scale

A logical vector indicating the variables to be scaled. If scale is of length 1, the value is recycled as many times as needed. Per default, data are scaled internally (both x and y variables) to zero mean and unit variance. The center and scale values are returned and used for later predictions.

Value

A object svm.prmdt with additional information to the model that allows to homogenize the results.

Note

the parameter information was taken from the original function svm.

See Also

The internal function is from package svm.

Examples


# Classification
data("iris")

n <- seq_len(nrow(iris))
.sample <- sample(n, length(n) * 0.75)
data.train <- iris[.sample,]
data.test <- iris[-.sample,]

modelo.svm <- train.svm(Species~., data.train)
modelo.svm
prob <- predict(modelo.svm, data.test , type = "prob")
prob
prediccion <- predict(modelo.svm, data.test , type = "class")
prediccion

# Regression
len <- nrow(swiss)
sampl <- sample(x = 1:len,size = len*0.20,replace = FALSE)
ttesting <- swiss[sampl,]
ttraining <- swiss[-sampl,]
model.svm <- train.svm(Infant.Mortality~.,ttraining)
prediction <- predict(model.svm, ttesting)
prediction


traineR documentation built on Nov. 10, 2023, 1:15 a.m.

Related to train.svm in traineR...