How to Do Predictive Analysis in Looker with AI
Thinking about the future of your business is no longer a guessing game. By using predictive analysis in Looker, you can use your historical data to make surprisingly accurate forecasts about what's coming next. This article will show you how to get started, from Looker's simple built-in forecasting tools to connecting it with powerful AI models in Google Cloud.
What is Predictive Analysis?
Predictive analysis is the practice of using historical data, statistical algorithms, and machine learning techniques to identify the likelihood of future outcomes. Instead of just looking at what happened (descriptive analytics), it helps you understand what is likely to happen. For a business, this opens up a world of possibilities.
You can use it to:
Forecast Sales and Revenue: Predict how much you'll sell next quarter, helping with inventory management and budgeting.
Identify Churn Risk: Pinpoint customers who are likely to cancel their subscriptions so you can intervene with targeted retention campaigns.
Optimize Marketing Campaigns: Determine which leads are most likely to convert, allowing you to focus your ad spend more effectively.
Anticipate Demand: For e-commerce stores, predict which products will be popular during certain seasons to avoid stockouts.
Traditionally, this was the domain of data scientists who would spend weeks building complex statistical models. But with tools like Looker, especially when combined with AI, a lot of this power is becoming much more accessible.
Option 1: Using Looker's Built-in Forecasting Feature
The easiest way to dip your toes into predictive analysis is with Looker's native forecasting feature. It’s a simple, one-click way to add a forecast to any time-series visualization, making it perfect for quick trend analysis without any complex setup.
This feature uses a model called ARIMA (Autoregressive Integrated Moving Average), which is good at identifying patterns like seasonality and trending behavior in your data history and projecting them into the future.
How to Add a Forecast in Looker
If you have a report that tracks a metric over time, you’re already halfway there. Here’s how to add a forecast:
Create a Query: Build an Explore in Looker that includes at least one time dimension (like "Order Date") and at least one measure (like "Total Sales"). Make sure your visualization is a line chart, area chart, or scatterplot.
Go to Visualization Settings: In the visualization panel, click the "Edit" gear icon.
Find the Forecast Option: Navigate to the "Y" tab. Next to your measure, you'll see a section for "Forecast."
Configure Your Forecast: Click the checkbox to turn it on. You'll see a few options:
Length: How far into the future you want to predict (e.g., 3 months, 12 weeks).
Prediction Interval: This determines the confidence level of your forecast, creating upper and lower bounds for the prediction. A 95% interval, for example, means Looker is 95% confident the actual values will fall within this range.
And that’s it! Your chart will now show a dotted line extending into the future, representing the forecast, along with a shaded area for the prediction interval.
This built-in feature is brilliant for a quick, high-level view of where your key metrics might be heading. However, it's based only on that one metric's historical data. To make more sophisticated predictions that consider multiple factors, you’ll want to bring in more powerful AI tools.
Option 2: Supercharging Looker with Google BigQuery ML (BQML)
For more advanced and accurate predictions, you can combine Looker with Google BigQuery ML (BQML). This approach lets you build and run sophisticated machine learning models directly within your BigQuery data warehouse using simple SQL commands. Looker then acts as the perfect front-end to visualize and interact with the results.
This bridges the gap between your business data and powerful AI without needing to move data out of your warehouse or manage complex Python environments. You can create models that answer more nuanced questions, like "which of my current users are most likely to make a second purchase next month, based on their browsing behavior and initial purchase category?"
Here’s a high-level overview of how that process works.
Step 1: Define Your Business Question
Before you build any model, you need to know what you're trying to solve. A clear question is the most important first step.
Bad Question: "Let's use AI on our customer data."
Good Question: "We want to identify the top 10% of users most likely to stop using our app in the next 30 days so we can send them a special offer."
A good question gives your analysis a clear purpose and helps you define success.
Step 2: Prepare Your Training Data in BigQuery
Machine learning models learn from historical data. For the question above, you'd need to create a table in BigQuery that has one row for each customer and includes:
Features: These are the variables the model will learn from. Examples could include
days_since_last_login,sessions_last_30_days,total_spend,customer_since_date, andplan_type.Label (Target Variable): This is the outcome you're trying to predict. In this case, it would be a column like
has_churned, with a value of TRUE or FALSE based on their historical behavior.
Data quality is incredibly important here. The model is only as good as the data it’s trained on.
Step 3: Create the Predictive Model with BQML
Once you have your training data, you can write a surprisingly simple SQL query in BigQuery to create and train your model. For a churn prediction (a yes/no question), a classification model works well.
This command tells BigQuery to create a machine learning model called customer_churn_model. It will analyze your training data to find patterns and relationships between your feature columns and the has_churned label.
Step 4: Use the Model to Make Predictions
After your model is trained, you can use the ML.PREDICT function to apply it to your current customer data - the ones you want to get a churn prediction for.
This query will return a table with each of your current customers and a new column, churn_probability, indicating the model's confidence that they will churn.
Step 5: Visualize the Predictions in Looker
This is where everything comes together. You can connect that prediction result from BigQuery directly into Looker.
In your LookML project, you can create a derived table that runs the ML.PREDICT query above. Once you've defined this as a new view and added it to your Explore, your whole team can build reports using these AI-powered predictions without ever writing a line of SQL.
You can now build powerful visualizations in Looker, such as:
A dashboard showing your top customers at risk of churn, enriched with their contact info and recent activity.
A report tracking the accuracy of your model over time.
An interactive scatter plot that segments high-value customers by their churn probability.
Your team doesn't need to know how the AI model works - they just know they have a new "Churn Score" available as a field in Looker that they can use to make smarter decisions and take proactive action.
Final Thoughts
Whether you're starting with simple, one-click forecasting for quick trends or diving into powerful AI models with BigQuery ML, Looker provides an incredibly flexible platform for moving from reactive to predictive analytics. Starting small is key, identify one important business question and see how a simple forecast or a basic model can give you the foresight to act more strategically.
We know that setting up BigQuery ML and writing the LookML for derived tables can still feel like a big hurdle. You don’t need to be a data scientist to get a handle on your numbers, but it helps to have tools that work the way you think. At Graphed , we created a way to connect all your data sources and get AI-powered insights using simple, natural language. Instead of wrangling LookML, you can ask for a dashboard showing "a weekly forecast of our Shopify sales for the next 3 months" or "are my Facebook Ads actually a good investment?", and our platform builds it for you in seconds.