src/mf_algorithms/mf.py
def leftbgs(self, X, lf, rf, row, **kwargs):
    
        '''
        Block Gauss-Seidel update rule (the subset of columns in the right factor matrix are chosen via weighted sample)
        
        Parameters:
        ---------------
        X:      array
                The data matrix "X" to be factored
        lf:     array
                The left factor matrix to be updated
        rf:     array
                The right factor matrix used in the update
        row:    int 
                The row of the data matrix "X" used in the update
        '''
        
        siter = kwargs.get('siter', 1)
        eps = kwargs.get('eps', 1e-3)
        s = kwargs.get('s', 1)
        k = lf.shape[1]
        
        for j in np.arange(siter):
            if s2 == 1:
                gsrow = np.random.choice(rf.shape[0], size = s, p = self.weightsample(rf, 1), replace = False)
            else:
                resample = True
                while(resample):
                    gsrow = np.random.choice(rf.shape[0], size = s, replace = False)           
                    if (np.linalg.norm(rf[gsrow, :] > 0)):
                        resample = False
                # compute BGS step
                lf[row, :] = lf[row, :] + np.linalg.lstsq(rf[gsrow, :].T, (X[row, :] - lf[row, :] @ rf).T, rcond = None)[0].T @ np.eye(k)[gsrow, :]
            if np.linalg.norm(lf[row, :] @ rf - X[row, :]) < eps:
                break
        return(lf)

        Block Gauss-Seidel update rule (the subset of columns in the right factor matrix are chosen via weighted sample)
        
        Parameters:
        ---------------
        X:      array
                The data matrix "X" to be factored
        lf:     array
                The left factor matrix to be updated
        rf:     array
                The right factor matrix used in the update
        row:    int 
                The row of the data matrix "X" used in the update
        
Block Gauss-Seidel update rule (the subset of columns in the right factor matrix are chosen via weighted sample)
Parameters.

array
The data matrix "X" to be factored
lf:     array
The left factor matrix to be updated
rf:     array
The right factor matrix used in the update
row:    int
The row of the data matrix "X" used in the update
Block Gauss - Seidel update rule ( the subset of columns in the right factor matrix are chosen via weighted sample ) Parameters . array The data matrix " X " to be factored lf : array The left factor matrix to be updated rf : array The right factor matrix used in the update row : int The row of the data matrix " X " used in the update
def leftbgs(self, X, lf, rf, row, **kwargs):
        siter = kwargs.get('siter', 1)
        eps = kwargs.get('eps', 1e-3)
        s = kwargs.get('s', 1)
        k = lf.shape[1]
        for j in np.arange(siter):
            if s2 == 1:
                gsrow = np.random.choice(rf.shape[0], size = s, p = self.weightsample(rf, 1), replace = False)
            else:
                resample = True
                while(resample):
                    gsrow = np.random.choice(rf.shape[0], size = s, replace = False)           
                    if (np.linalg.norm(rf[gsrow, :] > 0)):
                        resample = False
                lf[row, :] = lf[row, :] + np.linalg.lstsq(rf[gsrow, :].T, (X[row, :] - lf[row, :] @ rf).T, rcond = None)[0].T @ np.eye(k)[gsrow, :]
            if np.linalg.norm(lf[row, :] @ rf - X[row, :]) < eps:
                break
        return(lf)
def leftbgs ( self , X , lf , rf , row , ** kwargs ) : siter = kwargs . get ( 'siter' , 1 ) eps = kwargs . get ( 'eps' , 1e-3 ) s = kwargs . get ( 's' , 1 ) k = lf . shape [ 1 ] for j in np . arange ( siter ) : if s2 == 1 : gsrow = np . random . choice ( rf . shape [ 0 ] , size = s , p = self . weightsample ( rf , 1 ) , replace = False ) else : resample = True while ( resample ) : gsrow = np . random . choice ( rf . shape [ 0 ] , size = s , replace = False ) if ( np . linalg . norm ( rf [ gsrow , : ] > 0 ) ) : resample = False lf [ row , : ] = lf [ row , : ] + np . linalg . lstsq ( rf [ gsrow , : ] . T , ( X [ row , : ] - lf [ row , : ] @ rf ) . T , rcond = None ) [ 0 ] . T @ np . eye ( k ) [ gsrow , : ] if np . linalg . norm ( lf [ row , : ] @ rf - X [ row , : ] ) < eps : break return ( lf )
Block Gauss-Seidel update rule (the subset of columns in the right factor matrix are chosen via weighted sample)
Parameters:
Block Gauss - Seidel update rule ( the subset of columns in the right factor matrix are chosen via weighted sample ) Parameters :
'''
        Block Gauss-Seidel update rule (the subset of columns in the right factor matrix are chosen via weighted sample)
        
        Parameters:
        ---------------
        X:      array
                The data matrix "X" to be factored
        lf:     array
                The left factor matrix to be updated
        rf:     array
                The right factor matrix used in the update
        row:    int 
                The row of the data matrix "X" used in the update
        ''' # compute BGS step
self
X
lf
rf
row