Description Usage Arguments Details Value Author(s) Examples
SVMtrainInterface
generates a trained SVM classifier and SVMpredictInterface
uses it to make predictions on a test data set.
1 2 3 4 5 6 7 8 9 10 11 12 | ## S4 method for signature 'matrix'
SVMtrainInterface(measurements, classes, ...)
## S4 method for signature 'DataFrame'
SVMtrainInterface(measurements, classes, ..., verbose = 3)
## S4 method for signature 'MultiAssayExperiment'
SVMtrainInterface(measurements, targets = names(measurements), ...)
## S4 method for signature 'svm,matrix'
SVMpredictInterface(model, test, ...)
## S4 method for signature 'svm,DataFrame'
SVMpredictInterface(model, test, classes = NULL, returnType = c("class", "score", "both"), verbose = 3)
## S4 method for signature 'svm,MultiAssayExperiment'
SVMpredictInterface(model, test, targets = names(test), ...)
|
measurements |
Either a |
classes |
Either a vector of class labels of class |
returnType |
Default: |
test |
An object of the same class as |
targets |
If |
model |
A fitted model as returned by |
... |
Variables not used by the |
verbose |
Default: 3. A number between 0 and 3 for the amount of progress messages to give. This function only prints progress messages if the value is 3. |
If measurements
is an object of class MultiAssayExperiment
, the factor of
sample classes must be stored in the DataFrame accessible by the colData
function
with column name "class"
.
For SVMtrainInterface
, a trained SVM classifier of type svm
.
For SVMpredictInterface
, either a factor vector of predicted classes, a vector of secores for the
second class, or a table of both the class labels and second class scores, depending on the setting
of returnType
.
Dario Strbenac
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | if(require(e1071))
{
# Genes 76 to 100 have differential expression.
genesMatrix <- sapply(1:25, function(sample) c(rnorm(100, 9, 2)))
genesMatrix <- cbind(genesMatrix, sapply(1:25, function(sample)
c(rnorm(75, 9, 2), rnorm(25, 14, 2))))
classes <- factor(rep(c("Poor", "Good"), each = 25))
colnames(genesMatrix) <- paste("Sample", 1:ncol(genesMatrix))
rownames(genesMatrix) <- paste("Gene", 1:nrow(genesMatrix))
trainingSamples <- c(1:20, 26:45)
testingSamples <- c(21:25, 46:50)
classifier <- SVMtrainInterface(genesMatrix[, trainingSamples],
classes[trainingSamples], kernel = "linear")
SVMpredictInterface(classifier, genesMatrix[, testingSamples])
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.