tensorly.contrib.sparse.decomposition.parafac

parafac(tensor, rank, n_iter_max=100, init='svd', svd='numpy_svd', normalize_factors=False, tol=1e-08, orthogonalise=False, random_state=None, verbose=0, return_errors=False, non_negative=False, mask=None)

CANDECOMP/PARAFAC decomposition via alternating least squares (ALS) Computes a rank-rank decomposition of tensor [R21] such that,

tensor = [|weights; factors[0], ..., factors[-1] |].

Parameters

tensor : ndarray

rank : int

Number of components.

n_iter_max : int

Maximum number of iteration

init : {‘svd’, ‘random’}, optional

Type of factor matrix initialization. See initialize_factors.

svd : str, default is ‘numpy_svd’

function to use to compute the SVD, acceptable values in tensorly.SVD_FUNS

normalize_factors : if True, aggregate the weights of each factor in a 1D-tensor

of shape (rank, ), which will contain the norms of the factors

tol : float, optional

(Default: 1e-6) Relative reconstruction error tolerance. The algorithm is considered to have found the global minimum when the reconstruction error is less than tol.

random_state : {None, int, np.random.RandomState}

verbose : int, optional

Level of verbosity

return_errors : bool, optional

Activate return of iteration errors

non_negative : bool, optional

Perform non_negative PARAFAC. See non_negative_parafac.

mask : ndarray

array of booleans with the same shape as tensor should be 0 where the values are missing and 1 everywhere else. Note: if tensor is sparse, then mask should also be sparse with a fill value of 1 (or True). Allows for missing values [R22]

Returns

KruskalTensor : (weight, factors)

  • weights1D array of shape (rank, )

    all ones if normalize_factors is False (default), weights of the (normalized) factors otherwise

  • factorsList of factors of the CP decomposition element i is of shape

    (tensor.shape[i], rank)

errors : list

A list of reconstruction errors at each iteration of the algorithms.

References

R21(1,2)

T.G.Kolda and B.W.Bader, “Tensor Decompositions and Applications”, SIAM REVIEW, vol. 51, n. 3, pp. 455-500, 2009.

R22(1,2)

Tomasi, Giorgio, and Rasmus Bro. “PARAFAC and missing values.” Chemometrics and Intelligent Laboratory Systems 75.2 (2005): 163-180.