Y = XD
X
(n_samples, n_components)
D
(n_components, n_features)
X
n_nonzero_coefs
- Parameters:
- n_samples : int
Number of samples to generate.
- n_components : int
Number of components in the dictionary.
- n_features : int
Number of features of the dataset to generate.
- n_nonzero_coefs : int
Number of active (non-zero) coefficients in each sample.
- random_state : int, RandomState instance or None, default=None
Determines random number generation for dataset creation. Pass an int
for reproducible output across multiple function calls.
See Glossary.
- Returns:
- data : ndarray of shape (n_samples, n_features)
The encoded signal (Y).
- dictionary : ndarray of shape (n_components, n_features)
The dictionary with normalized components (D).
- code : ndarray of shape (n_samples, n_components)
The sparse code such that each column of this matrix has exactly
n_nonzero_coefs non-zero items (X).
Examples
from sklearn.datasets import make_sparse_coded_signal
data, dictionary, code = make_sparse_coded_signal(
n_samples=50,
n_components=100,
n_features=10,
n_nonzero_coefs=4,
random_state=0
)
data.shape
(50, 10)
dictionary.shape
(100, 10)
code.shape
(50, 100)