LVQs_recall {nnlib2Rcpp} | R Documentation |
Classify Data Using LVQs Code-Book Vectors
Description
This function simplifies applying a trained supervised Learning Vector Quantizer Neural Network (LVQ NN) to data (as compared to using the LVQs
module directly). It uses the codebook vector information returned by LVQs_train
to assign data to classes.
Usage
LVQs_recall(codebook_info,
data,
k = 1,
recall_rewards_limit = 1,
verbose = FALSE,
...)
Arguments
codebook_info |
LVQ codebook vector information (as returned by |
data |
data to be classified, numeric matrix (2d, cases in rows, variables in columns). |
k |
number of neighbours (codebook vectors) considered. See |
recall_rewards_limit |
do not use codebook vectors that were rewarded less that this limit during training. |
verbose |
show extra information and plots. |
... |
additional parameters for k-Nearest Neighbour Classification function ( |
Details
This is a k-Nearest Neighbor Classifier (employs class::knn
), customized for LVQs codebook vectors.
Value
Factor of classifications ids for data
(as returned by function class::knn
, see help("knn",package = class)
).
Author(s)
Vasilis N. Nikolaidis <vnnikolaidis@gmail.com>
References
Simpson, P. K. (1991). Artificial neural systems: Foundations, paradigms, applications, and implementations. New York: Pergamon Press. p.88.
Venables, W. N. & Ripley, B. D. (2002) Modern Applied Statistics with S. Fourth Edition. Springer, New York. ISBN 0-387-95457-0
See Also
Examples
# start with the well-know iris dataset:
DATA <- iris[,1:4]
CLASS <- as.factor(iris$Species)
# Randomly split the data into training and testing sets:
indices <- sample(1:nrow(DATA), size = .5 * nrow(DATA))
train_data <- DATA[indices, ]
train_class <- CLASS[indices]
test_data <- DATA[-indices, ]
test_class <- CLASS[-indices]
# train LVQ using train data and class:
cv <- LVQs_train(train_data,
train_class,
number_of_output_nodes_per_class = 4)
# recall (classify) test data:
cl <- LVQs_recall(cv, test_data)
# Compare known and returned test data classifications:
print(table(test_class, cl))