Beispiel #1
0
    def testSetMaxDepth(self):
        maxDepth = 20
        randomForest = RandomForest()
        randomForest.setMaxDepth(maxDepth)
        randomForest.learnModel(self.X, self.y)

        #self.assertTrue(RandomForest.depth(randomForest.getClassifier().tree) <= maxDepth+1)

        maxDepth = 5
        randomForest = RandomForest()
        randomForest.setMaxDepth(maxDepth)
        randomForest.learnModel(self.X, self.y)
Beispiel #2
0
    def testSetMaxDepth(self):
        maxDepth = 20
        randomForest = RandomForest()
        randomForest.setMaxDepth(maxDepth)
        randomForest.learnModel(self.X, self.y)

        #self.assertTrue(RandomForest.depth(randomForest.getClassifier().tree) <= maxDepth+1)

        maxDepth = 5
        randomForest = RandomForest()
        randomForest.setMaxDepth(maxDepth)
        randomForest.learnModel(self.X, self.y)
Beispiel #3
0
    def testPredict2(self):
        #We play around with parameters to maximise AUC on the IGF1_0-Haar data
        dataDir = PathDefaults.getDataDir()
        fileName = dataDir + "IGF1_0-Haar.npy"

        XY = numpy.load(fileName)
        X = XY[:, 0:XY.shape[1]-1]
        y = XY[:, XY.shape[1]-1].ravel()

        weight = numpy.bincount(numpy.array(y, numpy.int))[0]/float(y.shape[0])
        #weight = 0.5
        #weight = 0.9

        folds = 3
        randomForest = RandomForest()
        randomForest.setWeight(weight)
        randomForest.setMaxDepth(50)
        #randomForest.setMinSplit(100)
        mean, var = randomForest.evaluateCv(X, y, folds, Evaluator.auc)
        logging.debug("AUC = " + str(mean))
        logging.debug("Var = " + str(var))
Beispiel #4
0
    def testPredict2(self):
        #We play around with parameters to maximise AUC on the IGF1_0-Haar data
        dataDir = PathDefaults.getDataDir()
        fileName = dataDir + "IGF1_0-Haar.npy"

        XY = numpy.load(fileName)
        X = XY[:, 0:XY.shape[1] - 1]
        y = XY[:, XY.shape[1] - 1].ravel()

        weight = numpy.bincount(numpy.array(y, numpy.int))[0] / float(
            y.shape[0])
        #weight = 0.5
        #weight = 0.9

        folds = 3
        randomForest = RandomForest()
        randomForest.setWeight(weight)
        randomForest.setMaxDepth(50)
        #randomForest.setMinSplit(100)
        mean, var = randomForest.evaluateCv(X, y, folds, Evaluator.auc)
        logging.debug("AUC = " + str(mean))
        logging.debug("Var = " + str(var))