// Make a data splitting object for cross validation
from sklearn.cross_validation import LeaveOneLabelOut, cross_val_score
cv = LeaveOneLabelOut(session_labels)
mask_names = ["mask_vt", "mask_face", "mask_house"]
mask_scores = {}
After Change
// Make a data splitting object for cross validation
from sklearn.model_selection import LeaveOneGroupOut, cross_val_score
cv = LeaveOneGroupOut()
mask_names = ["mask_vt", "mask_face", "mask_house"]
mask_scores = {}
mask_chance_scores = {}
for mask_name in mask_names:
print("Working on mask %s" % mask_name)
// For decoding, standardizing is often very important
mask_filename = haxby_dataset[mask_name][0]
masker = NiftiMasker(mask_img=mask_filename, standardize=True)
masked_timecourses = masker.fit_transform(
func_filename)[task_mask]
mask_scores[mask_name] = {}
mask_chance_scores[mask_name] = {}
for category in categories:
print("Processing %s %s" % (mask_name, category))
classification_target = (stimuli[task_mask] == category)
mask_scores[mask_name][category] = cross_val_score(classifier,
masked_timecourses,
classification_target,
cv=cv.split(X=masked_timecourses, groups=session_labels),
scoring="roc_auc",
)