Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherbunn committed Sep 28, 2023
1 parent 8200319 commit 068d0d4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 63 deletions.
3 changes: 2 additions & 1 deletion evalml/pipelines/time_series_regression_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ def get_prediction_intervals(
self.time_index,
self.input_target_name,
)

X_no_datetime, y_no_datetime = self._drop_time_index(X, y)

Check warning on line 226 in evalml/pipelines/time_series_regression_pipeline.py

View check run for this annotation

Codecov / codecov/patch

evalml/pipelines/time_series_regression_pipeline.py#L226

Added line #L226 was not covered by tests

estimator_input = self.transform_all_but_final(

Check warning on line 228 in evalml/pipelines/time_series_regression_pipeline.py

View check run for this annotation

Codecov / codecov/patch

evalml/pipelines/time_series_regression_pipeline.py#L228

Added line #L228 was not covered by tests
Expand All @@ -241,7 +242,7 @@ def get_prediction_intervals(
}
residuals = self.estimator.predict(
estimator_input,
) # Get residual values
)
trans_pred_intervals = {}
if self.problem_type == ProblemTypes.MULTISERIES_TIME_SERIES_REGRESSION:
trend_pred_intervals = self.get_component(

Check warning on line 248 in evalml/pipelines/time_series_regression_pipeline.py

View check run for this annotation

Codecov / codecov/patch

evalml/pipelines/time_series_regression_pipeline.py#L246-L248

Added lines #L246 - L248 were not covered by tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,11 @@ def test_time_series_get_forecast_predictions(
@pytest.mark.parametrize("set_coverage", [True, False])
@pytest.mark.parametrize("add_decomposer", [True, False])
@pytest.mark.parametrize("ts_native_estimator", [True, False])
# @patch(
# "evalml.pipelines.components.transformers.preprocessing.stl_decomposer.STLDecomposer.transform"
# )
def test_time_series_pipeline_get_prediction_intervals(

Check warning on line 250 in evalml/tests/pipeline_tests/regression_pipeline_tests/test_multiseries_regression_pipeline.py

View check run for this annotation

Codecov / codecov/patch

evalml/tests/pipeline_tests/regression_pipeline_tests/test_multiseries_regression_pipeline.py#L247-L250

Added lines #L247 - L250 were not covered by tests
# mock_transform,
ts_native_estimator,
add_decomposer,
set_coverage,
multiseries_ts_data_stacked,
generate_seasonal_data,
):
X, y = multiseries_ts_data_stacked
y = pd.Series(np.random.rand(100), name="target")
Expand Down Expand Up @@ -324,63 +319,6 @@ def test_time_series_pipeline_get_prediction_intervals(
if set_coverage is False:
coverage = [0.95]

Check warning on line 320 in evalml/tests/pipeline_tests/regression_pipeline_tests/test_multiseries_regression_pipeline.py

View check run for this annotation

Codecov / codecov/patch

evalml/tests/pipeline_tests/regression_pipeline_tests/test_multiseries_regression_pipeline.py#L319-L320

Added lines #L319 - L320 were not covered by tests

# # The time series native estimators are handled separately when they have
# # a decomposer in the pipeline
# if ts_native_estimator and add_decomposer:
# predictions = pipeline.predict_in_sample(
# X_validation,
# y_validation,
# X_train,
# y_train,
# )
# X_validation, y_validation = pipeline._drop_time_index(
# X_validation,
# y_validation,
# )
# X_validation_unstacked, y_validation_unstacked = unstack_multiseries(
# X_validation,
# y_validation,
# "series_id",
# "date",
# "target",
# )
# features = pipeline.transform_all_but_final(
# X_validation_unstacked,
# y_validation_unstacked,
# X_train,
# y_train,
# )
# est_intervals = pipeline.estimator.get_prediction_intervals(
# X=features,
# y=y_validation_unstacked,
# predictions=predictions,
# coverage=coverage,
# )
#
# trend_pred_intervals = pipeline.get_component(
# "STL Decomposer",
# ).get_trend_prediction_intervals(y_validation, coverage=coverage)
# residuals = pipeline.estimator.predict(features)
#
# for cover_value in coverage:
# for key in [f"{cover_value}_lower", f"{cover_value}_upper"]:
# pl_interval = pl_intervals[key]
# residual_dict = {
# series_id: {} for series_id in X_train["series_id"].unique()
# }
# for series_id in X_train["series_id"].unique():
# residual_dict[series_id] = (
# est_intervals[int(series_id)][key] - residuals[int(series_id)]
# )
# residual_df = stack_data(pd.DataFrame(residual_dict))
# expected_res = pd.Series(
# residual_df.values
# + trend_pred_intervals[key].values
# + y_validation.values,
# index=trend_pred_intervals[key].index,
# )
# assert_series_equal(expected_res, pl_interval)

if set_coverage:
pairs = [(0.75, 0.85), (0.85, 0.95)]
for pair in pairs:
Expand Down

0 comments on commit 068d0d4

Please sign in to comment.