Repository navigation
Gam gsoc2015 - #2435
Gam gsoc2015#2435DonBeo wants to merge 94 commits into
Conversation
|
BTW: I'm going through http://www.quantoid.net/reg3/Lecture7_2013_4up.pdf which looks like a good quick overview for splines and GAMs in R. |
There was a problem hiding this comment.
in general, we use from numpy.testing import assert_allclose and other related asserts
No plain python asserts
|
@DonBeo Do you have the GLM example so I can look at it? |
|
Cubic splines can be fitted only with PIRLS. This is because they do not have the |
|
the predict problem is here is the result with bsplines estimated with nm/bfgs in first case and pirls in second case The differences are not visible in some of the graphs, because 0.1 is small compared to the overall scale and variation in the fit, e.g. the quadratic notebook example. |
|
What if you use |
In the cases that I checked So if you compare |
|
In pirls you should also check |
|
I just saw I will check these two things. I thought both should be available in the model already as attributes, so we shouldn't have to define it in pirls. (need to compare with Another unit test case would be to compare that GLMGAM produces identical results to GLM when alpha=0 (within optimization precision). |
|
ok I can add the test tomorrow. Should I wait your push ? On Thu, Aug 20, 2015 at 1:17 AM, Josef Perktold [email protected]
|
|
right now the only change I have is to set the
instead of
I still have to figure out how to set _offset_exposure and scaletype correctly. |
|
another cross-check: It looks like pirls and nm/bfgs use different scaling of alpha. manual search: I get agreement in sum of squared difference in prediction of 1e-11 with alpha=0.3545 in pirls, i.e. essentially exactly the same prediction/fittedvalues but with different alpha. This needs to be fixed, otherwise we are not able to switch between the optimizers. |
|
Overall PIRLS looks like a good optimizer, it seems to be more robust to starting values and faster than using the scipy optimizers. Once the two fit methods produce consistent results, we could use a pirls step as an initial step for the scipy optimizers similar to what we do with GLM, if that works as well in the GLMGAM case as in the GLM case. |
|
random numbers with no seed set makes replication difficult. current run (no seed either) alpha=1 in The factor in this case looks like which gives That seems to be correct, running several cases and changing alpha, I get for alpha in scipy optimizer, the corresponding alpha for pirls is no idea why divided by 100, I'm reverse engineering and not looking at code. |
|
in |
It's not because we don't need it in GLM for estimating the params. We wouldn't need it if we interpret The problem is that I don't know what the impact of estimating the scale at each iteration of the pirls loop is on the convergence behavior. Does the explanation in Wood for pirls mention anything about scale estimates? For now you could ignore the scale issue for converting alpha, and just use binomial or poisson as a test case where we don't need to include the scale because it's set to 1. The nobs correction for alpha should be in (I don't manage to wake up my monitor this morning and won't be able to look into it right now.) |
|
I haven't read anything about scale in Wood's . Personally I do not even know the statistical meaning of scale in this contest. I have updated some of the tests but a couple are still not working |
|
Does this need more code-review? What is stopping this being released? |
|
I think this is almost ready. I will be busy until the 6th of September. Then we will probably merge. |
|
Hi @josef-pkt, Let me know!! |
|
@DonBeo Sorry, I have been neglecting this since GSOC ended. I wanted to get some "easier" things done and merged before going back to penalization. Using git surgery to clean up this branch is pretty difficult, so I was thinking that the best way forward would be to start a new branch, copy everything over, moving modules to their proper location, and keep this PR for the history and discussion. Then we should also get TravisCI testing, I never figured out why this PR is stuck at appveyor and doesn't use Travis. When Travis runs the test, we will also get the test coverage report, to see how good that is. Overall, I think the code is in good shape, I still have some unfinished notebooks where I tried it out. But we might have to add some Future or Experimental warnings at the places where we expect future changes with reasonably high probability. |
|
Hi Josef, I am afraid that I can not do too much for the other elements in the TODO list as they require a good knowledge of the statsmodels' structure. Let me know. |
|
Luca, Can you create a new clean branch without any extra files? I think we can just put this in a new directory |
|
Hey @DonBeo have you opened up another branch for this yet? If so can you reference it here. I could do a code review on the code so far. I think this was really close to being accepted if I understood correctly? |
|
I think you may refer to this PR #2744 |
@josef-pkt I am starting a PR . At the moment there is the gam file that contains the gam penalty class. Smooth_basis contains some functions to get bsplines and polynomial basis. This file will be removed when we will be able to use directly patsy.
There are also 2 files that contains examples or small scripts. We will remove them later.
Let me know what do you think about that.
Todo
predicterrors (stateful transform, patsy ?), Note fittedvalues are availableonly a problem in pirls example, predict after fit works, requires spline basis values
get_predictionalso errors, maybe consequence of predict errorcurrently errors because weights is None
Interface
partial_valuesplot_partialhas inconvenient arguments (smoother and mask) instead of column index or term name or similarplot_partial_residuals(after GSOC?)