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
Add a fit
method to models
#1330
Comments
I like this idea. The default fitter to use could even be defined on a per-model basis (though also overridable). |
I'm not sure this is a good idea to select one of the Fitters as a default and different fitters have different input data, so the signature of this method would be complex. Can we hold off deciding whether to add this until we have a few more fitters in astropy? |
@cdeil - then we could consider at least supporting the most common fitting algorithm. |
Having just played around with modeling some more this morning, what I find unintuitive is that if one has a model
changes the state of
would change the state of
would just return a dictionary of parameters or something similar. |
This looks like one of those features which is easy to add and would be hard to remove or change. And I think developing a flexible way to construct a fitter with user-defined optimization method and statistic (and eventually error estimation method) should be done before adding a convenience method But to be sure I understand what you have in mind, is this how you see it working:
Also, since I see It may be good to get other opinions on this @eteq @keflavich Anyone else? |
I agree the
i.e. (it's also conceptually simpler that the fitter takes the model and the data as inputs) |
I agree this behaviour can be a bit unexpected for users and returning a copy of the modified model may be better. Of course one has to be careful about reusing the initial values with different data sets. I'm not so sure about passing the model to
and the state of the fitter is set in the first step. The most important part of this is determining the constraints and which parameters are supposed to be fit (frozen and tied parameters are not fit). One way around this may be to have a
A modified copy of the model is returned and the model is initialized before each fitting. I understand this is still not as explicit as
|
delaying for the next version is fine - I see the point that it's more important to get it right the first time, and the "create a new model" paradigm does sound safer |
@astrofrog @nden @embray @cdeil - is this now "resolved" in that we've accepted the current system of |
Maybe we can simply close this and see if anyone else raises this in future? |
I'm -0 on closing it. This is definitely not a priority right now. But it's not an altogether bad idea either. Putting this in "Future" |
Is this a duplicate of #979? |
No I think they are a bit different - this is saying models should have a fit method, whereas #979 (I think) is saying there should be a reference to the most recent fitter used. |
Let's close this - we have way too many issues of 'let's keep open just in case' these days, and I agree with @eteq that we've settled on an accepted way to use the fitters. |
I haven't checked through all the open modeling issues, but I think model classes should have a
fit
method (that would default to one of the fitters, but could also take an argument for the fitter to use). I think the following 'beginner' example could be made simpler if it looked like:The text was updated successfully, but these errors were encountered: