Package pycv :: Package cs :: Package ml :: Package cla :: Module dataset :: Class WeightedCDataset
[hide private]
[frames] | no frames]

Class WeightedCDataset

source code

ml.Dataset --+    
             |    
  cla.CDataset --+
                 |
                WeightedCDataset
Known Subclasses:
ScoredWCDataset

A CDataset with weights attached to the samples.

Instance Methods [hide private]
 
__init__(self, separated_input_data, separated_weights=None, approx=-1) source code
 
new(self)
Make a copy of WeightedCDataset with a copy of weights and a reference to input_data.
source code
 
initialize_weights(self, value=-1)
Initialize weights if 'weights' is None
source code
 
set_weights(self, value=1)
Set all weight values to 'value', initialize if necessary
source code
 
get_twpc(self)
Get total weights per class.
source code
 
get_skewness(self) source code
 
get_tw(self)
Get total weights of all class(es).
source code
 
normalize_weights(self)
Normalize the weights so that the sum of all weights is equal to 1.
source code
 
scale_weights(self, i, thelambda)
Scale the weights of class i by thelambda.
source code
 
dofilter(self, j, filterarray)
Filter away some samples in class j.
source code
 
concat(self, j, input_data, weights=None)
Concatenate a few samples to class j.
source code
 
compute_Stats2m(self)
Compute moments up to 2nd-order.
source code
 
_get_masks(self, j)
Get the masks for instances of class j if approximation is needed.
source code
 
compute_Stats2e(self)
Compute per-element moments up to 2nd-order.
source code
 
compute_Stats2(self)
Compute (total weights, means, and covariances).
source code
Method Details [hide private]

__init__(self, separated_input_data, separated_weights=None, approx=-1)
(Constructor)

source code 
Overrides: cla.CDataset.__init__

dofilter(self, j, filterarray)

source code 

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.
Returns:
fr: filtering rate, the new number of samples of class j divided

by the old number of samples of class j. The class is updated.

Overrides: cla.CDataset.dofilter

concat(self, j, input_data, weights=None)

source code 
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.

Overrides: cla.CDataset.concat

compute_Stats2m(self)

source code 

Compute moments up to 2nd-order. The results are stored as a single Stats2m.

Output:
B: a Stats2m representing the obtained statistics

compute_Stats2e(self)

source code 

Compute per-element moments up to 2nd-order. The results are stored as a single Stats2e.

Output:
B: a Stats2e representing the obtained statistics

compute_Stats2(self)

source code 

Compute (total weights, means, and covariances). The results are stored as a single Stats2.

Output:
B: a Stats2 representing the obtained statistics