frame a predictive problem what who under what context 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.
Anatomy of a Predictive Query
At its core, a predictive query follows this structure:| Component | Purpose |
|---|---|
PREDICT | Declares 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). |
FOR | Specifies 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: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.:
3. Pin the entity list
You can specify one entity or a group of entities explicitly:4. (Optional) Refine the context
Use theWHERE clause to control the feature generation window or apply static filters.For example:
5. Run & fetch results
Execute your predictive query using the RFM client:To see more examples on predictive query refer to predictive query reference