learnConstant | R Documentation |
These functions are used to apply the generic train-and-test mechanism to a classifier that simply returns the same constant value for all inputs.
learnConstant(data, status, params, predfun)
predictConstant(newdata, details, status, ...)
makeLeaf(value, status = factor(c("L", "R")))
data |
The data matrix, with rows as features ("genes") and columns as the samples to be classified. |
status |
A factor, with two levels, classifying the samples. The length must
equal the number of |
params |
A list of additional parameters used by the classifier; see Details. |
predfun |
The function used to make predictions on new data, using the
trained classifier. Should always be set to
|
newdata |
Another data matrix, with the same number of rows as |
details |
A list of additional parameters describing details about the particular classifier; see Details. |
... |
Optional extra parameters required by the generic "predict" method. |
value |
The constant value to be returned by the predictor. This should be one of the levels of the status vairable. |
The input arguments to both learnConstant
and predictConstant
are dictated by the requirements of the general train-and-test
mechanism provided by the Modeler-class
.
The "Constant" classifier is designed for use in the decision trees that are part of this package. They will be used as the "predictors" in leaf nodes, which always make the same prediction on any samples that make their way down to that node.
We provied the makeLeaf
fnction as a convenience to create
constant classifiers, by specifying their preferred value. (This value
could also be provided as an extra/optional pafameter to the
Modeler
constructor.) For must uses, it is easier to simply use
makeLeaf
and ignore the learnConstant
and
predictConstant
. The result of fitting the model using
learnConstant
or makeLeaf
is a member of the
FittedModel-class
.
The learnConstant
and the makeLeaf
functions return an
object of the FittedModel-class
, representing a
Constant classifier that has been fitted on a training data
set.
The predictConstant
function returns a factor containing the
predictions of the model when applied to the new data set, of length
equal tothe number of columns (samples).
Kevin R. Coombes <krc@silicovore.com>
See Modeler-class
and
Modeler
for details about how to train and test
models. See FittedModel-class
and
FittedModel
for details about the structure of
the object returned by learnConstant
.
# simulate some data
data <- matrix(rnorm(100*20), ncol=20)
status <- factor(rep(c("A", "B"), each=10))
# create a constnt modeler.
fm <- makeLeaf("A", factor(c("A", "B")))
# Make predictions on some new simulated data
predictConstant(data, fm@details, status)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.