Skip to content

Pretreatment.py中get_gama函数是否有误? #1

@heartk-zero

Description

@heartk-zero

Pretreatment.py中第207行if gamatest[i]>0 or (recalltest5<recall5 and recalltest10<recall10):,这里的gamatest中的每个元素是通过random函数得到的[0,1)之间的数,必定满足gamgatest[i]>0的条件,所以while循环内的值只执行一次,经过207行if判断后立即break退出while循环。

    def findgama(self, testX,testy,X,y):
        self.set(X,y)
        recall5 = 0
        recall10 = 0
        for n in range(10):
            print(" + [OK] wait for "+str(10-n)+" s!")
            gamatest = [random.random() for i in range(5)] 
            recalltest5 = 0
            recalltest10 = 0
            
            for i in range(5):
                print(" + [OK] tese gama["+str(i)+"] !")
                while True:
                    recalltest5 = self.test(testX, testy,5,gama = gamatest)
                    recalltest10 = self.test(testX, testy,10,gama = gamatest)
                    if recalltest5>recall5:
                        self.gama5= gamatest
                        recall5 = recalltest5
                        gamatest[i]+=0.03
                        
                    if recalltest10>recall10:
                        self.gama10= gamatest
                        recall10 = recalltest10
                        gamatest[i]+=0.03
                        
                    if gamatest[i]>0 or (recalltest5<recall5 and recalltest10<recall10):
                        break
        print(" + [OK]find gama:",self.gama5,self.gama10)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions