Description Usage Arguments Details Value Author(s) See Also Examples
The learn
function provides an abstraction that can be used to
fit a binary classification model to a training data set.
1 |
model |
An object of the |
data |
A matrix containing the training data, with rows as features and columns as samples to be classified. |
status |
A factor, with two levels, containing the known classification of the training data. |
prune |
A "pruning" funciton; that is, a funciton that takes two arguments (a data matrix and a class factor) and returns a logical vector indicating which features to retain. |
Objects of the Modeler-class
contain functions to learn
models from training data to make predictions on new test data. These
functions have to be prepared as pairs, since they have a shared
opinion about how to record and use specific details about the
parameters of the model. As a result, the learn function is
implemented by:
1 2 3 |
An object of the FittedModel-class
.
Kevin R. Coombes <krc@silicovore.com>
See predict
for how to make predictions on new test data
from an object of the FittedModel-class
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # set up a generic RPART model
rpart.mod <- Modeler(learnRPART, predictRPART, minsplit=2, minbucket=1)
# simulate fake data
data <- matrix(rnorm(100*20), ncol=20)
status <- factor(rep(c("A", "B"), each=10))
# learn the specific RPART model
fm <- learn(rpart.mod, data, status)
# show the predicted results from the model on the trianing data
predict(fm)
# set up a nearest neighbor model
knn.mod <- Modeler(learnKNN, predictKNN, k=3)
# fit the 3NN model on the same data
fm3 <- learn(knn.mod, data, status)
# show its performance
predict(fm3)
|
Loading required package: ClassDiscovery
Loading required package: cluster
Loading required package: oompaBase
Loading required package: ClassComparison
A B
1 1 0
2 1 0
3 1 0
4 1 0
5 1 0
6 1 0
7 1 0
8 1 0
9 1 0
10 1 0
11 0 1
12 0 1
13 0 1
14 0 1
15 0 1
16 0 1
17 0 1
18 0 1
19 0 1
20 0 1
[1] A A A A A A A A B A B B A B B B B B B B
Levels: A B
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.