Reference¶
Main API functions¶
- class opnmf.decomposition.model.OPNMF(n_components=10, max_iter=50000, tol=1e-05, init='nndsvd')¶
orthogonal projective non-negative matrix factorization
- Parameters
- n_components: int
Number of components.
- alpha: int
Constant that multiplies the regularization terms. Set it to zero to have no regularization. Defaults to 1.0.
- max_iter: int
Maximum number of iterations before timing out. Defaults to 200.
- tol: float, default=1e-4
Tolerance of the stopping condition.
- init{‘random’, ‘nndsvd’, ‘nndsvda’, ‘nndsvdar’, ‘custom’}, default=None
Method used to initialize the procedure. Valid options:
None: ‘nndsvd’ if n_components < n_features, otherwise ‘random’.
‘random’: non-negative random matrices, scaled with: sqrt(X.mean() / n_components)
‘nndsvd’: Nonnegative Double Singular Value Decomposition (NNDSVD) initialization (better for sparseness)
‘nndsvda’: NNDSVD with zeros filled with the average of X (better when sparsity is not desired)
‘nndsvdar’: NNDSVD with zeros filled with small random values (generally faster, less accurate alternative to NNDSVDa for when sparsity is not desired)
‘custom’: use custom matrices W and H if update_H=True. If update_H=False, then only custom matrix H is used.
- fit(X, init_W=None)¶
Learn a OPNMF model for the data X.
- Parameters
- X{array-like, sparse matrix} of shape (n_samples, n_features)
Data matrix to be decomposed
- init_Warray-like of shape (n_samples, n_components)
If init=’custom’, it is used as initial guess for the solution.
- Returns
- self
- fit_transform(X, init_W=None)¶
Learn a OPNMF model for the data X and returns the transformed data.
- Parameters
- X{array-like, sparse matrix} of shape (n_samples, n_features)
Data matrix to be decomposed
- init_Warray-like of shape (n_samples, n_components)
If init=’custom’, it is used as initial guess for the solution.
- Returns
- Wndarray of shape (n_samples, n_components)
Transformed data
- transform(X)¶
Transform the data X according to the fitted OPNMF model.
- Parameters
- X{array-like, sparse matrix} of shape (n_samples, n_features)
Data matrix to be transformed by the model.
- Returns
- Wndarray of shape (n_samples, n_components)
Transformed data.
- opnmf.decomposition.opnmf.opnmf(X, n_components, max_iter=50000, tol=1e-05, init='nndsvd', init_W=None)¶
Orthogonal projective non-negative matrix factorization.
- Parameters
- X: array-like of shape (n_samples, n_features)
Data matrix to be decomposed
- n_components: int
Number of components.
- max_iter: int
Maximum number of iterations before timing out. Defaults to 200.
- tol: float, default=1e-4
Tolerance of the stopping condition.
- init{‘random’, ‘nndsvd’, ‘nndsvda’, ‘nndsvdar’, ‘custom’}, default=None
Method used to initialize the procedure. Valid options:
None: ‘nndsvd’ if n_components < n_features, otherwise ‘random’.
‘random’: non-negative random matrices, scaled with: sqrt(X.mean() / n_components)
‘nndsvd’: Nonnegative Double Singular Value Decomposition (NNDSVD) initialization (better for sparseness)
‘nndsvda’: NNDSVD with zeros filled with the average of X (better when sparsity is not desired)
‘nndsvdar’: NNDSVD with zeros filled with small random values (generally faster, less accurate alternative to NNDSVDa for when sparsity is not desired)
‘custom’: use custom matrices W and H if update_H=True. If update_H=False, then only custom matrix H is used.
- init_W: array (n_samples, n_components)
Fixed initial coefficient matrix.
- Returns
- Wndarray of shape (n_samples, n_components)
The orthogonal non-negative factorization.
- Hndarray of shape (n_components, n_features)
Expansion coefficients.