Skip to content

ENH: functional boxplot - highest density region #3864

Closed

Activity

  1. tupui commented on Aug 18, 2017

    @tupui
    Contributor

    @josef-pkt I am currently adapting the code to fit statsmodels. I created a branch here: https://github.com/tupui/HDR-Boxplot/tree/statsmodels

    I replaced all dependencies and now it uses statsmodels methods. Still have to fix the tests and come up with a good way to return the plots.

  2. josef-pkt commented on Aug 18, 2017

    @josef-pkt
    MemberAuthor

    Based on a quick look
    We allow users to specify a ax or figure where the plots are added. You can look at other plot functions to see how that works and the helper function that we use.

    Two possibilities if there are several plots that share common computation:

    • use subplots or plot grid to combine several plots into one figure and return that figure
    • return an instance of a results class: If there is a lot of common computation, then it might be useful for users to access those intermediate results directly. Using a results class would have the advantage of separating the underlying computation from plot methods, especially if there are several plots.
  3. tupui commented on Aug 18, 2017

    @tupui
    Contributor

    @josef-pkt Correct me if I am wrong, the second option means creating a class that:

    1. Fit the data,
    2. Provide a plot method.

    If this is the case, I have done such class so It won't be an issue to adapt it now I have this code.

    The first option will not be pretty I am afraid. But the question might be, do we really need the extra plots? Because among the following [hdr_boxplot.pdf], we are interested in the last one. So we can imagine returning ax for this main plot and some extras to do the other plots. In fboxplot, ax is returned along with other infos.

  4. josef-pkt commented on Aug 18, 2017

    @josef-pkt
    MemberAuthor

    We have several "patterns" that depend on the focus of the functions/classes/methods, what is of main interest to the user and what is additional information that some users might want to have access to.
    I don't know yet what is the case here.

    If you think the focus is on the last plot, then following the fboxplot example would work. If there is more information or there are more plots and supporting methods, then using a class would be more appropriate, (e.g.
    (i) A function could return a results instance;
    (ii) a single class could handle everything and use attributes; or
    (iii) class that does the computation returns a class that provides the plot methods.)

  5. tupui commented on Aug 18, 2017

    @tupui
    Contributor

    I have committed a version that works as fboxplot. In the first place, I considered a function to be consistent with the other functional plot functions. So if what I have done so far seems enough, I can do the PR with that (after test fixed, and doc obviously). Otherwise I can port the changes I have made here to the class version which will enable to define several plot methods and have access to internal attributes. But this might be overkill.

    Another point, this version is ok up to ncomp=3 but after that, we must use some global optimization methods to replace the search within a np.meshgrid. I also have this (actually with the class version).

  6. josef-pkt commented on Aug 18, 2017

    @josef-pkt
    MemberAuthor

    Are your nested functions using variables from the main function scope? In general I prefer, and we usually put helper functions outside the functions. Besides possible reuse. it also makes debugging easier if problems show up. With leading underline those helper functions would be private.

    I think the structure is fine with your plot function. I would prefer to use a dict or something else for the extra returns instead of returning a single tuple. That would make future changes in the extra returns backwards compatible when only the figure is used.

    You could open a PR, and I try to go over the details later today.

    Also, as I mentioned on the mailing list, I would like to eventually start a statsmodels.functional folder for functional data analysis. If you have or once we get more extensive computation besides the plotting support, then we could add classes there with the focus on estimation and data analysis with plots as supporting methods.

  7. tupui commented on Aug 18, 2017

    @tupui
    Contributor

    Currently yes but I can change that is sec.

    I have committed the actual class in hdr_class.py so you can see.

    OK I open a PR then by adding for starting the function into functional.py.

  8. rgommers commented on Sep 22, 2017

    @rgommers
    Member

    This PR looks quite nice. I haven't used this type of functionality in a while, but +1 from me.

  9. josef-pkt commented on Oct 25, 2017

    @josef-pkt
    MemberAuthor

    @tupui PR #3876 merged in rebased version in #4049

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions