TuriCreate: SFrame filter_by()

Create a subset SFrame by filtering a bigger SFrame




Filter using a single string


dogs_SFrame = image_training_SFrame.filter_by(values="dog", column_name="label", exclude=False) 
print(dogs_SFrame["label"][0:15]) 
['dog', 'dog', 'dog', 'dog', 'dog', 'dog', 'dog', 'dog', 'dog', 'dog', 'dog', 'dog', 'dog', 'dog', 'dog']


Filter using an array of strings


animals = ["dog", "cat", "bird"] 
animals_SFrame = image_training_SFrame.filter_by(values=animals, column_name='label', exclude=False) 
print(animals_SFrame["label"][0:15]) 
['bird', 'cat', 'cat', 'dog', 'bird', 'dog', 'bird', 'bird', 'cat', 'dog', 'cat', 'bird', 'cat', 'cat', 'dog']




Example:

training_sframes = {}
for label in unique_labels:
    #print (label)
    training_sframes[label] = image_training_SFrame.filter_by(
        values = label,
        column_name = "label",
        exclude = False)
   
for key_name in training_sframes: # dictionary training_sframes
    print(key_name)