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

Speedup achieved by altering NMF parameters during initialization #1476

Open
fdeguire03 opened this issue Mar 3, 2025 · 4 comments
Open
Assignees

Comments

@fdeguire03
Copy link
Contributor

The end of the GreedyROI function in initialization.py uses sklearn.decomposition.NMF to estimate the background component in each patch:

model = NMF(n_components=nb, init='nndsvdar')
b_in = model.fit_transform(np.maximum(res, 0)).astype(np.float32)
f_in = model.components_.astype(np.float32)

I have found that the parameters init=random and max_iter=25 greatly improve the runtime (often by 2-3x) for this method without any detriment to quality (both methods give roughly the same reconstruction error in model.reconstruction_err_). Additionally, since initialize_components function immediately refines the results of GreedyROI using HALS, so using fewer iterations should not be an issue.

Would the maintainers consider switching to these NMF parameters by default or at least making them configurable via params.py?

@pgunn
Copy link
Member

pgunn commented Mar 3, 2025

We've exposed more parameters in the past when people requested them; I don't see any reason we couldn't do that here.

@pgunn pgunn self-assigned this Mar 3, 2025
@pgunn
Copy link
Member

pgunn commented Mar 3, 2025

@kushalkolar I'm wondering if you have any thoughts on changing the defaults

@kushalkolar
Copy link
Collaborator

Sure expose the params but I wouldn't change the defaults since that can mess with other people's known params.

@pgunn
Copy link
Member

pgunn commented Mar 3, 2025

@fdeguire03 I'll try to get these exposed by the next release; likely it'll be in dev within the week.

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

No branches or pull requests

3 participants