CPD

# Import statement

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

Canonical Polyadic Decomposition.

Computed via alternating least squares (ALS)

Parameters
initstr

Type of factor matrix initialisation. Available options are svd and random

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.

Methods

copy(self)

Copy of the CPD algorithm as a new object

decompose(self, tensor, rank[, keep_meta, …])

Performs CPD-ALS on the tensor 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, tensor, rank, keep_meta=0, kr_reverse=False, factor_mat=None)[source]

Performs CPD-ALS on the tensor with respect to the specified rank

Parameters
tensorTensor

Multi-dimensional data 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

keep_metaint

Keep meta information about modes of the given tensor. 0 - the output will have default values for the meta data 1 - keep only mode names 2 - keep mode names and indices

kr_reversebool
factor_matlist(np.ndarray)

Initial list of factor matrices. Specifying this option will ignore init.

Returns
tensor_cpdTensorCPD

CP representation of the tensor

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