Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"hash": "30931594ac51bdd2e08ac48f0fdeb89e",
"hash": "59a92755f2d22d8d2f65aff5974d179e",
"result": {
"engine": "jupyter",
"markdown": "---\ntitle: multitask.defaults.DefaultsTask\n---\n\n\n\n```python\nmultitask.defaults.DefaultsTask(\n config=None,\n *,\n dataframe=None,\n data_test=None,\n cache_home=None,\n log_level=logging.INFO,\n **overrides,\n)\n```\n\nTask 2 — Defaults fitting (no tuning, no cached params).\n\nCreates an unfitted forecaster per target via ``config.forecaster_factory``\n(or the package default) and fits with whatever parameters that factory\nchooses. Unlike ``LazyTask``, never reads the tuning-result cache.\n\n## Examples {.doc-section .doc-section-examples}\n\n\n::: {#00891dc1 .cell execution_count=1}\n``` {.python .cell-code}\nimport tempfile\nfrom pathlib import Path\nfrom spotforecast2_safe.multitask import DefaultsTask\nfrom spotforecast2_safe.configurator.config_multi import ConfigMulti\n\nwith tempfile.TemporaryDirectory() as tmp:\n cfg = ConfigMulti(data_frame_name=\"demo10\", predict_size=24, cache_home=Path(tmp))\n task = DefaultsTask(cfg)\n print(f\"Task: {task.TASK}\")\n print(f\"Predict size: {task.config.predict_size}\")\n```\n\n::: {.cell-output .cell-output-stdout}\n```\nTask: defaults\nPredict size: 24\n```\n:::\n:::\n\n\n## Methods\n\n| Name | Description |\n| --- | --- |\n| [run](#spotforecast2_safe.multitask.defaults.DefaultsTask.run) | Run defaults fitting for all targets. |\n\n### run { #spotforecast2_safe.multitask.defaults.DefaultsTask.run }\n\n```python\nmultitask.defaults.DefaultsTask.run(show=False, **kwargs)\n```\n\nRun defaults fitting for all targets.\n\n#### Parameters {.doc-section .doc-section-parameters}\n\n| Name | Type | Description | Default |\n|----------|---------------------|------------------------------------------------------------------------------------------------------------|-----------|\n| show | [bool](`bool`) | If ``True``, invoke the visualisation hooks. | `False` |\n| **kwargs | [Any](`typing.Any`) | Forwarded for compatibility with ``BaseTask.run``; ``DefaultsTask`` does not consume any extra parameters. | `{}` |\n\n#### Returns {.doc-section .doc-section-returns}\n\n| Name | Type | Description |\n|--------|------------------------------------------------------------|----------------------------------------------------------------|\n| | [Dict](`typing.Dict`)\\[[str](`str`), [Any](`typing.Any`)\\] | Aggregated prediction package. Per-target packages are stored |\n| | [Dict](`typing.Dict`)\\[[str](`str`), [Any](`typing.Any`)\\] | on ``self.results[\"defaults\"]``. |\n\n#### Examples {.doc-section .doc-section-examples}\n\n::: {#c2229c1d .cell execution_count=2}\n``` {.python .cell-code}\nimport tempfile\nimport warnings\nimport numpy as np\nimport pandas as pd\nfrom pathlib import Path\nfrom spotforecast2_safe.multitask.defaults import DefaultsTask\nfrom spotforecast2_safe.configurator.config_multi import ConfigMulti\n\nrng = np.random.default_rng(0)\nidx = pd.date_range(\"2023-01-01\", periods=24 * 14, freq=\"h\", tz=\"UTC\")\ndf = pd.DataFrame({\"load\": rng.normal(100, 10, len(idx))}, index=idx)\ndf.index.name = \"DateTime\"\n\nwith tempfile.TemporaryDirectory() as tmp:\n cfg = ConfigMulti(\n predict_size=6,\n use_exogenous_features=False,\n use_outlier_detection=False,\n auto_save_models=False,\n number_folds=2,\n cache_home=Path(tmp),\n verbose=False,\n )\n with warnings.catch_warnings():\n warnings.simplefilter(\"ignore\", DeprecationWarning)\n task = DefaultsTask(cfg, dataframe=df)\n task.prepare_data().detect_outliers().impute().build_exogenous_features()\n result = task.run()\n\nprint(f\"Future predictions: {len(result['future_pred'])} steps\")\nassert \"defaults\" in task.results\nassert isinstance(result[\"future_pred\"], pd.Series)\n```\n\n::: {.cell-output .cell-output-stdout}\n```\nFuture predictions: 6 steps\n```\n:::\n:::\n\n\n",
"markdown": "---\ntitle: multitask.defaults.DefaultsTask\n---\n\n\n\n```python\nmultitask.defaults.DefaultsTask(\n config=None,\n *,\n dataframe=None,\n data_test=None,\n cache_home=None,\n log_level=logging.INFO,\n **overrides,\n)\n```\n\nTask 2 — Defaults fitting (no tuning, no cached params).\n\nCreates an unfitted forecaster per target via ``config.forecaster_factory``\n(or the package default) and fits with whatever parameters that factory\nchooses. Unlike ``LazyTask``, never reads the tuning-result cache.\n\n## Examples {.doc-section .doc-section-examples}\n\n\n::: {#c3da1d24 .cell execution_count=1}\n``` {.python .cell-code}\nimport tempfile\nfrom pathlib import Path\nfrom spotforecast2_safe.multitask import DefaultsTask\nfrom spotforecast2_safe.configurator.config_multi import ConfigMulti\n\nwith tempfile.TemporaryDirectory() as tmp:\n cfg = ConfigMulti(data_frame_name=\"demo10\", predict_size=24, cache_home=Path(tmp))\n task = DefaultsTask(cfg)\n print(f\"Task: {task.TASK}\")\n print(f\"Predict size: {task.config.predict_size}\")\n```\n\n::: {.cell-output .cell-output-stdout}\n```\nTask: defaults\nPredict size: 24\n```\n:::\n:::\n\n\n## Methods\n\n| Name | Description |\n| --- | --- |\n| [run](#spotforecast2_safe.multitask.defaults.DefaultsTask.run) | Run defaults fitting for all targets. |\n\n### run { #spotforecast2_safe.multitask.defaults.DefaultsTask.run }\n\n```python\nmultitask.defaults.DefaultsTask.run(show=False, **kwargs)\n```\n\nRun defaults fitting for all targets.\n\n#### Parameters {.doc-section .doc-section-parameters}\n\n| Name | Type | Description | Default |\n|----------|---------------------|------------------------------------------------------------------------------------------------------------|-----------|\n| show | [bool](`bool`) | If ``True``, invoke the visualisation hooks. | `False` |\n| **kwargs | [Any](`typing.Any`) | Forwarded for compatibility with ``BaseTask.run``; ``DefaultsTask`` does not consume any extra parameters. | `{}` |\n\n#### Returns {.doc-section .doc-section-returns}\n\n| Name | Type | Description |\n|--------|------------------------------------------------------------|----------------------------------------------------------------|\n| | [Dict](`typing.Dict`)\\[[str](`str`), [Any](`typing.Any`)\\] | Aggregated prediction package. Per-target packages are stored |\n| | [Dict](`typing.Dict`)\\[[str](`str`), [Any](`typing.Any`)\\] | on ``self.results[\"defaults\"]``. |\n\n#### Examples {.doc-section .doc-section-examples}\n\n::: {#f4d150b3 .cell execution_count=2}\n``` {.python .cell-code}\nimport tempfile\nimport numpy as np\nimport pandas as pd\nfrom pathlib import Path\nfrom spotforecast2_safe.multitask.defaults import DefaultsTask\nfrom spotforecast2_safe.configurator.config_multi import ConfigMulti\n\nrng = np.random.default_rng(0)\nidx = pd.date_range(\"2023-01-01\", periods=24 * 14, freq=\"h\", tz=\"UTC\")\ndf = pd.DataFrame({\"load\": rng.normal(100, 10, len(idx))}, index=idx)\ndf.index.name = \"DateTime\"\n\nwith tempfile.TemporaryDirectory() as tmp:\n cfg = ConfigMulti(\n predict_size=6,\n use_exogenous_features=False,\n use_outlier_detection=False,\n auto_save_models=False,\n number_folds=2,\n cache_home=Path(tmp),\n verbose=False,\n )\n task = DefaultsTask(cfg, dataframe=df)\n task.prepare_data().detect_outliers().impute().build_exogenous_features()\n result = task.run()\n\nprint(f\"Future predictions: {len(result['future_pred'])} steps\")\nassert \"defaults\" in task.results\nassert isinstance(result[\"future_pred\"], pd.Series)\n```\n\n::: {.cell-output .cell-output-stdout}\n```\nFuture predictions: 6 steps\n```\n:::\n:::\n\n\n",
"supporting": [
"multitask.defaults.DefaultsTask_files/figure-html"
],
Expand Down
30 changes: 15 additions & 15 deletions docs/reference/manager.features.get_target_data.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ manager.features.get_target_data(
target,
df_pipeline,
config,
*,
data_with_exog=None,
exog_feature_names=None,
exo_pred=None,
start_train_ts=None,
end_train_ts=None,
start_train_ts,
end_train_ts,
)
```

Expand All @@ -27,22 +28,21 @@ engineering are applied consistently across all forecasting tasks.

The training-window timestamps are supplied as explicit parameters so that
this helper stays decoupled from ``RunState`` (ADR
``adr-multitask-configmulti-merge``, step 5). When either is ``None``
the function falls back to the corresponding attribute on *config* for
backward compatibility with existing direct callers.
``adr-multitask-configmulti-merge``, step 5). Both parameters are
required; passing ``None`` raises ``ValueError``.

## Parameters {.doc-section .doc-section-parameters}

| Name | Type | Description | Default |
|--------------------|---------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------|
| target | [str](`str`) | Name of the target column to extract from *df_pipeline*. | _required_ |
| df_pipeline | [pd](`pandas`).[DataFrame](`pandas.DataFrame`) | DataFrame with a tz-aware `DatetimeIndex` containing all target columns produced by the preprocessing pipeline. | _required_ |
| config | \'ConfigMulti\' | Pipeline configuration object. ``use_exogenous_features`` must be set. ``start_train_ts`` / ``end_train_ts`` are only read from *config* when the explicit parameters are not supplied. | _required_ |
| data_with_exog | [Optional](`typing.Optional`)\[[pd](`pandas`).[DataFrame](`pandas.DataFrame`)\] | Merged DataFrame of target and exogenous columns covering at least the training window. Required when ``config.use_exogenous_features`` is ``True``. Pass ``None`` (default) to skip exogenous slicing. | `None` |
| exog_feature_names | [Optional](`typing.Optional`)\[[List](`typing.List`)\[[str](`str`)\]\] | Column names to select from *data_with_exog* and *exo_pred*. Required when *data_with_exog* is not ``None``. Pass ``None`` (default) when exogenous features are disabled. | `None` |
| exo_pred | [Optional](`typing.Optional`)\[[pd](`pandas`).[DataFrame](`pandas.DataFrame`)\] | Exogenous feature DataFrame covering the forecast horizon. Required when *data_with_exog* is not ``None``. Pass ``None`` (default) when exogenous features are disabled. | `None` |
| start_train_ts | [Optional](`typing.Optional`)\[[pd](`pandas`).[Timestamp](`pandas.Timestamp`)\] | Inclusive start of the training window (tz-aware ``pd.Timestamp``). **Required** — pass ``task.run_state.start_train_ts`` after the pipeline has been prepared. Omitting this argument raises ``ValueError``; reading the value from ``config.start_train_ts`` is deprecated and emits a ``DeprecationWarning``. | `None` |
| end_train_ts | [Optional](`typing.Optional`)\[[pd](`pandas`).[Timestamp](`pandas.Timestamp`)\] | Inclusive end of the training window (tz-aware ``pd.Timestamp``). **Required** — pass ``task.run_state.end_train_ts`` after the pipeline has been prepared. Omitting this argument raises ``ValueError``; reading the value from ``config.end_train_ts`` is deprecated and emits a ``DeprecationWarning``. | `None` |
| Name | Type | Description | Default |
|--------------------|---------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------|
| target | [str](`str`) | Name of the target column to extract from *df_pipeline*. | _required_ |
| df_pipeline | [pd](`pandas`).[DataFrame](`pandas.DataFrame`) | DataFrame with a tz-aware `DatetimeIndex` containing all target columns produced by the preprocessing pipeline. | _required_ |
| config | \'ConfigMulti\' | Pipeline configuration object. ``use_exogenous_features`` must be set. | _required_ |
| data_with_exog | [Optional](`typing.Optional`)\[[pd](`pandas`).[DataFrame](`pandas.DataFrame`)\] | Merged DataFrame of target and exogenous columns covering at least the training window. Required when ``config.use_exogenous_features`` is ``True``. Pass ``None`` (default) to skip exogenous slicing. | `None` |
| exog_feature_names | [Optional](`typing.Optional`)\[[List](`typing.List`)\[[str](`str`)\]\] | Column names to select from *data_with_exog* and *exo_pred*. Required when *data_with_exog* is not ``None``. Pass ``None`` (default) when exogenous features are disabled. | `None` |
| exo_pred | [Optional](`typing.Optional`)\[[pd](`pandas`).[DataFrame](`pandas.DataFrame`)\] | Exogenous feature DataFrame covering the forecast horizon. Required when *data_with_exog* is not ``None``. Pass ``None`` (default) when exogenous features are disabled. | `None` |
| start_train_ts | [pd](`pandas`).[Timestamp](`pandas.Timestamp`) | Inclusive start of the training window (tz-aware ``pd.Timestamp``). **Keyword-only, required** — pass ``task.run_state.start_train_ts`` after the pipeline has been prepared. Passing ``None`` raises ``ValueError``. | _required_ |
| end_train_ts | [pd](`pandas`).[Timestamp](`pandas.Timestamp`) | Inclusive end of the training window (tz-aware ``pd.Timestamp``). **Keyword-only, required** — pass ``task.run_state.end_train_ts`` after the pipeline has been prepared. Passing ``None`` raises ``ValueError``. | _required_ |

## Returns {.doc-section .doc-section-returns}

Expand Down
Loading
Loading