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

CANDECOMP/PARAFAC decomposition via alternating least squares (ALS)

Computes a rank-rank decomposition of tensor [R9] 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.

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


factors : ndarray list

List of factors of the CP decomposition element i is of shape (tensor.shape[i], rank)

weights : ndarray, optional

Array of length rank of weights for each factor matrix. See the with_weights keyword attribute.

errors : list

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


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