EkNNfit function

Training of the EkNN classifier

Training of the EkNN classifier

EkNNfit optimizes the parameters of the EkNN classifier.

EkNNfit( x, y, K, param = NULL, alpha = 0.95, lambda = 1/max(as.numeric(y)), optimize = TRUE, options = list(maxiter = 300, eta = 0.1, gain_min = 1e-06, disp = TRUE) )

Arguments

  • x: Input matrix of size n x d, where n is the number of objects and d the number of attributes.
  • y: Vector of class labels (of length n). May be a factor, or a vector of integers from 1 to M (number of classes).
  • K: Number of neighbors.
  • param: Initial parameters (default: NULL).
  • alpha: Parameter α\alpha (default: 0.95)
  • lambda: Parameter of the cost function. If lambda=1, the cost function measures the error between the plausibilities and the 0-1 target values. If lambda=1/M, where M is the number of classes (default), the piginistic probabilities are considered in the cost function. If lambda=0, the beliefs are used.
  • optimize: Boolean. If TRUE (default), the parameters are optimized.
  • options: A list of parameters for the optimization algorithm: maxiter (maximum number of iterations), eta (initial step of gradient variation), gain_min (minimum gain in the optimisation loop), disp (Boolean; if TRUE, intermediate results are displayed during the optimization).

Returns

A list with five elements:

  • param: The optimized parameters.
  • cost: Final value of the cost function.
  • err: Leave-one-out error rate.
  • ypred: Leave-one-out predicted class labels (coded as integers from 1 to M).
  • m: Leave-one-out predicted mass functions. The first M columns correspond to the mass assigned to each class. The last column corresponds to the mass assigned to the whole set of classes.

Details

If the argument param is not supplied, the function EkNNinit is called.

Examples

## Iris dataset data(iris) x<-iris[,1:4] y<-iris[,5] fit<-EkNNfit(x,y,K=5)

References

T. Denoeux. A k-nearest neighbor classification rule based on Dempster-Shafer theory. IEEE Transactions on Systems, Man and Cybernetics, 25(05):804--813, 1995.

L. M. Zouhal and T. Denoeux. An evidence-theoretic k-NN rule with parameter optimization. IEEE Transactions on Systems, Man and Cybernetics Part C, 28(2):263--271,1998.

See Also

EkNNinit, EkNNval

Author(s)

Thierry Denoeux.

  • Maintainer: Thierry Denoeux
  • License: GPL-3
  • Last published: 2023-11-09

Useful links