Skip to content

Conversation

@martins0n
Copy link

Hi! I've added two robust regressions for trendlines. There's an import from scipy, maybe it's not great. But I think that robust regressions will be helpful for analyzing data.

@emmanuelle emmanuelle self-assigned this Sep 9, 2019
@nicolaskruchten
Copy link
Contributor

Thanks for this PR! We've been thinking about an extension mechanism for this "trendline" feature for a while, as an alternative to baking in an increasing number of types of regressions directly into the library. I was thinking of having this argument accept a function with a signature like (x_in, y_in) -> (y_out, results, hover_string) or something like that, so users like yourself would be able to define/tweak/pass-in different regression types.

The advantage to this function approach is that you could do something like the following:

def huber(t):
    def huber_impl(x_in, y_in):
        # math that depends on `t`
        return y_out, results, hover_string
    return huber_impl

px.scatter(..., trendline=huber(t=2.222))

In addition to this, I'd want to include some kind of px.trendline_functions dictionary where users could register "named" functions, and then refer to them by name like "huber" or something like that.

As our first new-regression-function contributor, how does this sound as an API?

@martins0n
Copy link
Author

Use of decorators is a great and flexible option. But it's maybe not very obvious for users.
How to make it more obvious keeping it simple I have no ideas unfortunately. Maybe good examples would help.

@nicolaskruchten
Copy link
Contributor

Thanks again for taking the time to submit this PR! I'm going to close it now in favour of #2418 but I will re-use this code when documenting the new pluggable interface, as examples of the kinds of things that can be done with it :)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants