nmf#
- class spidet.spike_detection.nmf.Nmf(rank: int, sparseness: float = 0.0)[source]#
This class hosts operations concerned with nonnegative matrix factorization (NMF).
- Parameters:
- rank: int
The rank used for the nonnegative matrix factorization
- sparseness: float, optional, default = 0.0
The sparseness parameter used in case NMF is run with sparseness constraints.
- nmf_run(preprocessed_data: ndarray[dtype[float]], n_runs: int) Tuple[Dict, ndarray[dtype[float]], ndarray[dtype[float]], ndarray[dtype[float]]][source]#
This method performs a number of nonegative matrix factorization runs for the rank defined at initialization of the
Nmfobject. At the beginning of each run the \(W\) and \(H\) matrices are randomly initialized. The algorithm runs until convergence (i.e., the reconstruction error < 1e-5) or for a maximum of 10 iterations.- Parameters:
- preprocessed_data: numpy.ndarray[numpy.dtype[float]]
The data used as input for NMF algorithm.
- n_runs: int
The number of NMF runs.
- Returns:
- Tuple[Dict,
- np.ndarray[np.dtype[float]],
- np.ndarray[np.dtype[float]],
- np.ndarray[np.dtype[float]]]
A dictionary containing the rank, the minimum reconstruction error, the cophenetic correlation and the instability index, together with the consensus, \(W\) and \(H\) matrices.