

def fit(self, X, y, sample_weight=None, neighbours_matrix=None):
    'Build a boosted classifier from the training set (X, y).\n        Parameters\n        ----------\n        X : array-like of shape = [n_samples, n_features]\n            The training input samples.\n\n        y : array-like of shape = [n_samples]\n            The target values (integers that correspond to classes).\n\n        sample_weight : array-like of shape = [n_samples], optional\n            Sample weights. If None, the sample weights are initialized to\n            ``1 / n_samples``.\n\n        neighbours_matrix: array-like of shape [n_samples, n_neighbours],\n            each row contains indices of signal neighbours\n            (neighbours should be computed for background too),\n            if None, this matrix is computed.\n\n        Returns\n        -------\n        self : object\n            Returns self.\n        '
    if (self.smoothing < 0):
        raise ValueError('Smoothing must be non-negative')
    if (not isinstance(self.base_estimator, BaseEstimator)):
        raise TypeError('estimator must be a subclass of BaseEstimator')
    if (self.n_estimators <= 0):
        raise ValueError('n_estimators must be greater than zero.')
    if (self.learning_rate <= 0):
        raise ValueError('learning_rate must be greater than zero')
    if (self.algorithm not in ('SAMME', 'SAMME.R')):
        raise ValueError(('algorithm %s is not supported' % self.algorithm))
    if (self.algorithm == 'SAMME.R'):
        if (not hasattr(self.base_estimator, 'predict_proba')):
            raise TypeError("uBoostBDT with algorithm='SAMME.R' requires that the weak learner have a predict_proba method.\nPlease change the base estimator or set algorithm='SAMME' instead.")
    assert np.in1d(y, [0, 1]).all(), 'only two-class classification is implemented'
    self.signed_uniform_label = ((2 * self.uniform_label) - 1)
    if (neighbours_matrix is not None):
        assert (np.shape(neighbours_matrix) == (len(X), self.n_neighbors)), 'Wrong shape of neighbours_matrix'
        self.knn_indices = neighbours_matrix
    else:
        assert (self.uniform_variables is not None), 'uniform_variables should be set'
        self.knn_indices = computeKnnIndicesOfSameClass(self.uniform_variables, X, y, self.n_neighbors)
    if (sample_weight is None):
        sample_weight = (np.ones(len(X), dtype=np.float) / len(X))
    else:
        assert np.all((sample_weight >= 0.0)), 'the weights should be non-negative'
        sample_weight /= np.sum(sample_weight)
    self.estimators_ = []
    self.estimator_weights_ = []
    self.score_cuts_ = []
    X_train_variables = self.get_train_vars(X)
    y = column_or_1d(y)
    (X_train_variables, y) = check_arrays(X_train_variables, y)
    if self.keep_debug_info:
        self.debug_dict = defaultdict(list)
    self.random_generator = check_random_state(self.random_state)
    self._boost(X_train_variables, y, sample_weight)
    self.score_cut = (self.signed_uniform_label * compute_bdt_cut(self.target_efficiency, (y == self.uniform_label), (self.predict_score(X) * self.signed_uniform_label)))
    assert np.allclose(self.score_cut, self.score_cuts_[(- 1)], rtol=1e-10, atol=1e-10), "score cut doesn't appear to coincide with the staged one"
    assert (len(self.estimators_) == len(self.estimator_weights_) == len(neighbours_matrix.score_cuts_))
    return self

dataset/ETHPy150Open anaderi/lhcb_trigger_ml/hep_ml/uboost.py uBoostBDT.fit/VarMisuse@513/1133 `self`->`neighbours_matrix`