mercredi 24 janvier 2018

sample X examples from each class label

l have a dataset (numpy vector) with 50 classes and 9000 training examples.

x_train=(9000,2048)
y_train=(9000,)  # Classes are strings 
classes=list(set(y_train))

l would like to build a sub-dataset such that each class will have 5 examples

which means l get 5*50=250 training examples. Hence my sub-dataset will take this form :

sub_train_data=(250,2048)
sub_train_labels=(250,)

Remark : we take randomly 5 examples from each class (total number of classes = 50)

Thank you




Aucun commentaire:

Enregistrer un commentaire