Skip to content

developer docs - how to add a new model #635

Open

Description

@josef-pkt

It came up in discussions a few times, but we don't have any explicit documentation how to write a new model class for statsmodels.

some information is spread across mailing list, current documentation and examples, but a dedicated section in the developer documentation would be more useful for new contributors.

Activity

  1. dengemann commented on Feb 5, 2013

    @dengemann
    Contributor

    That's a good idea. Loosely related, I wondered whether some clearer instructions for the examples / doc section might be indicated. This might include some sort of doc test. Also the examples could learn from sklearn concerning style and extent. Wdyt?

    On 05.02.2013, at 22:44, Josef Perktold [email protected] wrote:

    for other improvement ideas see also scikit-learn
    https://github.com/scikit-learn/scikit-learn/blob/master/doc/developers/index.rst

    —
    Reply to this email directly or view it on GitHub.

  2. jseabold commented on Feb 5, 2013

    @jseabold
    Member

    Always been the intention to have more of a tutorial like scikit-learn I think. Just a question of man hours. They have considerably more regularly contributing 'core' developers than we do. Trade-off-wise, we've spent the last year or so more concerned with improving the user-interface and structural framework of the models than the docs experience except for Vincent's recent work.

  3. dengemann commented on Feb 5, 2013

    @dengemann
    Contributor

    Sure, I totally see the point, no blame :-) API and models are very important. I just wanted to share what I think might be an ideal goal (at the risk of stating what's obvious for you guys).
    I'l definitely get back to it.

    D

    On 05.02.2013, at 23:45, Skipper Seabold [email protected] wrote:

    Always been the intention to have more of a tutorial like scikit-learn I think. Just a question of man hours. They have considerably more regularly contributing 'core' developers than we do. Trade-off-wise, we've spent the last year or so more concerned with improving the user-interface than the docs experience except for Vincent's recent work.

    —
    Reply to this email directly or view it on GitHub.

  4. jseabold commented on Feb 5, 2013

    @jseabold
    Member

    Contributions welcome :)

  5. josef-pkt commented on Feb 5, 2013

    @josef-pkt
    MemberAuthor

    Denis,
    documentation is important, however, if I had the choice between you working on documentation improvements or writing a repeated measures model, then I would choose ...

  6. dengemann commented on Feb 6, 2013

    @dengemann
    Contributor

    Don't worry. Let's first do the pep8 here ;-) My point was rather to think about how example writing could better become part of the development process. one could make it a rough rule that every significant feature added (beyond patches or pure internals) needs an example at least a simple vignette in order to be accepted.
    This would help finding bugs / improving API and can be regarded as part of a test-driven development model. As a side effect the functionality would be better exposed to the user.
    Adding sth. like that to the dev notes might be an idea. Less formally, one could simply enforce it in each qualified PR and ask for examples before merging.

    On 06.02.2013, at 00:50, Josef Perktold [email protected] wrote:

    Denis,
    documentation is important, however, if I had the choice between you working on documentation improvements or writing a repeated measures model, then I would choose ...

    —
    Reply to this email directly or view it on GitHub.

  7. josef-pkt commented on Feb 6, 2013

    @josef-pkt
    MemberAuthor

    I fully agree with the idea, and wish we were in a similar situation as scikit-learn. We can work in this direction and Vincent did a lot of work to organize and cleanup the examples and make it easier to write examples.

    Some of the new contributions do have examples or an example section in docstrings (as in graphics). Since we don't get so many "significant" contributions, it's also difficult to set the standard too high.

    Large parts of the code are still coming from Skipper and me and our record has been spotty, in general, we spend more effort on coding and maintenance than writing documentation. My examples end up in the source tree, not in the official documentation, or only with a long delay. Skipper has a more binary record, very good documentation on formula and it's new applications, not even a dirty example script ready to run for other things. (But he has extensive tests that I can sometimes convert to examples.)
    The other large group of contributors is the Google Summer of Code students and there the record also has been mixed.

    So any enforcement will also depend on how much or how fast I (or Skipper and I) can adjust.

    (one of my recent cases: I have a nice blog post planned for a while about SAS, R and my implementation of cohens_kappa https://github.com/statsmodels/statsmodels/pull/591/files but didn't find or were not willing to take the time to actually write it.)

    So, I think it's something to strive for, but too early to enforce. And, we should document what we would like to see in a PR.

  8. vincentarelbundock commented on Feb 6, 2013

    @vincentarelbundock

    clarification question: are the "dirty" examples in the source tree meant to eventually be converted to user-ready examples/tutorials? For instance, there are 3 sandwich files in there, with what appears to be some overlap. Robust cov estimates also have pretty extensive tests. So I'm wondering if all the code in dirty examples files is important, or if could we put together a clean example and delete the ex_sandwich1.py files. Mainly, I just want an indication of what's desirable to convert, and what's just meant as tools in your own development workflow.

  9. josef-pkt commented on Feb 6, 2013

    @josef-pkt
    MemberAuthor

    The examples serve both purposes.
    They, or some of them, should be converted to clean documentation examples. Large parts of the current documentation examples where initially "dirty" examples. Vincent also merged and streamlined several example scripts into one longer consistent example for the documentation. Everything in the examples that looks useful as documentation for users can be used.

    But, I also like to keep them around in runnable and adjustable form to help me with Q&A. Essentially, I can immediately check anything, questions, problems, bugs, when I know I have a "dirty" example. If they were not in the source, then I have to go look for them on my computer where they could be in many places.

    Some examples might be redundant, when I didn't clean up after finishing. A few might be left-overs from earlier versions. But in some cases, like sandwich robust covariance matrices there are so many different cases, that I needed to write several example scripts.
    I don't see ex_sandwich1.py, but for example ex_sandwich.py should be completely covered by the test suite. It could be deleted, but it might be useful because it compares the different cases when they (almost) overlap in special cases.
    It's not useful information for regular users, but it helped me understand the connection between the different versions and strands of literature. (It took me a long time to wrap my head around general sandwiches with time and cluster effects, and I have several additional scripts and versions not committed to the repo.)

    Similar, when I reviewed the non-parametric merge I added several example scripts, most of them trying to figure out how the models behave in different cases; same story in OneWayMixed. The original authors don't leave any examples, and the code might not even fully work, and I have to reverse-engineer examples, figuring out what the code is supposed to do. Once we know how it is supposed to work, we can write "clean" documentation examples.


    robust covariance matrices is a good example where the advertising is really lacking. I send several messages to the mailing list about the importance of robust covariance matrices while I was developing the code. But when I was finished I was so glad it was over, that I quickly went to other things (that have piled up while I was happily coding). There is also a ticket on connecting them to the result instances.
    (I usually go back to it after some time.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions