tensorly.decomposition
.sample_khatri_rao
- sample_khatri_rao(matrices, n_samples, skip_matrix=None, indices_list=None, return_sampled_rows=False, random_state=None)[source]
Random subsample of the Khatri-Rao product of the given list of matrices
If one matrix only is given, that matrix is directly returned.
- Parameters:
- matricesndarray list
list of matrices with the same number of columns, i.e.:
for i in len(matrices): matrices[i].shape = (n_i, m)
- n_samplesint
number of samples to be taken from the Khatri-Rao product
- skip_matrixNone or int, optional, default is None
if not None, index of a matrix to skip
- indices_listlist, default is None
Contains, for each matrix in matrices, a list of indices of rows to sample. if None, random indices will be created
- random_stateNone, int or numpy.random.RandomState
if int, used to set the seed of the random number generator if numpy.random.RandomState, used to generate random_samples
- returned_sampled_rowsbool, default is False
if True, also returns a list of the rows sampled from the full khatri-rao product
- Returns:
- sampled_Khatri_Raondarray
The sampled matricised tensor Khatri-Rao with n_samples rows
- indicestuple list
a list of indices sampled for each mode
- indices_krint list
list of length n_samples containing the sampled row indices