learnLogic | R Documentation |
These functions are used to apply the generic train-and-test mechanism to a classifier that uses the concept of logic regression.
learnLogic(data, status, params, pfun, debug = FALSE)
predictLogic(newdata, details, status, debug = FALSE, ...)
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. |
pfun |
The function used to make predictions on new data, using the
trained classifier. Should always be set to
|
debug |
A logical value; should debug information be printer? |
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. |
The input arguments to both learnLogic
and predictLogic
are dictated by the requirements of the general train-and-test
mechanism provided by the Modeler-class
.
The Logic classifier is similar to the logistic regression classifiers
already included in the Modeler
package. The crucial difference
is that the logic regression model assumes that all predictors are
binary variables (thought of as logical vectors) and that logical
combinations (based on and, or, and not operators) of predictors
shouod also be considered. Internally, if the trainng data consist of
continuous data, we use the bimodalIndex
function to dichotomize the trainng data. The same cutpoints are later
used to dichotomize the test data in the predict
function.
Feature selection is handled by the bagging routines in the
logicFS
package. The default call to
logic.bagging
sets specific values for
parameters B=20
, nleaves=10
, rand=54321
and for
logreg.anneal.control
. If you want to add additional
parameters, you can use the params
parameter in
learnLogic
.
The result of fitting the model using learnLogic
is a member of
the FittedModel-class
. In additon to storing
the prediction function (pfun
) and the training data and status,
the FittedModel stores those details about the model that are required
in order to make predictions of the outcome on new data. The
details
object is appropriate for sending as the second
argument to the predictLogic
function in order to make
predictions with the model on new data. Note that the status vector
here is the one used for the training data, since
the prediction function only uses the levels of this factor to
make sure that the direction of the predictions is interpreted
correctly.
The learnLogic
function returns an object of the
FittedModel-class
, representing a Logic
classifier that has been fitted on a training data
set.
The predictLogic
function returns a factor containing the
predictions of the model when applied to the new data set.
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 learnLogic
.
nr <- 100 # features
nc <- 40 # samples
set.seed(97531)
bimat <- matrix(rbinom(nr*nc, 1, 0.45), nrow = nr)
dimnames(bimat) <- list(paste0("B", 1:nr),
paste0("S", 1:nc))
stat <- rbinom(nc, 1, 0.37)
myMod <- learn(logicModeler, bimat, stat)
table(predict(myMod), stat) # on the diagonal
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.