parafac(tensor, rank, n_iter_max=100, init='svd', svd='numpy_svd', tol=1e-08, orthogonalise=False, random_state=None, verbose=False, return_errors=False)[source]

CANDECOMP/PARAFAC decomposition via alternating least squares (ALS)

Computes a rank-rank decomposition of tensor [R16] such that,

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

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

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


factors : ndarray list

List 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.


[R16](1, 2) tl.G.Kolda and B.W.Bader, “Tensor Decompositions and Applications”, SIAM REVIEW, vol. 51, n. 3, pp. 455-500, 2009.