A simple guide to Cortex ML Functions: Unveiling the Future with Forecasting

Mastering Snowflake
4 min readMay 30, 2024


Thank you for reading my latest article A simple guide to Cortex ML Functions: Unveiling the Future with Forecasting

Here at Medium I regularly write about modern data platforms and technology trends. To read my future articles simply join my network here or click ‘Follow’. Also feel free to connect with me via YouTube.

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

Forecasting is a powerful tool that leverages historical data to predict future outcomes. By utilizing advanced machine learning algorithms, forecasting can provide insights that are crucial for decision-making in various industries. In this blog post, we will explore what forecasting is, why it is useful, and how Snowflake Cortex enhances forecasting capabilities.

What is Forecasting?

Forecasting is the process of making predictions about future events based on historical data. It involves the use of statistical models and machine learning algorithms to analyze patterns and trends in past data, which can then be used to predict future values. The primary goal of forecasting is to provide a data-driven basis for making informed decisions.

Why is Forecasting Useful?

Forecasting is invaluable in a myriad of applications. It helps businesses and organizations anticipate changes and plan accordingly. For example, in retail, forecasting can predict future sales, allowing for better inventory management and resource allocation. In finance, it can forecast market trends, aiding in investment strategies. By providing a glimpse into the future, forecasting enables proactive measures, reducing uncertainty and enhancing strategic planning.

Snowflake Cortex and Forecasting

Snowflake Cortex takes forecasting to the next level by integrating advanced machine learning capabilities directly within the Snowflake data platform. This integration simplifies the forecasting process, making it accessible and efficient for users. Let’s delve into how Snowflake Cortex enhances forecasting.

The Mechanics of Forecasting with Snowflake Cortex

Historical Data Requirements:

  • Timestamp Column: This column should have a fixed frequency, such as hourly or daily timestamps.
  • Target Column: Represents the quantity of interest at each timestamp, such as sales figures.
  • Exogenous Variables (optional): Additional columns that might influence the target variable, like promotional events or economic indicators. These can be numerical or categorical data.

Training the Model:

The historical data is used to train a machine learning model. This model analyzes the patterns and relationships in the data to produce forecasts. The trained model is a schema-level object in Snowflake, which can be reused for multiple forecasting tasks.

Single-Series and Multi-Series Data:

  • Single-Series Data: Represents one sequence of events, such as sales data for a single store.
  • Multi-Series Data: Represents multiple sequences of events, such as sales data for multiple stores. The model can forecast each series separately based on a unique identifier, such as the store ID.

Forecasting with Snowflake Cortex:

  • Creating a Forecast Model: Use the Snowflake built-in class FORECAST (SNOWFLAKE.ML) to create a forecast model object. This object fits the model to the training data.
  • Generating Forecasts: Once the model is trained, you can call the forecast method to produce future predictions. This involves specifying the number of future time steps or providing future values of exogenous variables if they are used.

Practical Use Case: Forecasting Sales

Consider a retail company that wants to forecast its sales for the upcoming holiday season. By using Snowflake Cortex, the company can train a model using historical sales data, including timestamps, sales figures, and exogenous variables like marketing spend and holiday promotions. The trained model can then predict future sales, helping the company optimize inventory levels, staffing, and promotional strategies.


Forecasting is a critical component of modern data analytics, enabling organizations to anticipate and prepare for future events. Snowflake Cortex streamlines the forecasting process by providing robust machine learning capabilities within the Snowflake platform. By leveraging historical data and advanced algorithms, businesses can gain valuable insights and make data-driven decisions to stay ahead in a competitive landscape.

Embrace forecasting with Snowflake Cortex and unlock the power of predictive analytics for your organization. Let’s dive into a demo to show you how easy it is to use Snowflake and the forecasting Cortex function!

To stay up to date with the latest business and tech trends in data and analytics, make sure to subscribe to my newsletter, follow me on LinkedIn, and YouTube, and, if you’re interested in taking a deeper dive into Snowflake check out my books ‘Mastering Snowflake Solutions and SnowPro Core Certification Study Guide’.

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — -

About Adam Morton

Adam Morton is an experienced data leader and author in the field of data and analytics with a passion for delivering tangible business value. Over the past two decades Adam has accumulated a wealth of valuable, real-world experiences designing and implementing enterprise-wide data strategies, advanced data and analytics solutions as well as building high-performing data teams across the UK, Europe, and Australia.

Adam’s continued commitment to the data and analytics community has seen him formally recognised as an international leader in his field when he was awarded a Global Talent Visa by the Australian Government in 2019.

Today, Adam is dedicated to helping his clients to overcome challenges with data while extracting the most value from their data and analytics implementations. You can find out more information by visiting his website here.



Mastering Snowflake

Our mission is to help people trapped in a career dead end, working with on-premise, legacy technology break into cloud computing by using Snowflake.