Learn R Programming

fda.usc (version 0.9.4)

classif.knn: k-Nearest Neighbor Classifier from Functional Data

Description

Performs k-nearest neighbor classification of a test set using a training set. For each row of the test set, the k nearest training set vectors are found. Make supervised classification for training functional data via k-nearest neighbors method. The method classifies the functional data to the group with the highest number of nearest neighbors. In case of tie the data is classified in the group with a shorter distance.

Usage

classif.knn(group, fdataobj, w = NULL, 
knn = seq(3, floor(min(table(group))/3),by = 2),metric=metric.lp,...)

Arguments

group
Factor of length n
fdataobj
fdata class object.
w
Optional case weights.
knn
Vector of number of nearest neighbors considered
metric
Metric function, by default metric.lp
...
Further arguments passed to or from other methods. Arguments to be passed for metric function.

Value

  • fdataobjfdata class object.
  • groupFactor of length n
  • group.estVector of classes of the k nearest neighbors.
  • prob.groupMatrix of predicted class probabilities. For each functional point shows the probability of each possible group membership.
  • prob.classificationProbability of correct classification by group for the estimated number of k neighbors knn.opt.
  • knn.optNumber of neighbors with highest probability of correct classification.
  • DMatrix of distances of the optimal k nearest neighbors knn.opt.
  • max.probHighest probability of correct classification.
  • misclassificationVector of probability of misclassification by number of neighbors knn.
  • knnVector of number of k nearest neighbors considered.
  • CA call of function classif.knn.

Details

The nearest neighbor method classif.knn to estimate the number of k nearest neighbors to classify a sample of best practice. In the training sample is known for each data functional group (group). You can use different metric functions or types of distance metric by changing the parameters: p and w of metric.lp function.

References

Ferraty, F. and Vieu, P. (2006). Nonparametric functional data analysis. Springer Series in Statistics, New York. Ferraty, F. and Vieu, P. (2006). NPFDA in practice. Free access on line at http://www.lsp.ups-tlse.fr/staph/npfda/

See Also

See Also as predict.classif

Examples

Run this code
data(phoneme)
mlearn<-phoneme[["learn"]]
glearn<-phoneme[["classlearn"]]

out=classif.knn(glearn,mlearn)
summary.classif(out)

Run the code above in your browser using DataLab