<commit_before>"""

Training monitors for validation, early stopping, etc.

"""

import sklearn.utils
from . import AdditiveModel
from ..util.group import check_qids, get_groups
from ..util.sort import get_sorted_y


class ValidationMonitor(object):
    """Monitor for early stopping via validation set."""
    def __init__(self, X, y, qids, metric, stop_after=100,
                 trim_on_stop=True):
        self.X, self.y = sklearn.utils.check_X_y(
            X, y, dtype=sklearn.tree._tree.DTYPE)
        self.qids = qids
        self.metric = metric
        self.stop_after = stop_after
        self.trim_on_stop = trim_on_stop
<commit_msg>Update monitors.py<commit_after>"""

Training monitors for validation, early stopping, etc.

"""

import sklearn.utils
from . import AdditiveModel
from ..util.group import check_qids, get_groups
from ..util.sort import get_sorted_y


class ValidationMonitor(object):
    """Monitor for early stopping via validation set."""
    def __init__(self, X, y, qids, metric, stop_after=100,
                 trim_on_stop=True):
        if len(X) == 0:
            raise ValueError("A validation set can not be empty!")
        self.X, self.y = sklearn.utils.check_X_y(
            X, y, dtype=sklearn.tree._tree.DTYPE)
        self.qids = qids
        self.metric = metric
        self.stop_after = stop_after
        self.trim_on_stop = trim_on_stop

{'fraction_non_alphanumeric': 0.1, 'fraction_numerical': 0.005035971223021582, 'mean_word_length': 2.853185595567867, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5737007', 'n_tokens_mistral': 442, 'n_tokens_neox': 428, 'n_words': 118}