def _score_models(self, db_conn, X, y, y_bin):
        """Get cross-validated test scores for each model"""

        self._metric = self._metrics[self.score_metric]

        if (self.verbose):
            sys.stderr.write('\nscoring models:\n')

        insert_stmt = """insert into model_scores (model_idx, score, probs)
                         values (?,?,?)"""

        select_stmt = """select pickled_model
                         from fitted_models
                         where model_idx = ? and fold_idx = ?"""

        # nuke existing scores
        with db_conn:
            stmt = """drop index if exists model_scores_index;
                      delete from model_scores;"""
            db_conn.executescript(stmt)

        curs = db_conn.cursor()

        # build probs array using the test sets for each internal CV fold
        for model_idx in xrange(self._n_models):
            probs = np.zeros((len(X), self._n_classes))

            for fold_idx, fold in enumerate(self._folds):
                _, test_inds = fold

                curs.execute(select_stmt, [model_idx, fold_idx])
                res = curs.fetchone()
                model = loads(str(res[0]))

                probs[test_inds] = model.predict_proba(X[test_inds])

            score = self._metric(y, y_bin, probs)

            # save score and probs array
            with db_conn:
                vals = (model_idx, score, buffer(dumps(probs)))
                db_conn.execute(insert_stmt, vals)

            if (self.verbose):
                if ((model_idx + 1) % 50 == 0):
                    sys.stderr.write('%d\n' % (model_idx + 1))
                else:
                    sys.stderr.write('.')

        if (self.verbose):
            sys.stderr.write('\n')

        with db_conn:
            stmt = """create index model_scores_index
                      on model_scores (model_idx)"""
            db_conn.execute(stmt)
dataset/ETHPy150Open dclambert/pyensemble/ensemble.py/EnsembleSelectionClassifier._score_models/original