I am looking for a better way to count the array values than what I have described below (Graphlab Create with Python)
labels = graphlab.SArray([-1, -1, 1, 1, 1])
plus_ones_count = list(labels).count(1)
# plus_ones_count outputs 3
minu_ones_count = list(labels).count(-1)
# minu_ones_count outputs 2
Thank you for any pointers or suggestions.
After additional experiments len(labels[labels == ]) seems to be doing a better job (for my requirement where the desired number range is small) Just for others reference I am providing the code I used to measure three approaches. If you know any other better way of doing it (or) caveats please let me know.
import numpy as np
from random import randint
from collections import Counter
for data_set_size in [10, 100, 1000, 10000, 100000, 1000000]:
labels = graphlab.SArray([randint(-1,1) for p in range(0, data_set_size)])
print "Data set size: ", data_set_size
%timeit -n 100 l = list(labels); l.count(-1), l.count(0), l.count(1)
%timeit -n 100 len(labels[labels == -1]), len(labels[labels == 0]), len(labels[labels == 1])
%timeit -n 100 label_count = Counter(labels); label_count.get(-1), label_count.get(0), label_count.get(1)