Calculating threshold for big training sets