Exemplo n.º 1
0
 def transfer(self,numberOfTests=1):
     self.destinationEstimators,self.projMatrix,self.projVector = [],[],[]
     if self.matrix != [] and self.vect != []:
         proj,projMatrix,projVector = self.__generateProjectionNoRandom(np.array(self.vect),np.array(self.matrix))
         Hproj = []
         for i in range(self.sourceEstimators.size):
             Hproj.append(lambda x,S=self.sourceEstimators[i],P=proj: S(P(x)))
         temp = adaboost.adaBoost(self.destinationSet)
         temp.run(np.array(Hproj))
         self.destinationEstimators.append(temp)
         self.projMatrix.append(projMatrix)
         self.projVector.append(projVector)
     elif self.vect != []:
         for k in range(numberOfTests):
             proj,projMatrix,projVector = self.__generateProjectionPseudoRandomVect(len(self.sourceSet[0][0]),len(self.destinationSet[0][0]),np.array(self.vect))
             Hproj = []
             for i in range(self.sourceEstimators.size):
                 Hproj.append(lambda x,S=self.sourceEstimators[i],P=proj: S(P(x)))
             temp = adaboost.adaBoost(self.destinationSet)
             temp.run(np.array(Hproj))
             self.destinationEstimators.append(temp)
             self.projMatrix.append(projMatrix)
             self.projVector.append(projVector)
     else:
         for k in range(numberOfTests):
             proj,projMatrix,projVector = self.__generateProjection(len(self.sourceSet[0][0]),len(self.destinationSet[0][0]))
             Hproj = []
             for i in range(self.sourceEstimators.size):
                 Hproj.append(lambda x,S=self.sourceEstimators[i],P=proj: S(P(x)))
             temp = adaboost.adaBoost(self.destinationSet)
             temp.run(np.array(Hproj))
             self.destinationEstimators.append(temp)
             self.projMatrix.append(projMatrix)
             self.projVector.append(projVector)
Exemplo n.º 2
0
 def __init__(self,sourceSet,destinationSet,vect=[],matrix=[]):
     self.sourceSet = sourceSet
     self.destinationSet = destinationSet
     self.sourceEstimators = adaboost.adaBoost(sourceSet).generateDecisionStump(10)
     self.destinationEstimators = []
     self.projMatrix = []
     self.projVector = []
     self.matrix = []
     self.vect = []
Exemplo n.º 3
0
def testadaboost(iterations):
    adabooster = adaboost.adaBoost(EIGENVALUES)
    adabooster.loadData(dataMatrix, labelMatrix)
    adabooster.boost(iterations)

    correct = 0
    total = 0
    for i in range(len(testLabels)):
        if adabooster.classify(testData[i]) == testLabels[i]:
            correct += 1
            total += 1
        else:
            total += 1
    print "Correct: ", str(float(correct) / float(total)) + "%"
    correct = 0
    total = 0
    for i in range(len(labelMatrix)):
        if adabooster.classify(dataMatrix[i]) == labelMatrix[i]:
            correct += 1
            total += 1
        else:
            total += 1
    print "Correct: ", str(float(correct) / float(total)) + "%"