Пример #1
0
    def __init__(self, inp, target, 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.
        SequentialDataSet.__init__(self, inp, target)
        # we want integer class numbers as targets
        self.convertField('target', int)
        if len(self) > 0:
            # calculate class histogram, if we already have data
            self.calculateStatistics()
        self.nClasses = nb_classes
        self.class_labels = range(self.nClasses) if class_labels is None else class_labels
        # copy classes (targets may be changed into other representation)
        self.setField('class', self.getField('target'))
 def __init__(self, indim, targetdim):
     SequentialDataSet.__init__(self, indim, targetdim)
     self.addField('importance', targetdim)
     self.link.append('importance')
Пример #3
0
 def removeSequence(self, index):
     """Remove sequence (including class field) from the dataset."""
     self.assignClasses()
     self.linkFields(['input', 'target', 'class'])
     SequentialDataSet.removeSequence(self, index)
     self.unlinkFields(['class'])