Example #1
0
 def castToRegression(self, values):
     """Converts data set into a SupervisedDataSet for regression. Classes
     are used as indices into the value array given."""
     regDs = SupervisedDataSet(self.indim, 1)
     fields = self.getFieldNames()
     fields.remove('target')
     for f in fields:
         regDs.setField(f, self[f])
     regDs.setField('target', values[self['class'].astype(int)])
     return regDs
Example #2
0
 def __init__(self, inp, target, M, inp_transform=None, tgt_transform=None):
     """
     Initialize an MDN dataset.
     @param inp: int or np.array, input data or input dimension
     @param target: int or np.array, target data or target dimension
     @param M: number of Gaussian kernels #TODO: remove this from dataset!
     @param inp_transform: set of input transformations that have been
     applied to the dataset #TODO: remove
     @param tgt_transform: #TODO: remove
     """
     SupervisedDataSet.__init__(self, inp, target)
     self.M = M
     if np.isscalar(target):
         self.c = target
     else:
         self.c = target.shape[1]
     self.inp_transform=inp_transform
     self.tgt_transform=tgt_transform
Example #3
0
    def __init__(self, inp, target=1, nb_classes=0, class_labels=None):
        """Initialize an empty dataset.

        `inp` is used to specify the dimensionality of the input. While the
        number of targets is given by implicitly by the training samples, it can
        also be set explicity by `nb_classes`. To give the classes names, supply
        an iterable of strings as `class_labels`."""
        # FIXME: hard to keep nClasses synchronized if appendLinked() etc. is used.
        SupervisedDataSet.__init__(self, inp, target)
        self.addField('class', 1)
        self.nClasses = nb_classes
        if len(self) > 0:
            # calculate class histogram, if we already have data
            self.calculateStatistics()
        self.convertField('target', int)
        if class_labels is None:
            self.class_labels = list(set(self.getField('target').flatten()))
        else:
            self.class_labels = class_labels
        # copy classes (may be changed into other representation)
        self.setField('class', self.getField('target'))
Example #4
0
 def __init__(self, indim, targetdim):
     SupervisedDataSet.__init__(self, indim, targetdim)
     # add field that stores the beginning of a new episode
     self.addField('sequence_index', 1)
     self.append('sequence_index', 0)
     self.currentSeq = 0
Example #5
0
 def clear(self):
     SupervisedDataSet.clear(self, True)
     self._appendUnlinked('sequence_index', [0])
     self.currentSeq = 0
 def __init__(self, indim, targetdim):
     SupervisedDataSet.__init__(self, indim, targetdim)
     # add field that stores the beginning of a new episode
     self.addField('sequence_index', 1)
     self.append('sequence_index', 0)
     self.currentSeq = 0
 def clear(self):
     SupervisedDataSet.clear(self, True)
     self._appendUnlinked('sequence_index', [0])
     self.currentSeq = 0