vendredi 22 juillet 2016

Appended object to a set is `NoneType` python 2.7

I have a huge array of labels which I make unique via:

unique_train_labels = set(train_property_labels)

Which prints out as set([u'A', u'B', u'C']). I want to create a new set of unique labels with a new label called "no_region", and am using:

unique_train_labels_threshold = unique_train_labels.add('no_region')

However, this prints out to be None.

My ultimate aim is to use these unique labels to later generate a random array of categorical labels via:

    rng = np.random.RandomState(101)

    categorical_random = rng.choice(list(unique_train_labels), len(finalTestSentences))
    categorical_random_threshold = rng.choice(list(unique_train_labels_threshold), len(finalTestSentences))

From the docs it says that set.add() should generate a new set, which seems not to be the case (hence I can't later call list(unique_train_labels_threshold))




Aucun commentaire:

Enregistrer un commentaire