Skip to content

Consistency in documentation #3791

Closed
Closed

Description

@nmayorov

I think common things in documentation should be written in a consistent way. Right now I can think of the following points:

  1. Whether to name entities which can be transformed to ndarray as array or array-like.

  2. How to list different input options. Should curly braces always be used? For example:

    X : {array-like, sparse matrix}
    
  3. Optional arguments / default values. Some convention should be adopted, like:

    kernel : string, default ’rbf’
    

    or

    kernel : string (default='rbf')
    

    The word optional should be dropped anyway as redundant.

  4. How to name X and y arrays in fit and predict methods. The one adopted convention would be helpful.

  5. How to mention shapes of arrays. I was told that X, shape (n_samples, n_features) was adopted, is it true? How about 1-d arrays: (n_samples) or (n_samples,)?


Anyway, do you think it is an issue at all? Maybe core developers could decide and update coding guidelines? I listed only some points.

Activity

  1. GaelVaroquaux commented on Oct 21, 2014

    @GaelVaroquaux
    Member
    1. Whether to name entities which can be transformed to ndarray as array or
      array-like.

    array-like and arrays are 2 different things. We should strive to support
    as much as possible array-like everywhere.

    For the other remarks, I agree, and I would refer to the numpy doc
    standard, which is the one that we should be following.

  2. GaelVaroquaux commented on Oct 21, 2014

    @GaelVaroquaux
    Member

    Also, I am closing this issue, as we have way too many open issues in are
    tracker. It's not that I don't agree with it. Feel free to send in PRs
    for the parts of the documentation that do not respect the numpy doc
    standard.

  3. nmayorov commented on Oct 21, 2014

    @nmayorov
    ContributorAuthor

    Thanks for pointing to numpy doc.

    Point 4 is specific to scikit-learn, adding something about it to guidelines would be helpful.

  4. GaelVaroquaux commented on Oct 21, 2014

    @GaelVaroquaux
    Member

    I am a bit confused with regards to point 4.

    OK, I think that I am getting it: how should we be calling in plain English "X" and "y"? I must admit that I am not sure that there is a global agreement. We tend to call them "data" and "target". But the wording "input data" and "prediction target" would probably be more precise.

  5. nmayorov commented on Oct 21, 2014

    @nmayorov
    ContributorAuthor

    Yes, that's what I meant.

    In the current state X and y are called differently in every module.

  6. GaelVaroquaux commented on Oct 21, 2014

    @GaelVaroquaux
    Member

    In the current state X and y are called differently in every module.

    I agree that the question should be raised and documented. As it is more
    a question that calls for general discussion amongst the developer, I
    feel that we should rather use the mailing list, rather than an issue,
    for this discussion.

    My suggestion is "input data", and "prediction target".

  7. nmayorov commented on Oct 21, 2014

    @nmayorov
    ContributorAuthor

    I leave it to you to initiate this discussion on mailing list then, when you think it's a right time.

  8. amueller commented on Oct 27, 2016

    @amueller
    Member

    Answers are:

    1. ndarray if it's a numpy array, array-like for input that can be other things.
    2. use "or"
    3. kernel : string (default='rbf')
    4. (n_samples, n_features), (n_samples,)
  9. amueller commented on Oct 27, 2016

    @amueller
    Member

    Can someone add that to the docs?

  10. added
    Moderate
    on Oct 28, 2016
  11. raghavrv commented on Oct 28, 2016

    @raghavrv
    Member

    Tagging as moderate as this involves editing quite a few docstrings... (And addressing #7758 along the way). I think @karandesai-96 maybe interested in this? :)

  12. kdexd commented on Oct 28, 2016

    @kdexd

    @raghavrv I'll take this up. I was looking at a separate issue, @amueller gave me a direction for it. I'll do that if I am able to, this one comes next in the line 😄

  13. raghavrv commented on Oct 28, 2016

    @raghavrv
    Member

    Thx!

  14. thomasjpfan commented on Dec 10, 2021

    @thomasjpfan
    Member

    We now have a Guidelines for writing documentation that details how to write docstrings.

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

    DocumentationModerate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions