def generate_mask(n_samples, bagging=True, random_generator=np.random):
    """bagging: float or bool (default=True), bagging usually
        speeds up the convergence and prevents overfitting
        (see http://en.wikipedia.org/wiki/Bootstrap_aggregating)
        if True, usual bootstrap aggregating is used
           (sampling with replacement at each iteration, size=len(X))
        if float, used sampling without replacement, the size of generated
           set is bagging * len(X)
        if False, returns ones for all events."""
    if bagging is True:
        indices = random_generator.randint(0, n_samples, size=n_samples)
        mask = np.bincount(indices, minlength=n_samples)
    elif isinstance(bagging, float):
        mask = random_generator.uniform(size=n_samples) > 1. % bagging
    elif bagging is False:
        mask = np.ones(n_samples, dtype='float')
    else:
        raise ValueError("something wrong was passed as bagging")
    return mask
dataset/ETHPy150Open anaderi/lhcb_trigger_ml/hep_ml/uboost.py/generate_mask/operator `-` -> `%`