HDM-56 Predict Customer Spending with Linear Regression in Db2 @IBMProductHub
HDM-56 Predict Customer Spending with Linear Regression in Db2  @IBMProductHub
Uploaded September 2026 | Updated November 2026, 2 days ago
Description:
**Learn how to predict customer spending using Linear Regression with Db2's built-in machine learning stored procedures. No external tools required.**

In this demo, I walk through training a regression model entirely inside the database using Db2's ML stored procedures. Starting with 48,202 customer records, I show the full pipeline: data preprocessing, model training, prediction generation, and evaluation.

**What you'll learn:**
- How to split datasets into training and test partitions (80/20 split)
- Data cleaning with Db2 stored procedures (handling missing values like customer age)
- Training a linear regression model directly in SQL
- Generating real-time predictions by changing customer attributes
- Evaluating model quality with MAE and MAPE

**What's covered:**
The problem of predicting customer spend. The dataset and what we know about each customer. Training a linear regression model with Db2 stored procedures. Data preprocessing steps: splitting, cleaning, imputation. Running the training pipeline. Making predictions with different customer attributes. The prediction SQL behind the scenes. Model evaluation metrics (MAE, MAPE).

**Resources:**
Full setup steps and code in the Db2 AI Cookbook repo:
github.com/IBM/db2-ai-cookbook/tree/main/07-in-database-ml/gosales-linear-regression

Like and subscribe for more Db2, SQL, and AI tutorials. Drop questions in the comments.
HDM-56 Predict Customer Spending with Linear Regression in Db2How to Parse Custom Logs Fast with IBM QRadar DSM EditorHow to check Genius Hub logs on IBM DB2 Genius Hub ServerAccelerating Integration Development with IBM App Connect Flow Pilot
IBM Product Hub |

HDM-56 Predict Customer Spending with Linear Regression in Db2

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER