Skip to content
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

support not pre-compute cov #21

Merged
merged 9 commits into from
Aug 29, 2023
Merged

support not pre-compute cov #21

merged 9 commits into from
Aug 29, 2023

Conversation

powerfulbean
Copy link
Owner

support not pre-compute covmat, by delegating the functionality to the _cross_validate function. Also add corresponding test case in the tests

mtrf/matrices.py Outdated
@@ -1,6 +1,19 @@
import numpy as np


def _reduced_covariance_matrices(xs, ys, lags, zeropad=True, bias=True):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need an extra function for this? We could also add a boolean argument average to the covariance_matrices function

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel adding too much functionality into the covariance_matrices will make it too complicated (additional if..else.. branch). And because we need to accumulatively sum the cov_mat for each trial (to save memory), we still need to add several lines of code into the covariance_matrices, given that currently we use a list to store the cov_mat for each trial.

mtrf/model.py Outdated
If False, delete them.
method: str
Regularization method. Can be 'ridge' (default), 'tikhonov' or 'banded'.
See documentation for a detailed explanation.
pre_cal_cov: bool
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just call it 'precompute'? The details will be in the docstrings anyway and I think too many abbreviations make the code opaque

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah...., what about calling it savemem? (to directly indicate that this option is for saving memory)

mtrf/model.py Outdated
):
self.weights = None
self.bias = bias
self.times = None
self.fs = None
self.regularization = None
if isinstance(pre_cal_cov, bool):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should either check the types of all or arguments or none

mtrf/model.py Outdated
@@ -363,12 +389,17 @@ def test(
"Hyperparameter optimization",
verbose=verbose,
):
cov_xx_this = None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels not very informative, maybe cov_xx_train?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree totally!

@OleBialas
Copy link
Collaborator

I like the idea but I think its a lot of code for very little functionality - maybe we can simplify things by giving the existing covariance_matrices function the option to average across trials?

@OleBialas OleBialas merged commit bdb4de8 into master Aug 29, 2023
4 checks passed
@OleBialas OleBialas deleted the covmat-mode branch August 31, 2023 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants