コード例 #1
0
    def train(self, data, **args):

        # store the current cpu time:
        self._clock = time.clock()

        if not data.labels.numericLabels:
            # check if there is a class that is not represented in the training data:
            if min(data.labels.classSize) == 0:
                raise ValueError, 'there is a class with no data'

            # store just as much about the labels as is needed:
            self.labels = misc.Container()
            self.labels.addAttributes(data.labels,
                                      ['numClasses', 'classLabels'])
        # if dealing with a VectorDataSet test data needs to have the same features
        if data.__class__.__name__ == 'VectorDataSet':
            self.featureID = data.featureID[:]

        data.train(**args)
        # if there is some testing done on the data, it requires the training data:
        if data.testingFunc is not None:
            self.trainingData = data
コード例 #2
0
def convert (object, attributes) :
    obj = misc.Container()
    obj.addAttributes(object, attributes)
    return obj
コード例 #3
0
    def __init__(self, arg=None, **args):

        PyMLobject.__init__(self, arg, **args)
        if type(arg) == type(''):
            self.load(arg)
        self.log = misc.Container()