Skip to content

[BUG] Fix Prophet with logistic growth #1079#2609

Merged
fkiraly merged 58 commits intosktime:mainfrom
k1m190r:issue_1079
May 23, 2022
Merged

[BUG] Fix Prophet with logistic growth #1079#2609
fkiraly merged 58 commits intosktime:mainfrom
k1m190r:issue_1079

Conversation

@k1m190r
Copy link
Copy Markdown
Contributor

@k1m190r k1m190r commented May 6, 2022

Reference Issues/PRs

Fixes #1079 and #2444
Copy and paste of #1868

What does this implement/fix? Explain your changes.

Adds the possibility to define the required "cap" and "floor" parameters for Prophet when its growth is set to logistic.

Any other comments?

Suggest closing old relevant issues and PRs.

For all contributions

k1m190r and others added 30 commits January 6, 2022 14:09
…edict_quantiles()`.

Re-implemented `_has_predict_quantiles_been_refactored()` due to failing tests.

Small changes to `_convert_new_to_old_pred_int()` due to failing tests.
Copy link
Copy Markdown
Contributor

@aiwalter aiwalter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left few comments

Copy link
Copy Markdown
Collaborator

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

my main blocking change requests would be:

  • @aiwalter's comments
  • I think we need to do something in case the columns "cap" and "floor" already exist. An option would be to temporarily rename them to "cap__n" etc where n is the smallest positive integer that the string isn't already a column name

@k1m190r
Copy link
Copy Markdown
Contributor Author

k1m190r commented May 9, 2022

@fkiraly if cap and floor cols exist in y should the values from the columns be used as growth_cap and growth_floor params and removed from y? Since Prophet expects univariate.

@k1m190r
Copy link
Copy Markdown
Contributor Author

k1m190r commented May 9, 2022

Thank you for the corrections gents. I have noticed another [BUG] while implementing this PR. Will open new issue #2621.

@fkiraly
Copy link
Copy Markdown
Collaborator

fkiraly commented May 11, 2022

@fkiraly if cap and floor cols exist in y should the values from the columns be used as growth_cap and growth_floor params and removed from y? Since Prophet expects univariate.

No, I think in no case should values from y columns be used as parameters. That would break the unified interface.

Copy link
Copy Markdown
Collaborator

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good!

Three blocking changes:

  • optional parameter growth_cap needs to be indicated as optional in the docstring. Conditionally non-optional parameter growth_floor should say it is non-optional if growth="logistic" in the docstring.
  • I think array-like growth_cap and growth_floor do not work? So, docstring should not mention them.
  • we can't change existing default params without deprecation, but I also think interval_width is not used, so I'd leave it or remove it entirely

@fkiraly
Copy link
Copy Markdown
Collaborator

fkiraly commented May 11, 2022

See #2626 on the interval_width param. I think it can be removed?

@k1m190r
Copy link
Copy Markdown
Contributor Author

k1m190r commented May 11, 2022

  • optional parameter growth_cap needs to be indicated as optional in the docstring. Conditionally non-optional parameter growth_floor should say it is non-optional if growth="logistic" in the docstring.
  • growth_cap is conditionally optional if growth="logistic" and growth_floor optionality implied by default=0?
  • I think array-like growth_cap and growth_floor do not work? So, docstring should not mention them.
  • removed
  • we can't change existing default params without deprecation, but I also think interval_width is not used, so I'd leave it or remove it entirely
  • reverted to 0

@fkiraly
Copy link
Copy Markdown
Collaborator

fkiraly commented May 11, 2022

is conditionally optional if growth="logistic" and growth_floor optionality implied by default=0?

Well, docstring needs to make clear that growth_cap is usually optional.
Currently, a reader could think setting growth_cap is mandatory in all cases.

@k1m190r
Copy link
Copy Markdown
Contributor Author

k1m190r commented May 12, 2022

growth_floor: float, default=0
    Growth saturation minimum value.

growth_cap: float, default=None
    Growth saturation maximum aka carrying capacity.
    Conditionally optional: must be specified if `growth="logistic"`.

Is this ok?

@fkiraly
Copy link
Copy Markdown
Collaborator

fkiraly commented May 12, 2022

Is this ok?

Not sure - is None not ok for growth_cap if growth="logistic"?
Would 1 make sense as a sensible default?

I would also write "Used only if growth="logistic"" for growth_floor.

@fkiraly
Copy link
Copy Markdown
Collaborator

fkiraly commented May 22, 2022

@k1m190r, are you still working on this?

@k1m190r
Copy link
Copy Markdown
Contributor Author

k1m190r commented May 23, 2022

    growth: str, default="linear"
        String 'linear' or 'logistic' to specify a linear or logistic
        trend. If 'logistic' specified float for 'growth_cap' must be provided.
    growth_floor: float, default=0
        Growth saturation minimum value.
    growth_cap: float, default=None
        Growth saturation maximum aka carrying capacity.
        Conditionally optional: must be float if 'growth="logistic"'.

Ok I think this would be it.

  • if growth="linear": both growth_floor and growth_cap` are optional.
  • if growth="logistic": growth_floor is still optional (default=0) but growth_cap is not optional and must be non None - float.

@fkiraly
Copy link
Copy Markdown
Collaborator

fkiraly commented May 23, 2022

makes sense. I would remove the "conditionally optional" in favour of a clearer formulation, since this does not state what the condition is.

Last line, I would change to:

mandatory (float) iff `growth="logistic"`, has no effect and is optional, otherwise (if `growth` is not `"logistic"`)

To growth_floor, I would add:

used only if  `growth="logistic"`, has no effect otherwise (if `growth` is not `"logistic"`)

@k1m190r
Copy link
Copy Markdown
Contributor Author

k1m190r commented May 23, 2022

Done.

    growth: str, default="linear"
        String 'linear' or 'logistic' to specify a linear or logistic
        trend. If 'logistic' specified float for 'growth_cap' must be provided.
    growth_floor: float, default=0
        Growth saturation minimum value.
        Used only if  `growth="logistic"`, has no effect otherwise
        (if `growth` is not `"logistic"`).
    growth_cap: float, default=None
        Growth saturation maximum aka carrying capacity.
        Mandatory (float) iff `growth="logistic"`, has no effect and is optional,
        otherwise (if `growth` is not `"logistic"`).

Copy link
Copy Markdown
Collaborator

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@fkiraly fkiraly merged commit af197f1 into sktime:main May 23, 2022
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.

[BUG] Prophet with logistic growth does not work

3 participants