def __call__(self, i, model, localvars):
        assert i == self._prev_iter + 1
        self._prev_iter = i

        if isinstance(model, AdditiveModel):
            if self._y_pred is None:
                self._y_pred = model.predict(self.X)
            else:
                self._y_pred += model.iter_y_delta(i, self.X)
            y_pred = self._y_pred
        else:
            y_pred = model.predict(self.X)

        score = 0.0
        for qid, a, b in self._query_groups:
            sorted_y = get_sorted_y(self.y[a:b], y_pred[a:b])
            score += self.metric.evaluate(qid, sorted_y)
        score /= len(self._query_groups)

        if self._best_score is None or score > self._best_score:
            self._best_score = score
            self._best_score_i = i

        since = i - self._best_score_i
        if self.trim_on_stop and \
                (since >= self.stop_after or i + 1 == model.n_estimators):
            model.trim(self._best_score_i + 1)
            return True

        return 'C:{:12.4f} B:{:12.4f} S:{:3d}'.format(
            score, self._best_score, since)
Returns True if the model should stop early.
dataset/ETHPy150Open jma127/pyltr/pyltr/models/monitors.py/ValidationMonitor.__call__