Time Series Forecasting: End-to-End using Snowpark ML in Snowflake Notebooks | by Deepti Agrawal | Aug, 2024


In this project, we are developing a linear regression model to forecast shoe sales.

Linear regression is a straightforward yet powerful statistical method that predicts a dependent variable based on the relationship with one or more independent variables. By fitting a line to the historical sales data, the model will help us understand trends and make future predictions.

Using Snowpark ML, we’ll leverage Snowflake’s capabilities to train and evaluate this model efficiently within Snowflake Notebooks.

Linear Regression SnowparkML

We can bundle our model building and pre-processing steps up together as a Pipeline object and save that as an artifact to use later during training and inference.

Here, we have developed a Linear Regression model using our training and test data with the LinearRegression class from snowflake.ml.modeling.linear_model.

After building the Linear Regression model, we used the fit() function to train the model on our training data. This function adjusts the model parameters to best capture the relationship between the features and the target variable.

Following training, we applied the predict() function to generate forecasted sales based on the test data. This function uses the trained model to estimate future values, allowing us to evaluate the model’s performance and make informed predictions.

Now, we will plot the training data, testing data and Linear Regression test predicted data together to visualize the series.

Model Prediction Plot

After generating predictions with our model and plotting the results, we observed that the accuracy was not satisfactory.

This indicates the need for further refinement. To improve our predictions, we should consider experimenting with various models, such as XGBoost, Naive Bayes, and smoothing techniques, before selecting the best-performing model for final predictions.

This iterative approach will help us find a more accurate and reliable model for forecasting.

Recent Articles

Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here