-
Notifications
You must be signed in to change notification settings - Fork 9
feat: Add random state feature. #150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d8d4e11
feat: Add random state feature.
ae45726
Add class docstring
3d7c8b6
components->n_components
a0483b4
Updated docstring
d39cbe0
Shorten and reformat docstring
c783a02
docstring typo
7f8e33d
Flag self.rng as private
6ba837f
Make logic for n_components and Y0 more rigid
f45b4bb
added class attributes to docstring
bdfab77
fix: cleaner import of SNMFOptimizer
sbillinge 4e13df1
fix: correct class instantiation after change in import
sbillinge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,7 @@ | |
|
||
|
||
class SNMFOptimizer: | ||
"""A self-contained implementation of the stretched NMF algorithm (sNMF), | ||
including sparse stretched NMF. | ||
"""A implementation of stretched NMF (sNMF), including sparse stretched NMF. | ||
|
||
Instantiating the SNMFOptimizer class runs all the analysis immediately. | ||
The results matrices can then be accessed as instance attributes | ||
|
@@ -33,44 +32,39 @@ def __init__( | |
|
||
Parameters | ||
---------- | ||
MM: ndarray | ||
The array containing the data to be decomposed. Shape is (length_of_signal, | ||
number_of_conditions). | ||
Y0: ndarray | ||
The array containing initial guesses for the component weights | ||
at each stretching condition. Shape is (number of components, number of | ||
conditions) Must be provided if n_components is not provided. Will override | ||
n_components if both are provided. | ||
X0: ndarray | ||
The array containing initial guesses for the intensities of each component per | ||
MM : ndarray | ||
The data to be decomposed. Shape is (length_of_signal, number_of_conditions). | ||
Y0 : ndarray | ||
The initial guesses for the component weights at each stretching condition. | ||
Shape is (number of components, number ofconditions) Must be provided if | ||
n_components is not provided. Will override n_components if both are provided. | ||
X0 : ndarray | ||
The initial guesses for the intensities of each component per | ||
row/sample/angle. Shape is (length_of_signal, number_of_components). | ||
A: ndarray | ||
The array containing initial guesses for the stretching factor for each component, | ||
at each condition. Shape is (number_of_components, number_of_conditions). | ||
rho: float | ||
The float which sets a stretching factor that influences the decomposition. | ||
Zero corresponds to no stretching present. Relatively insensitive and typically | ||
adjusted in powers of 10. | ||
eta: float | ||
The integer which sets a sparsity factor than influences the decomposition. | ||
Should be set to zero for non sparse data such as PDF. Can be used to improve | ||
results for sparse data such as XRD, but due to instability, should be used | ||
only after first selecting the best value for rho. | ||
max_iter: int | ||
A : ndarray | ||
The initial guesses for the stretching factor for each component, at each | ||
condition. Shape is (number_of_components, number_of_conditions). | ||
rho : float | ||
The stretching factor that influences the decomposition. Zero corresponds to no | ||
stretching present. Relatively insensitive and typically adjusted in powers of 10. | ||
eta : float | ||
The sparsity factor than influences the decomposition. Should be set to zero for | ||
non-sparse data such as PDF. Can be used to improve results for sparse data such | ||
as XRD, but due to instability, should be used only after first selecting the | ||
best value for rho. | ||
max_iter : int | ||
The maximum number of times to update each of A, X, and Y before stopping | ||
the optimization. | ||
tol: float | ||
The minimum fractional improvement in the objective function to allow | ||
without terminating the optimization. Note that a minimum of 20 updates | ||
are run before this parameter is checked. | ||
n_components: int | ||
tol : float | ||
The convergence threshold. This is the minimum fractional improvement in the | ||
objective function to allow without terminating the optimization. Note that | ||
a minimum of 20 updates are run before this parameter is checked. | ||
n_components : int | ||
The number of components to attempt to extract from MM. Note that this will | ||
sbillinge marked this conversation as resolved.
Show resolved
Hide resolved
|
||
be overridden by Y0 if that is provided, but must be provided if no Y0 is | ||
provided. | ||
random_state: int | ||
The integer which acts as a reproducible seed for the initial matrices used in | ||
the optimization. Due to the non-convex nature of the problem, results may vary | ||
even with the same initial guesses, so this does not make the program deterministic. | ||
random_state : int | ||
The seed for the initial matrices used in the optimization. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a little unclear. What matrices? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be clearer now. |
||
""" | ||
|
||
self.MM = MM | ||
sbillinge marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.