コード例 #1
0
 def updateRanges(self, instance: Instance, ranges: List[List[float]]):
     numVals = instance.numValues()
     prevIndex = 0
     for j in range(numVals):
         currIndex = instance.index(j)
         while prevIndex < currIndex:
             if 0 < ranges[prevIndex][self.R_MIN]:
                 ranges[prevIndex][self.R_MIN] = 0
                 ranges[prevIndex][self.R_WIDTH] = ranges[prevIndex][
                     self.R_MAX] - ranges[prevIndex][self.R_MIN]
             if 0 > ranges[prevIndex][self.R_MAX]:
                 ranges[prevIndex][self.R_MAX] = 0
                 ranges[prevIndex][self.R_WIDTH] = ranges[prevIndex][
                     self.R_MAX] - ranges[prevIndex][self.R_MIN]
             prevIndex += 1
         prevIndex += 1
         if not instance.isMissingSparse(j):
             val = instance.valueSparse(j)
             if val < ranges[currIndex][self.R_MIN]:
                 ranges[currIndex][self.R_MIN] = val
                 ranges[currIndex][self.R_WIDTH] = ranges[currIndex][
                     self.R_MAX] - ranges[currIndex][self.R_MIN]
             if val > ranges[currIndex][self.R_MAX]:
                 ranges[currIndex][self.R_MAX] = val
                 ranges[currIndex][self.R_WIDTH] = ranges[currIndex][
                     self.R_MAX] - ranges[currIndex][self.R_MIN]
     return ranges
コード例 #2
0
 def updateRangesFirst(self, instance: Instance, numAtt: int,
                       ranges: List[List]):
     for i in range(len(ranges)):
         for j in range(len(ranges[i])):
             ranges[i][j] = 0
     numVals = instance.numValues()
     for j in range(numVals):
         currIndex = instance.index(j)
         if not instance.isMissingSparse(j):
             return True
     return False