Parafac2

# Import statement

from hottbox.algorithms.decomposition import Parafac2
class Parafac2(max_iter=50, epsilon=0.01, tol=0.0001, random_state=None, verbose=False)[source]

Computes PARAFAC2 for tensors of order three with respect to a specified rank.

Computed via alternating least squares (ALS)

Parameters
max_iterint

Maximum number of iteration

epsilonfloat

Threshold for the relative error of approximation.

tolfloat

Threshold for convergence of factor matrices

random_stateint
verbosebool

If True, enable verbose output

Attributes

cost

(list) A list of relative approximation errors at each iteration of the algorithm.

References

  • Kiers, H., ten Berge, J. and Bro, R. (1999). PARAFAC2 - Part I. A direct fitting algorithm for the PARAFAC2 model. Journal of Chemometrics, 13(3-4), pp.275-294.

Methods

copy(self)

Copy of the CPD algorithm as a new object

decompose(self, tenl, rank)

Performs Direct fitting using ALS on a list of tensors of order 2 with respect to the specified rank.

plot

property converged

Checks convergence of the CPD-ALS algorithm.

Returns
bool
copy(self)[source]

Copy of the CPD algorithm as a new object

decompose(self, tenl, rank)[source]

Performs Direct fitting using ALS on a list of tensors of order 2 with respect to the specified rank.

Parameters
tenlList(np.ndarray)

List of np.ndarray of dimension 2 to be decomposed

ranktuple

Desired Kruskal rank for the given tensor. Should contain only one value. If it is greater then any of dimensions then random initialisation is used

Returns
fmat_u, fmat_s, fmat_v, reconstructedTuple(np.ndarray)

fmat_u,fmat_s,fmat_v are PARAFAC2 representation of list of tensors reconstructed is the reconstruction of the original tensor directly using fmat_u, fmat_s, fmat_v

Notes

khatri-rao product should be of matrices in reversed order. But this will duplicate original data (e.g. images) Probably this has something to do with data ordering in Python and how it relates to kr product

property name

Name of the decomposition

Returns
decomposition_namestr