Exemple #1
0
 def __init__(self, uniform_variables, knn, exclude_self=True, penalize_large_preds=True):
     """ A is rectangular matrix, in each row we have only two '1's,
     all other elements are zeros, these two '1's are placed in the columns, corresponding to neighbours
     exclude_self: bool, exclude self from knn?
     """
     self.knn = knn
     self.exclude_self = exclude_self
     self.penalize_large_preds = penalize_large_preds
     AbstractMatrixLossFunction.__init__(self, uniform_variables)
Exemple #2
0
 def __init__(self, uniform_variables, n_rows, knn=5, knn_factor=3, large_preds_penalty=1.):
     """A general loss,
     at each iteration it takes some random event from train dataset,
     and selects randomly knn of its knn*knn_factor neighbours, the process is repeated 'n_rows' times"""
     self.n_rows = n_rows
     self.knn = knn
     self.knn_factor = knn_factor
     self.large_preds_penalty = large_preds_penalty
     AbstractMatrixLossFunction.__init__(self, uniform_variables)
Exemple #3
0
    def __init__(self, uniform_variables, knn=5, distinguish_classes=True, diagonal=0.):
        """A matrix is square, each row corresponds to a single event in train dataset,
        in each row we put ones to the closest neighbours of that event for signal.
        For background we have identity matrix.

        If distinguish_classes==True, only events of the same class are chosen.
        """
        self.knn = knn
        self.distinguish_classes = distinguish_classes
        self.diagonal = diagonal
        AbstractMatrixLossFunction.__init__(self, uniform_variables)
Exemple #4
0
 def __init__(self, uniform_variables, knn=None, distance_dependence=None, large_preds_penalty=0.,
              row_normalize=False):
     """If knn is None, the matrix will be filled, otherwise it will be sparse
     with knn as number of nonzero cells,
     distance dependence is function, that takes distance between i-th and j-th
     events and returns a_ij
     """
     self.knn = knn
     self.distance_dependence = distance_dependence
     self.large_pred_penalty = large_preds_penalty
     self.row_normalize = row_normalize
     AbstractMatrixLossFunction.__init__(self, uniform_variables)
Exemple #5
0
 def __init__(self, uniform_variables, knn=10, uniform_label=1, row_norm=1., diagonal=0., distinguish_classes=True):
     """A matrix is square, each row corresponds to a single event in train dataset, in each row we put ones
     to the closest neighbours of that event if this event from class along which we want to have uniform prediction.
     :param list[str] uniform_variables: the features, along which uniformity is desired
     :param int knn: the number of nonzero elements in the row, corresponding to event in 'uniform class'
     :param int|list[int] uniform_label: the label (labels) of 'uniform classes'
     :param int diagonal: float, A + diagonal * Identity is used.
     """
     self.knn = knn
     self.row_norm = row_norm
     self.diagonal = diagonal
     self.uniform_label = check_uniform_label(uniform_label)
     self.distinguish_classes = distinguish_classes
     AbstractMatrixLossFunction.__init__(self, uniform_variables)