Skip to main content
Once you’ve set up the Graph of your Tables, you can define a machine learning problem as a Kumo PredictiveQuery on your Graph. Predictive queries are written using the predictive query language (PQL), a concise SQL-like syntax that allows you to define a model for a new business problem. For information on the construction of a query string, please visit the Kumo documentation.

Writing a Query

In this example, we predict customer lifetime value — modeled as a regression problem to predict the maximum quantity of transactions for each customer over the next 30 days, given that the customer has made over 15 units worth of transactions in the past 7 days:
pquery = kumo.PredictiveQuery(
    graph=graph,
    query=(
        "PREDICT MAX(transaction.Quantity, 0, 30)\n"
        "FOR EACH customer.CustomerID\n"
        "ASSUMING SUM(transaction.UnitPrice, 0, 7, days) > 15"
    ),
)

# Validate the predictive query syntax:
pquery.validate(verbose=True)