neurosynth/analysis/classify.py
def feat_select_cvs(self, scoring=None, feat_select=None):
        """ Returns cross validated scores (just like cross_val_score),
        but includes feature selection as part of the cross validation loop """

        scores = []
        self.predictions = []

        for train, test in self.cver:
            X_train, X_test, y_train, y_test = self.X[
                train], self.X[test], self.y[train], self.y[test]

            if feat_select is not None:
                # Get which features are kept
                fs = feature_selection(
                    feat_select, X_train, y_train)

                self.features_selected.append(fs)

                # Filter X to only keep selected features
                X_train, X_test = X_train[
                    :, fs], X_test[:, fs]

            # Set scoring (not implement as accuracy is default)

            # Train classifier
            self.clf.fit(X_train, y_train)

            # Test classifier
            predicition, s = get_score(
                X_test, y_test, self.clf, scoring=scoring)

            scores.append(s)
            self.predictions.append((y_test, predicition))

        return np.array(scores)
def feat_select_cvs(self, scoring=None, feat_select=None):
        """ Returns cross validated scores (just like cross_val_score),
        but includes feature selection as part of the cross validation loop """

        scores = []
        self.predictions = []

        for train, test in self.cver:
            X_train, X_test, y_train, y_test = self.X[
                train], self.X[test], self.y[train], self.y[test]

            if feat_select is not None:
                # Get which features are kept
                fs = feature_selection(
                    feat_select, X_train, y_train)

                self.features_selected.append(fs)

                # Filter X to only keep selected features
                X_train, X_test = X_train[
                    :, fs], X_test[:, fs]

            # Set scoring (not implement as accuracy is default)

            # Train classifier
            self.clf.fit(X_train, y_train)

            # Test classifier
            predicition, s = get_score(
                X_test, y_test, self.clf, scoring=scoring)

            scores.append(s)
            self.predictions.append((y_test, predicition))

        return np.array(scores)
Returns cross validated scores (just like cross_val_score),
        but includes feature selection as part of the cross validation loop