Repository: alteryx/evalml
Pull request #3794 (2022-10-28 16:15:25)

Update _get_decomposer to use stripped freq
Fixes bug where any invalid frequencies that were either offset (i.e. 10 minutes -> `10T`) or anchored (annually at the year end -> `A-DEC`) were not properly getting excluded from training with the decomposer.

codecov[bot]: # [Codecov](https://codecov.io/gh/alteryx/evalml/pull/3794?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=alteryx) Report
> Merging [#3794](https://codecov.io/gh/alteryx/evalml/pull/3794?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=alteryx) (f7c9665) into [main](https://codecov.io/gh/alteryx/evalml/commit/8526d9b7c526811f8376355fdba7423c0e2331bb?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=alteryx) (8526d9b) will **decrease** coverage by `81.3%`.
> The diff coverage is `60.0%`.

> :exclamation: Current head f7c9665 differs from pull request most recent head 4e00c76. Consider uploading reports for the commit 4e00c76 to get more accurate results

```diff
@@           Coverage Diff            @@
##            main   #3794      +/-   ##
========================================
- Coverage   99.7%   18.4%   -81.2%     
========================================
  Files        343     343              
  Lines      35797   35799       +2     
========================================
- Hits       35660    6564   -29096     
- Misses       137   29235   +29098     
```


| [Impacted Files](https://codecov.io/gh/alteryx/evalml/pull/3794?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=alteryx) | Coverage Δ | |
|---|---|---|
| [evalml/tests/pipeline\_tests/test\_pipeline\_utils.py](https://codecov.io/gh/alteryx/evalml/pull/3794/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/pipelines/utils.py](https://codecov.io/gh/alteryx/evalml/pull/3794/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=alteryx#diff-ZXZhbG1sL3BpcGVsaW5lcy91dGlscy5weQ==) | `45.1% <75.0%> (-54.4%)` | :arrow_down: |
| [evalml/\_\_main\_\_.py](https://codecov.io/gh/alteryx/evalml/pull/3794/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/3794/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/3794/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/tests/component\_tests/test\_lda.py](https://codecov.io/gh/alteryx/evalml/pull/3794/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=alteryx#diff-ZXZhbG1sL3Rlc3RzL2NvbXBvbmVudF90ZXN0cy90ZXN0X2xkYS5weQ==) | `0.0% <0.0%> (-100.0%)` | :arrow_down: |
| [evalml/tests/component\_tests/test\_lsa.py](https://codecov.io/gh/alteryx/evalml/pull/3794/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=alteryx#diff-ZXZhbG1sL3Rlc3RzL2NvbXBvbmVudF90ZXN0cy90ZXN0X2xzYS5weQ==) | `0.0% <0.0%> (-100.0%)` | :arrow_down: |
| [evalml/tests/component\_tests/test\_pca.py](https://codecov.io/gh/alteryx/evalml/pull/3794/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=alteryx#diff-ZXZhbG1sL3Rlc3RzL2NvbXBvbmVudF90ZXN0cy90ZXN0X3BjYS5weQ==) | `0.0% <0.0%> (-100.0%)` | :arrow_down: |
| [evalml/tests/demo\_tests/test\_datasets.py](https://codecov.io/gh/alteryx/evalml/pull/3794/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=alteryx#diff-ZXZhbG1sL3Rlc3RzL2RlbW9fdGVzdHMvdGVzdF9kYXRhc2V0cy5weQ==) | `0.0% <0.0%> (-100.0%)` | :arrow_down: |
| [evalml/tests/objective\_tests/test\_sla.py](https://codecov.io/gh/alteryx/evalml/pull/3794/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=alteryx#diff-ZXZhbG1sL3Rlc3RzL29iamVjdGl2ZV90ZXN0cy90ZXN0X3NsYS5weQ==) | `0.0% <0.0%> (-100.0%)` | :arrow_down: |
| ... and [281 more](https://codecov.io/gh/alteryx/evalml/pull/3794/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 8f915335..d6350ce3 100644
--- a/docs/source/release_notes.rst
+++ b/docs/source/release_notes.rst
@@ -4,6 +4,7 @@ Release Notes
 **Future Releases**
     * Enhancements
     * Fixes
+        * Fixed bug where invalid anchored or offset frequencies were including the ``STLDecomposer`` in pipelines :pr:`3794`
     * Changes
     * Documentation Changes
     * Testing Changes
diff --git a/evalml/pipelines/utils.py b/evalml/pipelines/utils.py
index c4169d5e..6df7f9ae 100644
--- a/evalml/pipelines/utils.py
+++ b/evalml/pipelines/utils.py
@@ -65,7 +65,7 @@ from evalml.problem_types import (
 from evalml.utils import get_time_index, infer_feature_types
 from evalml.utils.gen_utils import contains_all_ts_parameters
 
-_UNSUPPORTED_FREQUENCIES_STL_DECOMPOSER = ["A", "T"]
+_UNSUPPORTED_FREQUENCIES_STL_DECOMPOSER = ["A", "Y", "T", "AS", "YS"]
 
 
 def _get_label_encoder(X, y, problem_type, estimator_class, sampler_name=None):
@@ -231,8 +231,11 @@ 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)
-        freq = time_index.freq
-        if freq not in _UNSUPPORTED_FREQUENCIES_STL_DECOMPOSER:
+        freq = time_index.freq.name.split("-")[0]
+        if (
+            freq[-1] not in _UNSUPPORTED_FREQUENCIES_STL_DECOMPOSER
+            and freq not in _UNSUPPORTED_FREQUENCIES_STL_DECOMPOSER
+        ):
             components.append(STLDecomposer)
     return components
 


Test patch:
diff --git a/evalml/tests/pipeline_tests/test_pipeline_utils.py b/evalml/tests/pipeline_tests/test_pipeline_utils.py
index 7dded3fc..67cebf5d 100644
--- a/evalml/tests/pipeline_tests/test_pipeline_utils.py
+++ b/evalml/tests/pipeline_tests/test_pipeline_utils.py
@@ -40,7 +40,6 @@ from evalml.pipelines.components.utils import (
     handle_component_class,
 )
 from evalml.pipelines.utils import (
-    _UNSUPPORTED_FREQUENCIES_STL_DECOMPOSER,
     _get_pipeline_base_class,
     _get_preprocessing_components,
     _make_pipeline_from_multiple_graphs,
@@ -197,10 +196,22 @@ def test_make_pipeline(
         ProblemTypes.TIME_SERIES_REGRESSION,
     ],
 )
-@pytest.mark.parametrize("frequency", ["D", "MS", "A", "T"])
-def test_make_pipeline_controls_decomposer(
+@pytest.mark.parametrize(
+    "frequency, should_decomp",
+    [
+        ("D", True),
+        ("MS", True),
+        ("A", False),
+        ("T", False),
+        ("10T", False),
+        ("AS-JAN", False),
+        ("YS", False),
+    ],
+)
+def test_make_pipeline_controls_decomposer_time_series(
     problem_type,
     frequency,
+    should_decomp,
     get_test_data_from_configuration,
 ):
     X, y = get_test_data_from_configuration(
@@ -221,14 +232,10 @@ def test_make_pipeline_controls_decomposer(
     pipeline_class = _get_pipeline_base_class(problem_type)
     for estimator_class in estimators:
         if problem_type in estimator_class.supported_problem_types:
-
             pipeline = make_pipeline(X, y, estimator_class, problem_type, parameters)
             assert isinstance(pipeline, pipeline_class)
 
-            if (
-                is_regression(problem_type)
-                and frequency not in _UNSUPPORTED_FREQUENCIES_STL_DECOMPOSER
-            ):
+            if is_regression(problem_type) and should_decomp:
                 assert "STL Decomposer" in pipeline.component_graph.compute_order
             else:
                 assert "STL Decomposer" not in pipeline.component_graph.compute_order