Best would be to to use the scipy way of creating a class that takes all the model parameters and fitting it to the data, but keeping it one function is also fair.
If you don’t use a class, Best don’t return a dict, but a namedtuple. This has the advantage that elements are easier to access, and it can be unpacked:
# I just want the fist two items, don’t care about the rest:
factors, loadings, *_ = glm_pca(counts, 50)
# I want an object containing everything:
pca = glm_pca(counts, 2, fam="muli")
plt.scatter(*pca.factors.T)
This is a straight translation from R. I’d recommend making this pythonic:
Don’t use mathy variable names or dict parameters. Use expressive names in lower case, especially for the 3rd parameter onwards:
Best would be to to use the scipy way of creating a class that takes all the model parameters and fitting it to the data, but keeping it one function is also fair.
If you don’t use a class, Best don’t return a dict, but a namedtuple. This has the advantage that elements are easier to access, and it can be unpacked: