Repository: alteryx/evalml
Pull request #3800 (2022-10-31 15:45:25)

Add catch for invalid time index frequencies
Fixes a bug where uninferrable time indices were causing `make_pipeline` to fail

codecov[bot]: # [Codecov](https://codecov.io/gh/alteryx/evalml/pull/3800?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=alteryx) Report
> Merging [#3800](https://codecov.io/gh/alteryx/evalml/pull/3800?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=alteryx) (1e95d39) into [main](https://codecov.io/gh/alteryx/evalml/commit/6788c06780370d38e7456b3841101f7e5c1ff390?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=alteryx) (6788c06) will **decrease** coverage by `49.5%`.
> The diff coverage is `0.0%`.

```diff
@@           Coverage Diff            @@
##            main   #3800      +/-   ##
========================================
- Coverage   99.7%   50.2%   -49.4%     
========================================
  Files        343     343              
  Lines      35813   35817       +4     
========================================
- Hits       35676   17974   -17702     
- Misses       137   17843   +17706     
```


| [Impacted Files](https://codecov.io/gh/alteryx/evalml/pull/3800?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=alteryx) | Coverage Δ | |
|---|---|---|
| [evalml/pipelines/utils.py](https://codecov.io/gh/alteryx/evalml/pull/3800/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=alteryx#diff-ZXZhbG1sL3BpcGVsaW5lcy91dGlscy5weQ==) | `45.9% <0.0%> (-53.6%)` | :arrow_down: |
| [evalml/tests/pipeline\_tests/test\_pipeline\_utils.py](https://codecov.io/gh/alteryx/evalml/pull/3800/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=alteryx#diff-ZXZhbG1sL3Rlc3RzL3BpcGVsaW5lX3Rlc3RzL3Rlc3RfcGlwZWxpbmVfdXRpbHMucHk=) | `0.0% <0.0%> (-99.7%)` | :arrow_down: |
| [evalml/\_\_main\_\_.py](https://codecov.io/gh/alteryx/evalml/pull/3800/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=alteryx#diff-ZXZhbG1sL19fbWFpbl9fLnB5) | `0.0% <0.0%> (-100.0%)` | :arrow_down: |
| [evalml/tests/utils\_tests/test\_logger.py](https://codecov.io/gh/alteryx/evalml/pull/3800/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=alteryx#diff-ZXZhbG1sL3Rlc3RzL3V0aWxzX3Rlc3RzL3Rlc3RfbG9nZ2VyLnB5) | `0.0% <0.0%> (-100.0%)` | :arrow_down: |
| [evalml/tests/automl\_tests/test\_search.py](https://codecov.io/gh/alteryx/evalml/pull/3800/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=alteryx#diff-ZXZhbG1sL3Rlc3RzL2F1dG9tbF90ZXN0cy90ZXN0X3NlYXJjaC5weQ==) | `0.0% <0.0%> (-100.0%)` | :arrow_down: |
| [evalml/model\_understanding/force\_plots.py](https://codecov.io/gh/alteryx/evalml/pull/3800/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=alteryx#diff-ZXZhbG1sL21vZGVsX3VuZGVyc3RhbmRpbmcvZm9yY2VfcGxvdHMucHk=) | `0.0% <0.0%> (-100.0%)` | :arrow_down: |
| [evalml/tests/automl\_tests/test\_progress.py](https://codecov.io/gh/alteryx/evalml/pull/3800/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=alteryx#diff-ZXZhbG1sL3Rlc3RzL2F1dG9tbF90ZXN0cy90ZXN0X3Byb2dyZXNzLnB5) | `0.0% <0.0%> (-100.0%)` | :arrow_down: |
| [evalml/tests/pipeline\_tests/test\_graphs.py](https://codecov.io/gh/alteryx/evalml/pull/3800/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=alteryx#diff-ZXZhbG1sL3Rlc3RzL3BpcGVsaW5lX3Rlc3RzL3Rlc3RfZ3JhcGhzLnB5) | `0.0% <0.0%> (-100.0%)` | :arrow_down: |
| [evalml/tests/utils\_tests/test\_cli\_utils.py](https://codecov.io/gh/alteryx/evalml/pull/3800/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=alteryx#diff-ZXZhbG1sL3Rlc3RzL3V0aWxzX3Rlc3RzL3Rlc3RfY2xpX3V0aWxzLnB5) | `0.0% <0.0%> (-100.0%)` | :arrow_down: |
| [evalml/tests/automl\_tests/dask\_test\_utils.py](https://codecov.io/gh/alteryx/evalml/pull/3800/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=alteryx#diff-ZXZhbG1sL3Rlc3RzL2F1dG9tbF90ZXN0cy9kYXNrX3Rlc3RfdXRpbHMucHk=) | `0.0% <0.0%> (-100.0%)` | :arrow_down: |
| ... and [109 more](https://codecov.io/gh/alteryx/evalml/pull/3800/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=alteryx) | |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=alteryx). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=alteryx)


Patch:
diff --git a/docs/source/release_notes.rst b/docs/source/release_notes.rst
index 8121c5c9..3eaf2880 100644
--- a/docs/source/release_notes.rst
+++ b/docs/source/release_notes.rst
@@ -6,6 +6,7 @@ Release Notes
     * Fixes
         * Fixed bug with datetime conversion in ``get_time_index`` :pr:`3792`
         * Fixed bug where invalid anchored or offset frequencies were including the ``STLDecomposer`` in pipelines :pr:`3794`
+        * Fixed bug where irregular datetime frequencies were causing errors in ``make_pipeline`` :pr:`3800`
     * Changes
         * Capped dask at < 2022.10.1 :pr:`3797`
         * Uncapped dask and excluded 2022.10.1 from viable versions :pr:`3803`
diff --git a/evalml/pipelines/utils.py b/evalml/pipelines/utils.py
index 6df7f9ae..d48bab7a 100644
--- a/evalml/pipelines/utils.py
+++ b/evalml/pipelines/utils.py
@@ -231,6 +231,9 @@ def _get_decomposer(X, y, problem_type, estimator_class, sampler_name=None):
     components = []
     if is_time_series(problem_type) and is_regression(problem_type):
         time_index = get_time_index(X, y, None)
+        # If the time index frequency is uninferrable, STL will fail
+        if time_index.freq is None:
+            return components
         freq = time_index.freq.name.split("-")[0]
         if (
             freq[-1] not in _UNSUPPORTED_FREQUENCIES_STL_DECOMPOSER


Test patch:
diff --git a/evalml/tests/pipeline_tests/test_pipeline_utils.py b/evalml/tests/pipeline_tests/test_pipeline_utils.py
index 67cebf5d..c7234d73 100644
--- a/evalml/tests/pipeline_tests/test_pipeline_utils.py
+++ b/evalml/tests/pipeline_tests/test_pipeline_utils.py
@@ -206,6 +206,7 @@ def test_make_pipeline(
         ("10T", False),
         ("AS-JAN", False),
         ("YS", False),
+        (None, False),
     ],
 )
 def test_make_pipeline_controls_decomposer_time_series(
@@ -219,7 +220,16 @@ def test_make_pipeline_controls_decomposer_time_series(
         problem_type,
         column_names=["dates", "numerical"],
     )
-    X.ww["dates"] = pd.Series(pd.date_range("2000-02-03", periods=20, freq=frequency))
+    if frequency is None:
+        X.ww["dates"] = pd.Series(
+            pd.date_range("2000-02-03", periods=10, freq=frequency).append(
+                pd.date_range("2000-02-15", periods=10, freq=frequency),
+            ),
+        )
+    else:
+        X.ww["dates"] = pd.Series(
+            pd.date_range("2000-02-03", periods=20, freq=frequency),
+        )
     parameters = {
         "pipeline": {
             "time_index": "date",