Skip to content

RelFMTabularForecaster

relationalai.semantics.reasoners.predictive
RelFMTabularForecaster(
*,
database: str,
schema: str,
context: b.Concept,
label_column: str,
time_column: str,
max_context_length: int,
item_id_column: Optional[str] = None,
validation: Optional[b.Concept] = None,
eval_metric: Optional[str] = None,
test_batch_size: Optional[int] = None,
stream_logs: bool = True,
dataset_alias: Optional[str] = None,
device: Literal["cpu", "cuda"] = "cpu",
n_estimators: int = 8,
random_state: Optional[int] = 42,
sample_size: Optional[int] = None,
sampling_strategy: str = "stratified",
quantile_levels: Optional[List[float]] = None,
norm_methods: Optional[Union[str, List[str]]] = None
)

Forecasting flat-table RelFM — see RelFMTabular.

forecast(domain=...) requires domain to carry pre-populated future (item_id, time) skeleton rows (no label column), same convention as RelFMTabularPredictor.predictions(domain=...). Output properties on prediction_concept: predicted_value (point estimate) plus, when quantile_levels is set, one quantile_<level> property per level (e.g. quantile_10/quantile_50/quantile_90 for [0.1, 0.5, 0.9]) — plain attribute access, no getattr needed.

The forecast lands exactly on domain’s own (item_id, time) rows — each series may ask for its own dates, at its own spacing. An item with no history in context, or a duplicate (item_id, time) row in domain, is refused before the job runs. A domain date that falls inside context’s own date range raises a leakage warning in get_status()["warnings"], since the model has already seen the true value for that date.

Parameters

  • database

    (str) - Snowflake database to save predictions in.
  • schema

    (str) - Snowflake schema to save predictions in.
  • context

    (Concept) - History/panel Concept — naturally identified by (item_id, time) together (a composite identity, unlike RelFMTabularPredictor’s single natural key), carrying label_column among its own properties.
  • label_column

    (str) - Name of the value property on context/validation.
  • time_column

    (str) - Datetime property name on context/validation/the forecast() domain.
  • max_context_length

    (int) - Max history length (in time steps) looked back over.
  • item_id_column

    (str, default: None) - Series-partition property name for panel/multi-series forecasting. Omit for a single-series forecast.
  • validation

    (Concept, default: None) - Optional labeled validation split.
  • eval_metric

    (str, default: None) - One of "mae", "rmse", or "mape".
  • test_batch_size

    (int | None, default: None)
  • stream_logs

    (int | None, default: None)
  • dataset_alias

    (int | None, default: None)
  • device

    (int | None, default: None)
  • n_estimators

    (int | None, default: None)
  • random_state

    (int | None, default: 42) - See RelFMTabular.
  • sample_size

    (int | None, default: 42) - See RelFMTabular.
  • sampling_strategy

    (int | None, default: 42) - See RelFMTabular.
  • quantile_levels

    (int | None, default: 42) - See RelFMTabular.
  • norm_methods

    (int | None, default: 42) - See RelFMTabular.

Examples

relfm_forecast = RelFMTabularForecaster(
database="MYDB",
schema="MYSCHEMA",
context=SalesHistory,
label_column="sales",
time_column="date",
item_id_column="storeid",
max_context_length=60,
)
FutureWindow.forecast = relfm_forecast.forecast(domain=FutureWindow)

Methods

.forecast()

RelFMTabularForecaster.forecast(domain: b.Concept) -> b.Relationship

Forecast future values for every (item_id, time) row of a domain Concept.

Context is context alone — if validation was also passed to the constructor, it is not automatically folded in as additional context (the SDK notebook this is modeled on builds two separate TabularTasks for score-context vs. predict-context, since context_table is fixed at task-definition time). Call score against validation separately if needed.

Parameters:

  • domain

    (Concept) - Future (item_id, time) rows to forecast for — no label_column, but with time_column (and item_id_column, if this is a multi-series/panel forecast) present. See the class docstring: the actual dates forecast are determined by where context’s history ends, not by domain’s date values.

Returns:

  • Relationship - A forecast relationship: {domain} -> prediction.

Inheritance Hierarchy

RelFMTabularForecaster_RelFMTabularBase