baseSVM | R Documentation |
Prediction by support vector machine (SVM) with two different settings: 'classification' and 'regression'.
baseSVM( trainData, testData, predMode = c("classification", "probability", "regression"), paramlist = list(tuneP = TRUE, kernel = "radial", gamma = 10^(-3:-1), cost = 10^(-2:2)) )
trainData |
The input training dataset. The first column is the label or the output. For binary classes, 0 and 1 are used to indicate the class member. |
testData |
The input test dataset. The first column is the label or the output. For binary classes, 0 and 1 are used to indicate the class member. |
predMode |
The prediction mode. Available options are c('classification', 'probability', 'regression'). |
paramlist |
A set of model parameters defined in an R list object. The valid option: list(kernel, gamma, cost, tuneP).
|
Hyperparameter tuning is recommended in many biological data mining applications. The best parameters can be determined via an internal cross validation.
The predicted output for the test data.
Junfang Chen
svm
## Load data methylfile <- system.file('extdata', 'methylData.rds', package='BioMM') methylData <- readRDS(methylfile) dataY <- methylData[,1] ## select a subset of genome-wide methylation data at random methylSub <- data.frame(label=dataY, methylData[,c(2:2001)]) trainIndex <- sample(nrow(methylSub), 12) trainData = methylSub[trainIndex,] testData = methylSub[-trainIndex,] library(e1071) predY <- baseSVM(trainData, testData, predMode='classification', paramlist=list(tuneP=FALSE, kernel='radial', gamma=10^(-3:-1), cost=10^(-3:1))) testY <- testData[,1] accuracy <- classifiACC(dataY=testY, predY=predY) print(accuracy)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.