Infer offers suggested analyses using Coworker AI, which constructs the view and query required to do the analysis.
If you would rather write your own custom analysis from scratch, you can follow the basic steps below or see our Use Cases page for more examples.
Create a View
Creating a view in SQL allows you to define a virtual table based on the result-set of a SQL statement. This enables you to simplify complex queries, encapsulate complex logic, or pre-calculate commonly needed results. Creating a view can be particularly useful in the feature engineering stage, as it allows you to prepare and structure your data before running advanced analyses.
SUM(p.purchase_amount) AS total_spent,
AVG(p.purchase_amount) AS avg_spending,
customers c ON p.customer_id = c.id
p.customer_id, c.age, c.country;
In this example, the view
CustomerProfileView contains the
customer_id, the total and average amounts spent by each customer, as well as their age and country.
Write a SQL-inf Query
After creating a view, the next step is to write a SQL-inf query that performs the analysis you're interested in. SQL-inf extends traditional SQL with commands like
RECOMMEND, and more, allowing for machine learning-based analyses right within the SQL environment.
SELECT * FROM CustomerProfileView PREDICT(avg_spending)
In this example, the SQL-inf query predicts
avg_spending for each customer in the
Once you've crafted your custom SQL-inf query, the final step is to execute it. The results will vary depending on the options and commands you've used in your query. You can then analyze the output data, visualize it, or use it in further queries to gather insights and make data-driven decisions.
By following these steps, you can conduct custom analyses tailored to your specific needs and questions. For more information and examples, check out our Use Cases page.