src/mf_algorithms/mf.py
def leftubrk(self, X, lf, rf, row, **kwargs):
    
        '''
        Uniform Block randomized Kaczmarz update step (the subset of columns in the right factor matrix are uniformly sampled)
        
        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)
        
        for i in np.arange(siter):
            kaczcol = np.random.choice(rf.shape[1], size = s, replace = False)
            if s == 1:
                lf[row, :] = lf[row, :] + (X[row, kaczcol] - lf[row, :] @ rf[:, kaczcol]) / (np.linalg.norm(rf[:, kaczcol])**2) * rf[:, kaczcol].T 
                if (i % 100 == 0):
                    if np.linalg.norm(lf[row, :] @ rf - X[row, :]) < eps:
                        #print("left break " + str(i))
                        break
            else:
                lf[row, :] = lf[row, :] + np.linalg.lstsq(rf[:, kaczcol].T, (X[None, row, kaczcol] - lf[row, :] @ rf[:, kaczcol]).T, rcond = None)[0].T
                if np.linalg.norm(lf[row, :] @ rf - X[row, :]) < eps:
                    #print("left break " + str(i))
                    break
                
        return(lf)

        Uniform Block randomized Kaczmarz update step (the subset of columns in the right factor matrix are uniformly sampled)
        
        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
        
Uniform Block randomized Kaczmarz update step (the subset of columns in the right factor matrix are uniformly sampled)
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
Uniform Block randomized Kaczmarz update step ( the subset of columns in the right factor matrix are uniformly sampled ) 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 leftubrk(self, X, lf, rf, row, **kwargs):
        siter = kwargs.get('siter', 1)
        eps = kwargs.get('eps', 1e-3)
        s = kwargs.get('s', 1)
        for i in np.arange(siter):
            kaczcol = np.random.choice(rf.shape[1], size = s, replace = False)
            if s == 1:
                lf[row, :] = lf[row, :] + (X[row, kaczcol] - lf[row, :] @ rf[:, kaczcol]) / (np.linalg.norm(rf[:, kaczcol])**2) * rf[:, kaczcol].T 
                if (i % 100 == 0):
                    if np.linalg.norm(lf[row, :] @ rf - X[row, :]) < eps:
                        break
            else:
                lf[row, :] = lf[row, :] + np.linalg.lstsq(rf[:, kaczcol].T, (X[None, row, kaczcol] - lf[row, :] @ rf[:, kaczcol]).T, rcond = None)[0].T
                if np.linalg.norm(lf[row, :] @ rf - X[row, :]) < eps:
                    break
        return(lf)
def leftubrk ( self , X , lf , rf , row , ** kwargs ) : siter = kwargs . get ( 'siter' , 1 ) eps = kwargs . get ( 'eps' , 1e-3 ) s = kwargs . get ( 's' , 1 ) for i in np . arange ( siter ) : kaczcol = np . random . choice ( rf . shape [ 1 ] , size = s , replace = False ) if s == 1 : lf [ row , : ] = lf [ row , : ] + ( X [ row , kaczcol ] - lf [ row , : ] @ rf [ : , kaczcol ] ) / ( np . linalg . norm ( rf [ : , kaczcol ] ) ** 2 ) * rf [ : , kaczcol ] . T if ( i % 100 == 0 ) : if np . linalg . norm ( lf [ row , : ] @ rf - X [ row , : ] ) < eps : break else : lf [ row , : ] = lf [ row , : ] + np . linalg . lstsq ( rf [ : , kaczcol ] . T , ( X [ None , row , kaczcol ] - lf [ row , : ] @ rf [ : , kaczcol ] ) . T , rcond = None ) [ 0 ] . T if np . linalg . norm ( lf [ row , : ] @ rf - X [ row , : ] ) < eps : break return ( lf )
Uniform Block randomized Kaczmarz update step (the subset of columns in the right factor matrix are uniformly sampled)
Parameters:
Uniform Block randomized Kaczmarz update step ( the subset of columns in the right factor matrix are uniformly sampled ) Parameters :
'''
        Uniform Block randomized Kaczmarz update step (the subset of columns in the right factor matrix are uniformly sampled)
        
        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
        ''' #print("left break " + str(i)) #print("left break " + str(i))
self
X
lf
rf
row