User 3652 | 3/16/2016, 5:44:03 PM
I am taking a ML course on Coursera , while implementing Decision Tree on graphlab it is taking too much time as if i was coding 1970 machine.
def intermediate_node_num_mistakes(labels_in_node): # Corner case: If labels_in_node is empty, return 0 if len(labels_in_node) == 0: return 0 # Count the number of 1's (safe loans) ## YOUR CODE HERE pos=0 for i in range(0,len(labels_in_node)): if(labels_in_node[i]==1l): pos+=1 if(len(labels_in_node)-pos>pos): pos = len(labels_in_node)-pos # Count the number of -1's (risky loans) ## YOUR CODE HERE # Return the number of mistakes that the majority classifier makes. ## YOUR CODE HERE return len(labels_in_node)-pos
If i pass an Array of order
10^6 , my code will go in limbo state