def gen_cv_preds(clf, arr, sel_score, num_chunks=<NUM_LIT:3>):
cv_len = int(math.floor(len(sel_score) / num_chunks))<EOL>chunks = []<EOL>for i in range(<NUM_LIT:0>, num_chunks):<EOL><INDENT>range_min = i * cv_len<EOL>range_max = ((i + <NUM_LIT:1>) * cv_len)<EOL>if i == num_chunks - <NUM_LIT:1>:<EOL><INDENT>range_max = len(sel_score)<EOL><DEDENT>chunks.append(range(range_min, range_max))<EOL><DEDENT>preds = []<EOL>set_score = numpy.asarray(sel_score, dtype=numpy.int)<EOL>chunk_vec = numpy.asarray(range(<NUM_LIT:0>, len(chunks)))<EOL>for i in xrange(<NUM_LIT:0>, len(chunks)):<EOL><INDENT>loop_inds = list(<EOL>chain.from_iterable([chunks[int(z)] for z, m in enumerate(range(<NUM_LIT:0>, len(chunks))) if int(z) != i]))<EOL>sim_fit = clf.fit(arr[loop_inds], set_score[loop_inds])<EOL>preds.append(list(sim_fit.predict(arr[chunks[i]])))<EOL><DEDENT>all_preds = list(chain(*preds))<EOL>return(all_preds)<EOL>
Generates cross validated predictions using an input classifier and data.
clf is a classifier that implements that implements the fit and predict methods.
arr is the input data array (X)
sel_score is the target list (y).  y[n] corresponds to X[n,:]
num_chunks is the number of cross validation folds to use
Returns an array of the predictions where prediction[n] corresponds to X[n,:]