def __init__(self, X, y, batch_size, process_fn=None):
"""A `Sequence` implementation that returns balanced `y` by undersampling majority class.
Args:
X: The numpy array of inputs.
y: The numpy array of targets.
batch_size: The generator mini-batch size.
process_fn: The preprocessing function to apply on `X`
"""
self.X = X
self.y = y
self.batch_size = batch_size
self.process_fn = process_fn or (lambda x: x)
self.pos_indices = np.where(y == 1)[0]
self.neg_indices = np.where(y == 0)[0]
self.n = min(len(self.pos_indices), len(self.neg_indices))
self._index_array = None
评论列表
文章目录