Exemplo n.º 1
0
    def testBinaryBootstrapError(self):

        testY = numpy.array([-1, -1, 1, 1, 1])
        predY = 1 - testY

        trainY = numpy.array([-1, -1, 1, 1, 1])
        predTrainY = 1 - trainY

        self.assertEquals(Evaluator.binaryBootstrapError(testY, testY, trainY, trainY, 0.5), 0.0)

        self.assertEquals(Evaluator.binaryBootstrapError(testY, testY, trainY, predTrainY, 0.5), 0.5)
        self.assertEquals(Evaluator.binaryBootstrapError(testY, testY, trainY, predTrainY, 0.1), 0.9)

        self.assertEquals(Evaluator.binaryBootstrapError(testY, predY, trainY, trainY, 0.1), 0.1)
Exemplo n.º 2
0
def computeBootstrapError(args):
    """
    Used in conjunction with the parallel model selection. Trains and then tests
    on a seperate test set and evaluated the bootstrap error. 
    """
    (trainX, trainY, testX, testY, learner) = args
    learner.learnModel(trainX, trainY)
    predTestY = learner.predict(testX)
    predTrainY = learner.predict(trainX)
    weight = 0.632
    return Evaluator.binaryBootstrapError(predTestY, testY, predTrainY, trainY, weight)
Exemplo n.º 3
0
    def testBinaryBootstrapError(self):

        testY = numpy.array([-1, -1, 1, 1, 1])
        predY = 1 - testY

        trainY = numpy.array([-1, -1, 1, 1, 1])
        predTrainY = 1 - trainY

        self.assertEquals(
            Evaluator.binaryBootstrapError(testY, testY, trainY, trainY, 0.5),
            0.0)

        self.assertEquals(
            Evaluator.binaryBootstrapError(testY, testY, trainY, predTrainY,
                                           0.5), 0.5)
        self.assertEquals(
            Evaluator.binaryBootstrapError(testY, testY, trainY, predTrainY,
                                           0.1), 0.9)

        self.assertEquals(
            Evaluator.binaryBootstrapError(testY, predY, trainY, trainY, 0.1),
            0.1)