Configuration

View as Markdown

This page covers the runtime configuration options for KumoRFM, including run modes, temporal behavior, inference behavior, batch prediction, and retry handling.

Run Modes

The run_mode parameter controls the trade-off between prediction quality and speed by adjusting how much context data is sampled.

Run ModeContext SizeNeighbor SamplingUse Case
DEBUG100[16, 16, 4, 4, 1, 1]Quick iteration, testing queries
FAST1,000[32, 32, 8, 8, 4, 4]Default. Good balance of speed and quality
NORMAL5,000[64, 64, 8, 8, 4, 4]Higher quality predictions
BEST10,000[64, 64, 8, 8, 4, 4]Maximum quality

For forecasting tasks, when an entity has more historical rows than the Context Size cap, KumoRFM uses the most recent N rows (not the oldest). This ensures forecasts reflect the latest data patterns.

1# Use the fastest mode for quick testing
2result = model.predict(query, run_mode="DEBUG")
3
4# Use the highest quality mode for production
5result = model.predict(query, run_mode="BEST")

You can also fine-tune the neighbor sampling directly:

1result = model.predict(
2 query,
3 num_neighbors=[64, 64, 8, 8, 4, 4],
4)

Temporal and Context Timing

Use these parameters in KumoRFM.predict() and KumoRFM.evaluate() when you need to control the prediction timestamp or the historical examples used as model context.

OptionDefaultDescription
anchor_timeNoneThe anchor timestamp for the prediction. If set to None, KumoRFM uses the maximum timestamp in the data. If set to "entity", KumoRFM uses each entity’s own timestamp.
context_anchor_timeNoneThe maximum anchor timestamp for context examples. If set to None, anchor_time determines the anchor time for context examples.
use_prediction_timeFalseWhether to use the anchor timestamp as an additional feature during prediction. When True, the anchor time is included as a feature for all task types including forecasting.
lag_timesteps0Number of past timesteps to include as lagged target features for temporal predictive queries.

For example, set anchor_time when you want to predict as of a specific point in time:

1result = model.predict(
2 query,
3 indices=[0, 1, 2],
4 anchor_time=pd.Timestamp("2024-06-01"),
5)

Use context_anchor_time when the prediction date and the latest available context data should differ:

1result = model.predict(
2 query,
3 indices=[0, 1, 2],
4 anchor_time=pd.Timestamp("2024-06-01"),
5 context_anchor_time=pd.Timestamp("2024-03-01"),
6)

Set lag_timesteps when recent historical target values should be available to the model as additional context. For example, lag_timesteps=3 adds the previous three target windows as lagged features:

1result = model.predict(
2 query,
3 indices=[0, 1, 2],
4 lag_timesteps=3,
5)

Inference Configuration

The inference_config parameter controls inference-time model behavior, including ensembling. You can pass either a dictionary or a configuration object from kumoapi.rfm.

When you pass a dictionary, KumoRFM casts it based on the task type:

  • Classification tasks use ClassificationInferenceConfig.
  • Regression and forecasting tasks use RegressionInferenceConfig.

If you omit inference_config, KumoRFM selects defaults automatically based on the task type.

Common options:

OptionDescription
num_estimatorsNumber of estimators to ensemble. Defaults to 1 and must be between 1 and 4.
column_shuffleWhether to shuffle column order across estimators.
category_shuffleWhether to shuffle categories within categorical columns across estimators.
hop_shuffleWhether to shuffle subgraph depth across estimators.

Classification option:

OptionDescription
class_shuffleWhether to shuffle class order across estimators.

Regression and forecasting options:

OptionDescription
target_transformsTarget preprocessing transforms to vary across estimators. Supported values are "clip", "power", "quantile", and None. Defaults to ["quantile"].
output_typeHow to summarize the output distribution. Supported values are "median", "mean", and "quantiles". Defaults to "median".

When output_type="quantiles", the prediction output contains 27 quantile columns instead of a single TARGET_PRED column:

q_0.005 q_0.01 q_0.02 q_0.025 q_0.05 q_0.1 q_0.15
q_0.2 q_0.25 q_0.3 q_0.35 q_0.4 q_0.45 q_0.5
q_0.55 q_0.6 q_0.65 q_0.7 q_0.75 q_0.8 q_0.85
q_0.9 q_0.95 q_0.975 q_0.98 q_0.99 q_0.995

Classification example:

1result = model.predict(
2 query,
3 indices=[0, 1, 2],
4 inference_config=dict(
5 num_estimators=4,
6 column_shuffle=True,
7 hop_shuffle=True,
8 class_shuffle=True,
9 ),
10)

Regression example:

1result = model.predict(
2 regression_query,
3 indices=[0, 1, 2],
4 inference_config=dict(
5 num_estimators=4,
6 column_shuffle=True,
7 target_transforms=["quantile", "clip", "power", None],
8 output_type="median",
9 ),
10)

Output and Collection Controls

These options control what predict() returns and how KumoRFM collects valid context labels.

OptionDefaultDescription
return_embeddingsFalseWhether to include embeddings for each prediction example in the output DataFrame.
explainFalseWhether to return an Explanation object instead of a plain prediction DataFrame. Explainability currently supports single-entity predictions with run_mode="FAST". See Prediction Explainability.
max_pq_iterations10Maximum number of iterations used to collect valid labels. Increase this when a predictive query has strict entity filters and KumoRFM needs to sample more entities to find enough valid labels.
random_seed42Manual seed for pseudo-random sampling.
verboseTrueWhether to print progress output during prediction or evaluation.
1result = model.predict(
2 query,
3 indices=[0, 1, 2],
4 return_embeddings=True,
5 max_pq_iterations=20,
6 random_seed=42,
7)

Batch Mode

For predictions over many entities, use KumoRFM.batch_mode() to automatically split the workload into batches:

1with model.batch_mode(batch_size='max', num_retries=1):
2 result = model.predict(
3 "PREDICT COUNT(orders.*, 0, 30, days) > 0 FOR users.user_id=1",
4 indices=list(range(1, 1001)),
5 )

Parameters:

  • batch_size: The number of entities per batch. Set to "max" (default) to use the maximum applicable batch size for the task type.
  • num_retries: Number of retries for failed batches due to server issues.

The maximum prediction sizes per task type are:

Task TypeMax Prediction SizeMax Test Size
Classification / Regression / Forecasting1,0002,000
Temporal Link Prediction200400

Retry

Use KumoRFM.retry() to automatically retry failed queries due to transient server issues:

1with model.retry(num_retries=2):
2 result = model.predict(query, indices=[1, 2, 3])

This is useful for long-running batch predictions where occasional failures are expected.

Size Limits

KumoRFM enforces a 30 MB context size limit per prediction. If exceeded, you will see an error message suggesting:

  • Reducing the number of tables in the graph
  • Reducing the number of columns (e.g., large text columns)
  • Adjusting the neighborhood configuration
  • Using a lower run mode

The optimize parameter in KumoRFM can help with database backends by creating indices for faster sampling:

1model = rfm.KumoRFM(graph, optimize=True)