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

Refactor ARIMA/Prophet #3104

Merged
merged 26 commits into from
Dec 7, 2021
Merged

Refactor ARIMA/Prophet #3104

merged 26 commits into from
Dec 7, 2021

Conversation

ParthivNaresh
Copy link
Contributor

@ParthivNaresh ParthivNaresh commented Nov 30, 2021

Fixes: #3091 #3067 #3046

Perf tests here: https://alteryx.atlassian.net/wiki/spaces/PS/pages/1152516105/ARIMA+-+No+longer+relying+on+date+index

I've also added 4 new datasets to the S3 bucket:

  • Christmas_Daily_PageViews
  • Summer_Daily_PageViews
  • OlympicGames_Daily_PageViews
  • Pandemic_Daily_PageViews

I got these by downloading the Wikipedia page views from here for different articles over various time horizons.


After creating the pull request: in order to pass the release_notes_updated check you will need to update the "Future Release" section of docs/source/release_notes.rst to include this pull request by adding :pr:123.

@codecov
Copy link

codecov bot commented Nov 30, 2021

Codecov Report

Merging #3104 (28aaec1) into main (4bfe5f4) will decrease coverage by 0.1%.
The diff coverage is 100.0%.

Impacted file tree graph

@@           Coverage Diff           @@
##            main   #3104     +/-   ##
=======================================
- Coverage   99.8%   99.7%   -0.0%     
=======================================
  Files        315     315             
  Lines      30711   30547    -164     
=======================================
- Hits       30620   30447    -173     
- Misses        91     100      +9     
Impacted Files Coverage Δ
...ests/automl_tests/test_automl_search_regression.py 100.0% <ø> (ø)
...lml/automl/automl_algorithm/iterative_algorithm.py 100.0% <100.0%> (ø)
...omponents/estimators/regressors/arima_regressor.py 100.0% <100.0%> (ø)
...ponents/estimators/regressors/prophet_regressor.py 100.0% <100.0%> (ø)
evalml/pipelines/time_series_pipeline_base.py 100.0% <100.0%> (ø)
...alml/tests/component_tests/test_arima_regressor.py 100.0% <100.0%> (ø)
evalml/tests/component_tests/test_components.py 99.0% <100.0%> (+0.2%) ⬆️
...ml/tests/component_tests/test_prophet_regressor.py 100.0% <100.0%> (ø)
evalml/tests/conftest.py 97.0% <0.0%> (-1.4%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4bfe5f4...28aaec1. Read the comment docs.

if y is None:
raise ValueError("ARIMA Regressor requires y as input.")
if X is not None:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This addresses #2960. The issue is that since TimeSeriesFeaturizer isn't included in ARIMA-based pipelines, the potential for target leakage can occur.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should back this out of this PR and tackle it in it's own issue because I don't think this is the best fix for the problem.

I think the root cause of the problem is including features that will not be known during prediction time during fit. And whether or not a feature is known-in-advanced is independent of it's correlation to the target (which is what TargetLeakeage is checking). It's possible that there is a feature that will not be known in advanced that is not picked up by TargetLeakage and it's also possible that a feature that will be known in advanced will be dropped because it's correlated with the target.

I think we gotta think this through a bit more it's possible #2960 is blocked by #2511

X = X.select_dtypes(exclude=["datetime64"])
fh_ = self._set_forecast(X)
X = X[self.cols_to_keep]
X = X.select_dtypes(exclude=["datetime64"])
Copy link
Contributor Author

@ParthivNaresh ParthivNaresh Dec 1, 2021

Choose a reason for hiding this comment

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

_remove_datetime isn't called here because ARIMA doesn't have a problem predicting on data that has an arbitrary temporal index, even if it was fit on data that doesn't have a temporal index (because the forecast horizon is relative to the end of the training data).

@ParthivNaresh ParthivNaresh changed the title ARIMA remove mandatory date index Refactor ARIMA/Prophet Dec 2, 2021
if datetime_feature:
X_train["Dates"] = dates[:40]
X_test["Dates"] = dates[40:]
if train_none:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The difference between train_none and no_features is that train_none passes in None as X, while no_features passes in a dataframe with only an index set.

@ParthivNaresh ParthivNaresh marked this pull request as ready for review December 3, 2021 02:37
Copy link
Contributor

@chukarsten chukarsten left a comment

Choose a reason for hiding this comment

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

This looks good to me, Parthiv! I think just a few minor string related stuff.

@chukarsten
Copy link
Contributor

Just for completeness, I filed this : #3121

Copy link
Contributor

@freddyaboulton freddyaboulton left a comment

Choose a reason for hiding this comment

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

@ParthivNaresh Thanks for this PR I think it looks great! I think it's awesome you added some new seasonal datasets from wikipedia for us to test on. Looking forward to the LG PR to add those so I can use them too. Can you upload the html report to your results page? I'm curious to hover over those datasets/look at the rankings table.

The one thing is that I think we should back out the changes related to #2960 and tackle that problem in its own PR.

if y is None:
raise ValueError("ARIMA Regressor requires y as input.")
if X is not None:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should back this out of this PR and tackle it in it's own issue because I don't think this is the best fix for the problem.

I think the root cause of the problem is including features that will not be known during prediction time during fit. And whether or not a feature is known-in-advanced is independent of it's correlation to the target (which is what TargetLeakeage is checking). It's possible that there is a feature that will not be known in advanced that is not picked up by TargetLeakage and it's also possible that a feature that will be known in advanced will be dropped because it's correlated with the target.

I think we gotta think this through a bit more it's possible #2960 is blocked by #2511

)
def test_fit_predict_ts_with_y_not_X_index(
mock_get_dates, mock_format_dates, ts_data_seasonal_train
def test_fit_predict_sk_failure(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: This is basically testing that without remove_datetime, our ARIMA component would fail right? Can we rename the test to reflect that and add a comment to the pytest.raises to explain why/what is happening?

Copy link
Contributor Author

@ParthivNaresh ParthivNaresh Dec 7, 2021

Choose a reason for hiding this comment

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

Actually this is testing a few different use cases in which the original sktime.AutoARIMA fails but our implementation succeeds.

  • When the X index is of datetime type and the y index is not (and vice versa)
  • When X has no features but still has an index
  • When X has a datetime feature

So I named it test_fit_predict_sk_failure to represent the difference in behaviour from sktime and evalml. Also because of the different use cases, the error from sktime varies so I can't pin it down with an error message.

# Conflicts:
#	docs/source/release_notes.rst
# Conflicts:
#	evalml/tests/component_tests/test_arima_regressor.py
#	evalml/tests/component_tests/test_prophet_regressor.py
@ParthivNaresh ParthivNaresh merged commit 6a82b55 into main Dec 7, 2021
@chukarsten chukarsten mentioned this pull request Dec 9, 2021
@freddyaboulton freddyaboulton deleted the ARIMA_DateIndex branch May 13, 2022 15:03
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.

Do not set date index on data/target for Arima component
4 participants