Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove pyarrow dependency for polars #705

Merged
merged 2 commits into from
Nov 27, 2023
Merged

remove pyarrow dependency for polars #705

merged 2 commits into from
Nov 27, 2023

Conversation

jmoralez
Copy link
Member

@jmoralez jmoralez commented Nov 23, 2023

  • The CV methods used pl.from_pandas, which requires pyarrow to be installed. This moves the processing to the corresponding engine so that the dataframe is built from the start in pandas/polars, thus removing the need to convert a pandas dataframe to polars and the need for pyarrow.
  • Also vectorizes the times creation, which should speed up all methods.
  • Adds the ufp prefix to the utilsforecast.processing functions.
  • Only saves the original times because the ids can be easily reconstructed when computing the fitted values, which saves memory.
  • Fixes predict and forecast with polars dataframe, output ds has different time unit than source #703.
  • Deletes the fcst_fitted_values_ and cv_fitted_values_ attributes at the start of the forecast and cross_validation methods to avoid getting old results back, e.g.
sf.forecast(df=df, ..., fitted=True)
sf.forecast(df=other_df, ..., fitted=False)
sf.forecast_fitted_values()  # these would correspond to the first df. in this PR it raises an error

Breaking changes

  • The frequency when using polars dataframes must be a valid by argument for offset_by, e.g. daily frequency is '1d'.
  • The frequency when using integer times should be an integer, e.g. if you have ds = [1, 2, 3] you should set freq=1

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@jmoralez jmoralez marked this pull request as ready for review November 23, 2023 23:01
@jmoralez jmoralez requested a review from AzulGarza November 23, 2023 23:01
Copy link
Member

@AzulGarza AzulGarza left a comment

Choose a reason for hiding this comment

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

really nice the abstraction of process_df and cv_times in utilsforecast😍

@jmoralez jmoralez merged commit 33cacc0 into main Nov 27, 2023
16 checks passed
@jmoralez jmoralez deleted the remove-pyarrow-dep branch November 27, 2023 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

predict and forecast with polars dataframe, output ds has different time unit than source
2 participants