def score(self, clf, X, y, groups, scoring):
y_uniq = np.unique(y)
if len(y_uniq) == 2:
for ind, l in enumerate(y_uniq):
y[y==l] = ind
acc = cross_val_score(clf, X, y, cv=[(np.nonzero(groups==1)[0], np.nonzero(groups==0)[0])],
scoring=scoring, n_jobs=self.n_jobs)
return acc.mean()
After Change
self.ind_cache.append(np.ones(y.shape))
def score(self, clf, X, y, groups, scoring):
le = LabelEncoder()
y = le.fit_transform(y)
acc = cross_val_score(clf, X, y, cv=[(np.nonzero(groups==1)[0], np.nonzero(groups==0)[0])],
scoring=scoring, n_jobs=self.n_jobs)
return acc.mean()