Skip to content

RelFMTabular

relationalai.semantics.reasoners.predictive
RelFMTabular(
*,
database: str,
schema: str,
context: b.Concept,
label_column: str,
task_type: str,
validation: Optional[b.Concept] = None,
eval_metric: Optional[str] = None,
time_column: Optional[str] = None,
item_id_column: Optional[str] = None,
max_context_length: Optional[int] = 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",
clamp_min: Optional[int] = 0,
clamp_max: Optional[int] = 100,
regression_output: Literal["point", "distribution"] = "point",
quantile_levels: Optional[List[float]] = None,
norm_methods: Optional[Union[str, List[str]]] = None
) -> Union[RelFMTabularPredictor, RelFMTabularForecaster]

Predict in-context with RelFM on a single flat table — no relational joins.

Standalone alternative to RelFM for data that’s already one flat table per split (features + label all on the same row) — no Graph, no shared entity Concept across splits, no Relationship wrapping. Each of context/validation/the domain passed to predictions()/forecast() is its own Concept.

A thin factory: dispatches to RelFMTabularPredictor (classification/ regression) or RelFMTabularForecaster (forecasting) based on task_type, since the two have disjoint parameters and validation. Construct that subclass directly instead if you want static type-checking of exactly which parameters apply.

Parameters

  • database

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

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

    (Concept) - Labeled split (or, for forecasting, the history/panel Concept), used directly as in-context examples (RelFM has no training step).
  • label_column

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

    (str) - One of "binary_classification", "multiclass_classification", "regression", or "forecasting".
  • validation

    (Concept, default: None) - Optional labeled validation split. Does not need to be the same Concept as context — only needs the same feature columns.
  • eval_metric

    (str, default: None) - Evaluation metric compatible with the chosen task_type. For "forecasting": "mae", "rmse", or "mape".
  • time_column

    (str, default: None) - Datetime property name. Required when task_type="forecasting".
  • item_id_column

    (str, default: None) - Series-partition property name for panel/multi-series forecasting. Forecasting-only.
  • max_context_length

    (int, default: None) - Max history length (in time steps) looked back over. Required when task_type="forecasting".
  • test_batch_size

    (int, default: None) - Batch size used during inference. Default is 256.
  • stream_logs

    (bool, default: True) - Stream logs to stdout. Default is True.
  • dataset_alias

    (str, default: None) - User chosen alias for the dataset.
  • device

    (str, default: “cpu”) - Inference device, "cpu" (default) or "cuda".
  • n_estimators

    (int, default: 8) - Ensemble size. More = better quality, slower inference. Default is 8.
  • random_state

    (int, default: 42) - Seed for ensemble generation and context sampling. Default is 42.
  • sample_size

    (int, default: None) - Max context rows sampled from context. Default (None) uses all rows.
  • sampling_strategy

    (str, default: “stratified”) - How to draw the context sample: "stratified" (default), "most_recent", "mixed", "random", or "balanced".
  • clamp_min

    (int, default: 0) - Min percentile clamp for regression predictions. Default is 0. Classification/regression-only.
  • clamp_max

    (int, default: 100) - Max percentile clamp for regression predictions. Default is 100. Classification/regression-only.
  • regression_output

    (str, default: “point”) - "point" (default) or "distribution". Classification/regression-only.
  • quantile_levels

    (list of float, default: None) - Quantile levels output when regression_output="distribution" or for forecasting tasks.
  • norm_methods

    (str or list of str, default: None) - Feature normalization method(s).

Returns

Examples

relfm_tabular = RelFMTabular(
database="MYDB",
schema="MYSCHEMA",
context=Customer,
label_column="lifetime_value",
task_type="regression",
eval_metric="rmse",
)
Customer.predictions = relfm_tabular.predictions(domain=TestCustomer)