tensorly.decomposition.non_negative_parafac_hals

non_negative_parafac_hals(tensor, rank, n_iter_max=100, init='svd', svd='truncated_svd', tol=1e-07, random_state=None, sparsity_coefficients=None, fixed_modes=None, nn_modes='all', exact=False, normalize_factors=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 [1]

Parameters:
tensorndarray
rankint

number of components

n_iter_maxint

maximum number of iteration

init{‘svd’, ‘random’}, optional
svdstr, default is ‘truncated_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

random_state{None, int, np.random.RandomState}
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

nn_modes: None, ‘all’ or array of integers (between 0 and the number of modes)

Used to specify which modes to impose non-negativity constraints on. If ‘all’, then non-negativity is imposed on all modes. Default: ‘all’

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

normalize_factorsif True, aggregate the weights of each factor in a 1D-tensor

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

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
random_state{None, int, np.random.RandomState}
Returns:
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.

References

[1]

N. Gillis and F. Glineur, Accelerated Multiplicative Updates and Hierarchical ALS Algorithms for Nonnegative Matrix Factorization, Neural Computation 24 (4): 1085-1105, 2012.