1. A computer-implemented method comprising: receiving a training set of items X that are each labeled as belonging to a respective class c, from among a set of classes C; initializing a reduced dataset S as an empty set; for each class c of the set of classes C, initializing, as an empty set, a set Wc for identifying (i) items whose nearest neighbor belongs to a different class, when the reduced dataset S is not an empty set, or (ii) all items that are labeled as belonging to the class c, when the reduced dataset S is an empty set; determining that the reduced dataset S is an empty set, then, for each class c of the set of classes C: assigning all items of the training set X that are labeled as belonging to the class c to the set Wc, generating a representation Yc of the items that are assigned to the set Wc, and assigning the representation Yc of the items to the reduced dataset S as belonging to the class c; after (i) determining that the reduced dataset S is an empty set, and (ii) assigning the representations Yc of the items to the reduced dataset S, re-initializing, as an empty set, the set Wc for each class c of the set of classes C; determining that the reduced dataset S is not an empty set, then, for each class c of the set of classes C: identifying whether any items that are labeled as being members of the class have a nearest neighbor, among the representations Yc of the items in the reduced dataset S, that belongs to a different class, if any items are identified that are labeled as being members of the class have a nearest neighbor, among the representations of the items in the reduced dataset S, that belongs to a different class are identified, generating a representation of the identified items, and assigning the representation of identified items as belonging to the class c; and using the reduced dataset S to identify a class to which a particular item belongs.