Skip to main content
Once you have created your graph, the next step is to frame a predictive problem — defining what you want to predict, who to predict for, and under what context. Kumo provides a simple, declarative way to do this using the Predictive Query Language (PQL).
If you are familiar with Predictive query, scroll down to section “5. Run & fetch results” to get the code to make prediction on your graph

What is PQL?

Predictive Query Language (PQL) is a declarative, SQL-like syntax that lets you describe an entire machine learning task in a single statement. A predictive query defines:
  • The target value to predict,
  • The entity or set of entities to make predictions for,
  • And optionally, filters that refine the feature context.
Once defined, RFM automatically handles feature computation, time alignment, and train table generation - all based on your underlying graph.

Anatomy of a Predictive Query

At its core, a predictive query follows this structure:
PREDICT <target_expression>
FOR <entity_specification>
[WHERE <filters>]
ComponentPurpose
PREDICTDeclares the target - the value you want the model to output. This can be a column or an aggregation over a future window (e.g., total spend in the next 30 days).
FORSpecifies who to predict for - the main entity of interest (e.g., customer, user, account). You provide an explicit ID or an IN (...) list.
WHERE (optional)Applies contextual filters to the data used for feature generation. Unlike FOR, it doesn’t limit which entities are predicted for - it only shapes the feature computation context.

Writing Queries in Kumo

To write a predictive query in Kumo, follow these five steps:

1. Choose your entity

Select the table and primary key column that represent the entity you’ll predict for. Example:
FOR customer_id
This tells RFM to make predictions for each customer_id

2. Define the target

The target defines what outcome or value the model should predict.
It can be:
  • A raw column, e.g., PREDICT customer_churn_flag
  • Or an aggregation over a future horizon, e.g.:
PREDICT SUM(orders.PRICE, 0,30, days)
This tells RFM to predict total transaction amount over the next 30 days for each customer.

3. Pin the entity list

You can specify one entity or a group of entities explicitly:
FOR customer_id IN = 101
OR
FOR customer_id IN (101, 102,103,104)
This ensures RFM generates predictions only for the entities you care about.

4. (Optional) Refine the context

Use the WHERE clause to control the feature generation window or apply static filters.
For example:
WHERE region = 'North America'
This does not change the entities you’re predicting for - it simply limits which historical data RFM uses when building features.

5. Run & fetch results

Execute your predictive query using the RFM client:
model = rfm.KumoRFM(graph) 
#From the graph creation step [Insert link to the graph creation page]

query = """PREDICT sum(orders.PRICE, 0,30)
FOR customers.customer_id = 101
"""
prediction_result = model.predict(query) 
print(prediction_result)
To see more examples on predictive query refer to predictive query reference