LSH/LSH_ANN.py
def tune(self, validDat, validLabs, hyperParamsToTest):
        
        '''
        Tune the LSH classifier for the optimal value of w (the quantization bin width). 
        Sets self.w to the value that minimized validation error.
        @param validDat a 2D numpy array holding validation data. Patterns in rows, variables in columns.
        @param validLabs a 1D numpy array, in row correspondence with validDat, which holds validation data labels.
        @param hyperParamsToTest: an iterable containing all the different values of w to tune on.
        @raise LogicalError: If the labels are not in row correspondence with the validation data
        '''
        
        if len(validLabs) != len(validDat):
            raise LogicalError, "Method LSH_ANN.tune(): Labels were not in row correspondence with data."
        
        bestAccuracy = 0
        bestW = self.w
        for val in hyperParamsToTest:
            self.w = val
            accuracy = self.test(validDat, validLabs)   # Not providing neighbor number for now.
            if accuracy > bestAccuracy:
                bestAccuracy = accuracy
                bestW = val
        self.w = bestW
        return bestW

        Tune the LSH classifier for the optimal value of w (the quantization bin width). 
        Sets self.w to the value that minimized validation error.
        @param validDat a 2D numpy array holding validation data. Patterns in rows, variables in columns.
        @param validLabs a 1D numpy array, in row correspondence with validDat, which holds validation data labels.
        @param hyperParamsToTest: an iterable containing all the different values of w to tune on.
        @raise LogicalError: If the labels are not in row correspondence with the validation data
        
Tune the LSH classifier for the optimal value of w (the quantization bin width).
Sets self.w to the value that minimized validation error.
@param validDat a 2D numpy array holding validation data. Patterns in rows, variables in columns.
@param validLabs a 1D numpy array, in row correspondence with validDat, which holds validation data labels.
@param hyperParamsToTest: an iterable containing all the different values of w to tune on.
@raise LogicalError: If the labels are not in row correspondence with the validation data
Tune the LSH classifier for the optimal value of w ( the quantization bin width ) . Sets self . w to the value that minimized validation error . @param validDat a 2D numpy array holding validation data . Patterns in rows variables in columns . @param validLabs a 1D numpy array in row correspondence with validDat which holds validation data labels . @param hyperParamsToTest : an iterable containing all the different values of w to tune on . @raise LogicalError : If the labels are not in row correspondence with the validation data
def tune(self, validDat, validLabs, hyperParamsToTest):
        if len(validLabs) != len(validDat):
            raise LogicalError, "Method LSH_ANN.tune(): Labels were not in row correspondence with data."
        bestAccuracy = 0
        bestW = self.w
        for val in hyperParamsToTest:
            self.w = val
            accuracy = self.test(validDat, validLabs)   
            if accuracy > bestAccuracy:
                bestAccuracy = accuracy
                bestW = val
        self.w = bestW
        return bestW
def tune ( self , validDat , validLabs , hyperParamsToTest ) : if len ( validLabs ) != len ( validDat ) : raise LogicalError , "Method LSH_ANN.tune(): Labels were not in row correspondence with data." bestAccuracy = 0 bestW = self . w for val in hyperParamsToTest : self . w = val accuracy = self . test ( validDat , validLabs ) if accuracy > bestAccuracy : bestAccuracy = accuracy bestW = val self . w = bestW return bestW
Tune the LSH classifier for the optimal value of w (the quantization bin width).
Tune the LSH classifier for the optimal value of w ( the quantization bin width ) .
'''
        Tune the LSH classifier for the optimal value of w (the quantization bin width). 
        Sets self.w to the value that minimized validation error.
        @param validDat a 2D numpy array holding validation data. Patterns in rows, variables in columns.
        @param validLabs a 1D numpy array, in row correspondence with validDat, which holds validation data labels.
        @param hyperParamsToTest: an iterable containing all the different values of w to tune on.
        @raise LogicalError: If the labels are not in row correspondence with the validation data
        ''' # Not providing neighbor number for now.
self
validDat
validLabs
hyperParamsToTest