Description Usage Arguments Details Value References See Also Examples
Classify multivariate observations using the prototype representation of the data
obtained with the kmc
function.
1 | predict.kmc(object, newdata = NULL, ...)
|
object |
An object of class |
newdata |
A |
... |
Further arguments. Currently unused. |
Classification of a new observation is based on the prototypes found in the training data by function kmc
.
This function is a method for the generic function predict()
for class
"kmc"
.
It can be invoked by calling predict(x)
for an object x
of the
appropriate class, or directly by calling predict.kmc(x)
regardless of
the class of the object.
A list
with components:
class |
The predicted class labels (a |
posterior |
Matrix of class posterior probabilities. |
T. Hastie, R. Tibshirani, and J. Friedman. The Elements of Statistical Learning: Data Mining, Inference, and Prediction. Springer Series in Statistics. Springer, New York, 2001.
kmc
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # generate waveform data
library(mlbench)
data.train <- as.data.frame(mlbench.waveform(300))
data.test <- as.data.frame(mlbench.waveform(200))
# prediction based on the nearest prototype
object <- kmc(classes ~ ., data = data.train, K = 3, wf = "rectangular", k = 1)
pred <- predict(object, data.test[,-22])
mean(pred$class != data.test$classes)
# prediction based on the 3 nearest prototypes with weighting
object <- kmc(classes ~ ., data = data.train, K = 3, wf = "gaussian", bw = 1, k = 3)
pred <- predict(object, data.test[,-22])
mean(pred$class != data.test$classes)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.