-
Notifications
You must be signed in to change notification settings - Fork 14
Pad zero uncertainties in the MLE solver #177
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
base: main
Are you sure you want to change the base?
Changes from 3 commits
fca29dc
a2aa0fb
ebffc4c
191dab0
e2702e8
a2fe64d
acb623b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -205,6 +205,13 @@ def mle(graph: nx.DiGraph, factor: str = "f_ij", node_factor: Union[str, None] = | |
| action="symmetrize", | ||
| node_label=node_factor.replace("_", "_d"), | ||
| ) | ||
| # if the uncertainty is zero, the MLE solver will fail | ||
| # set all non-diagonal zeros to a small value if exactly zero | ||
| # see <https://github.com/OpenFreeEnergy/cinnabar/issues/97> for details | ||
| for i in range(N): | ||
| for j in range(N): | ||
| if i != j and df_ij[i, j] == 0.0: | ||
| df_ij[i, j] = 1e-6 | ||
|
Member
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. How about something like
Contributor
Author
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. Yeah I wasn't sure about replacing the absolute values on the diagonal as they are currently zero and it works but I guess there is no harm.
Member
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. ah yeah that's fair! better keep the diagonals zero
Contributor
Author
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. Ahh no this causes the F_matrix to change see here where each row is multipiled by some large inverse weight. I'll revert for now. |
||
|
|
||
| node_name_to_index = {} | ||
| for i, name in enumerate(graph.nodes()): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| **Added:** | ||
|
|
||
| * <news item> | ||
|
|
||
| **Changed:** | ||
|
|
||
| * The MLE estimator will now automatically pad uncertainties of exactly zero to a small non-zero value to avoid issues with SVD calculations `PR#177 <https://github.com/OpenFreeEnergy/cinnabar/pull/177>`_. | ||
|
|
||
| **Deprecated:** | ||
|
|
||
| * <news item> | ||
|
|
||
| **Removed:** | ||
|
|
||
| * <news item> | ||
|
|
||
| **Fixed:** | ||
|
|
||
| * <news item> | ||
|
|
||
| **Security:** | ||
|
|
||
| * <news item> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be warning users that this is happening / we're fixing their data on the fly? In many ways the 1e-6 is likely going to come from cases where only a single repeat was used, so maybe we should warn folks that this isn't a great situation (given that MLE does use the errors).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could be warning but how many people listen to warnigs, maybe the alternative would be better, and we should raise an error if we detect this case, causing the user to handle this properly? They could of course just pad the values themselves in that case, but at least they know what is happening.