condense                package:class                R Documentation

_C_o_n_d_e_n_s_e _t_r_a_i_n_i_n_g _s_e_t _f_o_r _k-_N_N _c_l_a_s_s_i_f_i_e_r

_D_e_s_c_r_i_p_t_i_o_n:

     Condense training set for k-NN classifier

_U_s_a_g_e:

     condense(train, class, store, trace = TRUE)

_A_r_g_u_m_e_n_t_s:

   train: matrix for training set 

   class: vector of classifications for test set 

   store: initial store set. Default one randomly chosen element of the
          set. 

   trace: logical. Trace iterations? 

_D_e_t_a_i_l_s:

     The store set is used to 1-NN classify the rest, and misclassified
     patterns are added to the store set. The whole set is checked
     until no additions occur.

_V_a_l_u_e:

     index vector of cases to be retained (the final store set).

_R_e_f_e_r_e_n_c_e_s:

     P. A. Devijver and J. Kittler (1982) _Pattern Recognition. A
     Statistical Approach._ Prentice-Hall, pp. 119-121.

     Ripley, B. D. (1996) _Pattern Recognition and Neural Networks._
     Cambridge.

     Venables, W. N. and Ripley, B. D. (2002) _Modern Applied
     Statistics with S._ Fourth edition.  Springer.

_S_e_e _A_l_s_o:

     'reduce.nn', 'multiedit'

_E_x_a_m_p_l_e_s:

     data(iris3)
     train <- rbind(iris3[1:25,,1], iris3[1:25,,2], iris3[1:25,,3])
     test <- rbind(iris3[26:50,,1], iris3[26:50,,2], iris3[26:50,,3])
     cl <- factor(c(rep("s",25), rep("c",25), rep("v",25)))
     keep <- condense(train, cl)
     knn(train[keep, , drop=FALSE], test, cl[keep])
     keep2 <- reduce.nn(train, keep, cl)
     knn(train[keep2, , drop=FALSE], test, cl[keep2])

