def __init__(self, separated_input_data, separated_weights = None, approx = -1 ): CDataset.__init__(self,separated_input_data) self.weights = separated_weights # If approx > 0 then approximately compute mu, cov, var, std using # 100*approx percent of the total weights self.approx = approx
def concat(self,j,input_data,weights = None): """Concatenate a few samples to class j. Input: j: class j input_data: an array of samples weights: the additional weights of the samples if weights is None xor self.weights is None: raise an error else: concatenate the new weights to the old weights list Output: The WeightedCDataset is updated. """ CDataset.concat(self,j,input_data) if (weights is None) ^ (self.weights is None): raise ValueError('weights and self.weights are not compatible') if weights is not None: self.weights[j] = concatenate([self.weights[j],weights])
def dofilter(self,j,filterarray): """Filter away some samples in class j. Input: j: class j filterarray: a 'bool' numpy.array of size self.nspc[j] Output: fr: filtering rate, the new number of samples of class j divided by the old number of samples of class j. The WeightedCDataset is updated. """ if self.weights is not None: self.weights[j] = self.weights[j][filterarray] return CDataset.dofilter(self,j,filterarray)