n-of-classes              package:clue              R Documentation

_C_l_a_s_s_e_s _i_n _a _P_a_r_t_i_t_i_o_n

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

     Determine the number of classes and the class ids in a partition
     of objects.

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

     n_of_classes(x)
     cl_class_ids(x)

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

       x: an object representing a (hard or soft) partition.

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

     These function are generic functions.

     The methods provided in package 'clue' handle the partitions
     obtained from clustering functions in the base R distribution, as
     well as packages 'cclust', 'cluster', 'e1071', and 'mclust' (and
     of course, 'clue' itself).

     Note that the number of classes is taken as the number of distinct
     class ids actually used in the partition, and may differ from the
     number of columns in a membership matrix representing the
     partition.

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

     For 'n_of_classes', an integer giving the number of classes in the
     partition.

     For 'cl_class_ids', a vector of integers with the corresponding
     class ids.  For soft partitions, the class ids returned are those
     of the "nearest" hard partition obtained by taking the class ids
     of the (first) maximal membership values.

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

     'is.cl_partition'

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

     data("Cassini")
     party <- kmeans(Cassini$x, 3)
     n_of_classes(party)
     ## A simple confusion matrix:
     table(cl_class_ids(party), Cassini$classes)
     ## For an "oversize" membership matrix representation:
     n_of_classes(cl_membership(party, 6))

