@@ -17,6 +17,64 @@ def __init__(
1717 components = None ,
1818 random_state = None ,
1919 ):
20+ """Run sNMF based on an ndarray, parameters, and either a number
21+ of components or a set of initial guess matrices.
22+
23+ Currently instantiating the SNMFOptimizer class runs all the analysis
24+ immediately. The results can then be accessed as instance attributes
25+ of the class (X, Y, and A). Eventually, this will be changed such
26+ that __init__ only prepares for the optimization, which will can then
27+ be done using fit_transform.
28+
29+ Parameters
30+ ----------
31+ MM: ndarray
32+ A numpy array containing the data to be decomposed. Rows correspond
33+ to different samples/angles, while columns correspond to different
34+ conditions with different stretching. Currently, there is no option
35+ to treat the first column (commonly containing 2theta angles, sample
36+ index, etc) differently, so if present it must be stripped in advance.
37+ Y0: ndarray
38+ A numpy array containing initial guesses for the component weights
39+ at each stretching condition, with number of rows equal to the assumed
40+ number of components and number of columns equal to the number of
41+ conditions (same number of columns as MM). Must be provided if components
42+ is not provided. Will override components if both are provided.
43+ X0: ndarray
44+ A numpy array containing initial guesses for the intensities of each
45+ component per row/sample/angle. Has rows equal to the rows of MM and
46+ columns equal to n_components or the number of rows of Y0.
47+ A: ndarray
48+ A numpy array containing initial guesses for the stretching factor for
49+ each component, at each condition. Has number of rows equal to n_components
50+ or the number of rows of Y0, and columns equal to the number of conditions
51+ (columns of MM).
52+ rho: float
53+ A stretching factor that influences the decomposition. Zero corresponds to
54+ no stretching present. Relatively insensitive and typically adjusted in
55+ powers of 10.
56+ eta: float
57+ A sparsity factor than influences the decomposition. Should be set to zero
58+ for non sparse data such as PDF. Can be used to improve results for sparse
59+ data such as XRD, but due to instability, should be used only after first
60+ selecting the best value for rho.
61+ max_iter: int
62+ The maximum number of times to update each of A, X, and Y before stopping
63+ the optimization.
64+ tol: float
65+ The minimum fractional improvement in the objective function to allow
66+ without terminating the optimization. Note that a minimum of 20 updates
67+ are run before this parameter is checked.
68+ components: int
69+ The number of components to attempt to extract from MM. Note that this will
70+ be overridden by Y0 if that is provided, but must be provided if no Y0 is
71+ provided.
72+ random_state: int
73+ Used to set a reproducible seed for the initial matrices used in the
74+ optimization. Due to the non-convex nature of the problem, results may vary
75+ even with the same initial guesses, so this does not make the program
76+ deterministic.
77+ """
2078
2179 self .MM = MM
2280 self .X0 = X0
0 commit comments