Target Specification
PredictionWindowTargetSpec
from tempora.samplers import PredictionWindowTargetSpec
Targets that are generated according to a prediction or lookahead window.
PredictionWindowTargetSpec(
window_len: int | float | dt.timedelta | np.timedelta64 | pd.Timedelta | Length,
window_shift: int | float | dt.timedelta | np.timedelta64 | pd.Timedelta | Length | None = None,
columns: list[str] | None = None,
transform_spec: TransformSpec | LabelEncoder | EventEncoder | None = None
)
Parameters
| Name | Description |
|---|---|
window_len |
Length of the prediction window. |
window_shift |
Optional shift between context window end and target window start. |
columns |
Optional target columns (defaults to all target-capable columns). |
transform_spec |
Optional TransformSpec, LabelEncoder, or EventEncoder for target-window transforms. |
NextStepAheadTargetSpec
from tempora.samplers import NextStepAheadTargetSpec
Next-step ahead targets (requires the context window to be defined in rows).
NextStepAheadTargetSpec(
columns: list[str] | None = None,
transform_spec: TransformSpec | LabelEncoder | EventEncoder | None = None
)
Parameters
| Name | Description |
|---|---|
columns |
Optional target columns. |
transform_spec |
Optional TransformSpec, LabelEncoder, or EventEncoder for target-window transforms. |
ContextWindowTargetSpec
from tempora.samplers import ContextWindowTargetSpec
Targets that are generated according to the current context window.
ContextWindowTargetSpec(
window_len: int | float | dt.timedelta | np.timedelta64 | pd.Timedelta | Length | None = None,
window_shift: int | float | dt.timedelta | np.timedelta64 | pd.Timedelta | Length | None = None,
columns: list[str] | None = None,
transform_spec: TransformSpec | LabelEncoder | EventEncoder | None = None
)
Parameters
| Name | Description |
|---|---|
window_len |
Optional target window length. Defaults to context length. |
window_shift |
Optional shift between context and target windows. |
columns |
Optional target columns. |
transform_spec |
Optional TransformSpec, LabelEncoder, or EventEncoder for target-window transforms. |
SeriesTargetSpec
from tempora.samplers import SeriesTargetSpec
Target specification for full-series sampling.
SeriesTargetSpec(
columns: list[str] | None = None,
transform_spec: TransformSpec | LabelEncoder | EventEncoder | None = None
)
Parameters
| Name | Description |
|---|---|
columns |
Optional subset of target columns. If all selected columns are non-temporal, the target for each sampled series is collapsed to a single row. If any selected column is temporal, the full series target window is returned. |
transform_spec |
Optional TransformSpec, LabelEncoder, or EventEncoder for target-window transforms. For non-temporal targets, the single-row collapse happens before the transform is applied. |
Example: If each entity has a joined static class_label, then SeriesTargetSpec(columns=['class_label']) returns a scalar target for each sampled series.
TimeToEventTargetSpec
from tempora.samplers import TimeToEventTargetSpec
Time-to-event (TTE) targets.
TimeToEventTargetSpec(
window_len: int | float | dt.timedelta | np.timedelta64 | pd.Timedelta | Length,
window_shift: int | float | dt.timedelta | np.timedelta64 | pd.Timedelta | Length | None = None,
columns: list[str] | None = None,
censored: bool = False
)
Parameters
| Name | Description |
|---|---|
window_len |
Window length for event detection. |
window_shift |
Optional shift between context and target windows. |
columns |
Optional target columns. |
censored |
Whether to treat missing events as censored. |