> ## Documentation Index
> Fetch the complete documentation index at: https://kumo.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Commands and Operators

> Suggest Edits

## PREDICT and FOR EACH

A Predictive Query starts with a `PREDICT` clause that defines the value you want to predict. After specifying the prediction target in `PREDICT`, you must include a `FOR EACH` clause to specify the entity you want to make predictions for. Only a primary key column can be selected for this field.

## Boolean Operators

You can use any number of boolean operators in your predictive queries. For example, `LAST(LOAN.AMOUNT, 0, 30) = 2`.

## ASSUMING

`ASSUMING` allows you to investigate hypothetical scenarios and evaluate the impact of your actions or decisions. The `ASSUMING` keyword is followed by one or more future-looking temporal aggregations which will be assumed to be true during predictions.

For example, you may want to investigate how much a user will spend in the next 30 days if you give them more than two coupons or notifications in the next 7 days:

<CodeGroup>
  ```Text PQL theme={null}
  PREDICT SUM(TRANSACTIONS.PRICE, 0, 30)
  FOR EACH CUSTOMERS.CUSTOMER_ID
  ASSUMING COUNT(NOTIFICATIONS.*, 0, 7) > 2
  ```
</CodeGroup>

<Info />

## CLASSIFY and RANK TOP K

When creating Predictive Queries with a `LIST_DISTINCT` aggregation target, you can use `CLASSIFY` and `RANK TOP K` to classify or retrieve only the top ranked values for a prediction, respectively.

### CLASSIFY

For example, the following predictive query predicts customer purchases over the next 30 days, resulting in a separate binary classification per article ID:

<CodeGroup>
  ```Text PQL theme={null}
  PREDICT LIST_DISTINCT(TRANSACTIONS.ARTICLE_ID, 0, 30) CLASSIFY
  FOR EACH CUSTOMERS.CUSTOMER_ID
  ```
</CodeGroup>

If you don't specify a `TOP K` clause, we will generate classes for all available classes up to the limit.

### RANK

In contrast, the following predictive query uses `RANK TOP K` at the end of the target definition (where K is the number of items of interest) to predict likely customer purchases—in this case ranking the top 12 products the customer is most likely to buy in the next 30 days:

<CodeGroup>
  ```Text PQL theme={null}
  PREDICT LIST_DISTINCT(TRANSACTIONS.ARTICLE_ID, 0, 30) RANK TOP 12
  FOR EACH CUSTOMERS.CUSTOMER_ID
  ```
</CodeGroup>

Using `RANK` on a foreign key is the only scenario where Kumo will allow adding new targets at batch prediction time—in this case, by adding new rows to the article table.

***

What’s Next

* [Putting It All Together](/putting-it-all-together)

* [Table of Contents](#)

* * [PREDICT and FOR EACH](#predict-and-for-each)

  * [Boolean Operators](#boolean-operators)

  * [ASSUMING](#assuming)

  * [CLASSIFY and RANK TOP K](#classify-and-rank-top-k)

    * [CLASSIFY](#classify)
    * [RANK](#rank)
