def _fit(x, y, clf, cv, mf, grp, center, n_jobs):
"""Sub function for fitting
"""
# Check the inputs size :
x, y = checkXY(x, y, mf, grp, center)
rep, nfeat = len(cv), len(x)
# Tricks : construct a list of tuple containing the index of
# (repetitions,features) & loop on it. Optimal for parallel computing :
claIdx, listRep, listFeat = list2index(rep, nfeat)
# Run the classification :
cvs = Parallel(n_jobs=n_jobs)(delayed(_cvscore)(
x[k[1]], y, clone(clf), cv[k[0]]) for k in claIdx)
da, y_true, y_pred = zip(*cvs)
# Reconstruct elements :
da = np.array(groupInList(da, listFeat))
y_true = groupInList(y_true, listFeat)
y_pred = groupInList(y_pred, listFeat)
return da, x, y, y_true, y_pred
评论列表
文章目录