non_negative_parafac_hals(tensor, rank, n_iter_max=100, init='svd', svd='numpy_svd', tol=1e-07, sparsity_coefficients=None, fixed_modes=None, exact=False, verbose=False, return_errors=False, cvg_criterion='abs_rec_error')[source]

Non-negative CP decomposition via HALS

Uses Hierarchical ALS (Alternating Least Squares) which updates each factor column-wise (one column at a time while keeping all other columns fixed), see [R2e3307d426ae-1]


number of components


maximum number of iteration

init{‘svd’, ‘random’}, optional
svdstr, default is ‘numpy_svd’

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

tolfloat, optional

tolerance: the algorithm stops when the variation in the reconstruction error is less than the tolerance Default: 1e-8

sparsity_coefficients: array of float (of length the number of modes)

The sparsity coefficients on each factor. If set to None, the algorithm is computed without sparsity Default: None,

fixed_modes: array of integers (between 0 and the number of modes)

Has to be set not to update a factor, 0 and 1 for U and V respectively Default: None

exact: If it is True, the algorithm gives a results with high precision but it needs high computational cost.

If it is False, the algorithm gives an approximate solution Default: False

verbose: boolean

Indicates whether the algorithm prints the successive reconstruction errors or not Default: False

return_errors: boolean

Indicates whether the algorithm should return all reconstruction errors and computation time of each iteration or not Default: False

cvg_criterion{‘abs_rec_error’, ‘rec_error’}, optional

Stopping criterion for ALS, works if tol is not None. If ‘rec_error’, ALS stops at current iteration if (previous rec_error - current rec_error) < tol. If ‘abs_rec_error’, ALS terminates when |previous rec_error - current rec_error| < tol.

sparsityfloat or int
factorsndarray list

list of positive 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 algorithm.