naiveBayesKernel {ClassifyR} | R Documentation |
Kernel density estimates are fitted to the training data and a naive Bayes classifier is used to classify samples in the test data.
## S4 method for signature 'matrix' naiveBayesKernel(measurements, classes, test, ...) ## S4 method for signature 'DataFrame' naiveBayesKernel(measurements, classes, test, densityFunction = density, densityParameters = list(bw = "nrd0", n = 1024, from = expression(min(featureValues)), to = expression(max(featureValues))), weighted = c("both", "unweighted", "weighted"), weight = c("all", "height difference", "crossover distance", "sum differences"), minDifference = 0, returnType = c("class", "score", "both"), verbose = 3) ## S4 method for signature 'MultiAssayExperiment' naiveBayesKernel(measurements, test, targets = names(measurements), ...)
measurements |
Either a |
classes |
Either a vector of class labels of class |
test |
An object of the same class as |
targets |
If |
... |
Unused variables by the three top-level methods passed to the internal method which does the classification. |
densityFunction |
Default: |
densityParameters |
A list of options for |
weighted |
Default: |
weight |
Default: |
minDifference |
Default: 0. The minimum difference in densities for a feature to be allowed to vote. Can be a vector of cutoffs. If no features for a particular sample have a difference large enough, the class predicted is simply the largest class. |
returnType |
Default: |
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 weighted
is TRUE
, then a sample's predicted class is the class with
the largest sum of weights, each scaled for the number of samples in
the training data of each class. Otherwise, when weighted
is FALSE
,
each feature has an equal vote, and votes for the class with the largest weight,
scaled for class sizes in the training set.
The variable name of each feature's measurements in the iteration over all features is featureValues
.
This is important to know if each feature's measurements need to be referred to in the specification of
densityParameters
, such as for specifying the range of x values of the density function to be computed.
For example, see the default value of densityParameters
above.
If weight
is "crossover distance"
, the crossover points are computed by considering the
distance between y values of the two densities at every x value. x values for which the sign of the difference
changes compared to the difference of the closest lower value of x are used as the crossover points.
Setting weight to "sum differences"
is intended to find a mix of features which are strongly
differentially expressed and differentially variable.
A vector or list of class prediction information, as long as the number of samples in the test data, or lists of such information, if a variety of predictions is generated.
Dario Strbenac, John Ormerod
trainMatrix <- matrix(rnorm(1000, 8, 2), ncol = 10) classes <- factor(rep(c("Poor", "Good"), each = 5)) # Make first 30 genes increased in value for poor samples. trainMatrix[1:30, 1:5] <- trainMatrix[1:30, 1:5] + 5 testMatrix <- matrix(rnorm(1000, 8, 2), ncol = 10) # Make first 30 genes increased in value for sixth to tenth samples. testMatrix[1:30, 6:10] <- testMatrix[1:30, 6:10] + 5 naiveBayesKernel(trainMatrix, classes, testMatrix)