Description Usage Arguments Details Value Author(s) References See Also Examples
View source: R/exportedFuncs.R
SWAP.KTSP.Classify
classifies new test samples
using KTSP coming out of the function SWAP.KTSP.Train
.
1 | SWAP.KTSP.Classify(inputMat, classifier, DecisionFunc)
|
inputMat |
is a numerical matrix containing the
measurements (e.g., gene expression data)
to be used with a K-TSP classifier to classify the samples
in a specific class or the other.
In this numerical matrix the columns represent the samples
and the rows represent the features (e.g., genes)
used by the classification rule.
Note that |
classifier |
the classifier obtained by invoking
|
DecisionFunc |
is the function used to generate the final
classification prediction by combining the comparisons of the TSPs
in the classifier. By default each sample is classified
according to the class voted by the majority of the TSPs
(“majority wins” principle).
Different decision rules can be also specified using
alternative functions passed |
The SWAP.KTSP.Classify
classifies new test samples
based on a specific decision rule. By default, each sample
is classified based on the the majority voting rule of
the comparisons of TSPs in the classifier.
Alternative rules can be defined by the user and passed
to SWAP.KTSP.Classify
using the argument
DecisionFunc
. A decision function takes
as its input a logical vector x
corresponding
to the individual decision of each TSP
(TRUE
if the first feature in the pair is
larger then the second, FALSE
in the opposite case). The output of the
DecisionFunction
is a single logical
value summarizing all votes of the individual TSPs
(see examples below).
This function returns the predicted class for each sample in the form of a factor.
Bahman Afsari bahman.afsari@gmail.com, Luigi Marchionni marchion@jhu.edu, Wikum Dinalankara wdinala1@jhmi.edu
See switchBox for the references.
SWAP.KTSP.Train
,
SWAP.Filter.Wilcoxon
,
SWAP.CalculateSignedScore
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | ##################################################
### Load gene expression data for the training set
data(trainingData)
### Show group variable for the TRAINING set
table(trainingGroup)
##################################################
### Train a classifier using default filtering function based on the Wilcoxon test
classifier <- SWAP.KTSP.Train(matTraining, trainingGroup, krange=c(3, 5, 8:15))
### Show the classifier
classifier
### Apply the classifier to the TRAINING set using default decision rule
trainingPrediction <- SWAP.KTSP.Classify(matTraining, classifier)
### Resubstitution performance in the TRAINING set
### Define a "positive" test result if needed
table(trainingPrediction, trainingGroup)
### Use an alternative DecideFunction to classify each patient
### Here for instance at least two TSPs must agree
trainingPrediction <- SWAP.KTSP.Classify(matTraining, classifier,
DecisionFunc = function(x) sum(x) > 5.5 )
### Contingency table for the TRAINING set
table(trainingPrediction, trainingGroup)
##################################################
### Testing on new data
### Load the example data for the TEST set
data(testingData)
### Show group variable for the TEST set
table(testingGroup)
### Apply the classifier to one sample of the TEST set using default decision rule
testPrediction <- SWAP.KTSP.Classify(matTesting[ , 1, drop=FALSE], classifier)
### Show prediction
testPrediction
### Apply the classifier to the complete the TEST set
### using decision rule defined above (agreement of two TSPs)
testPrediction <- SWAP.KTSP.Classify(matTesting,
classifier, DecisionFunc = function(x) sum(x) > 5.5)
### Show prediction
head(testPrediction, n=10)
### Contingency table for the TEST set
table(testPrediction, testingGroup)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.