Tuesday, August 19, 2025

Demand Sales Forecasting with HeatWave Regression for Manufacturing Company

 

Introduction

In the manufacturing sector, demand forecasting is the heartbeat of efficient operations. Knowing how many units of a product will sell in the future allows companies to optimize production schedules, manage inventory, and align supply chain decisions with actual customer demand.

Traditionally, demand forecasting requires building machine learning pipelines, exporting sales data into external ML tools, and integrating the results back into applications. This process is time-consuming, complex, and costly.

Enter Oracle MySQL HeatWave with AutoML — a fully integrated in-database machine learning solution that enables forecasting directly within the MySQL database. This means that manufacturing companies can predict future sales quantities without leaving their operational database environment.

In this blog, we’ll explore how a manufacturing company can use HeatWave regression models to forecast monthly sales demand per branch, using historical sales data as input.


Why Demand Forecasting Matters in Manufacturing

For manufacturing companies, demand forecasting is critical because:

  1. Production Planning: Aligns factory output with expected demand.

  2. Inventory Optimization: Reduces carrying costs by avoiding overproduction.

  3. Branch-level Allocation: Ensures each regional warehouse or retail branch is stocked appropriately.

  4. Cost Efficiency: Prevents both stockouts (lost sales) and overstocks (wasted capital).

  5. Customer Satisfaction: Guarantees availability of products when customers need them.

For example, if a manufacturer sells electrical appliances across 100 branches, forecasting how many air conditioners each branch will sell next month enables better procurement, logistics, and marketing strategies.

Dataset Overview

Let’s assume we have a sales dataset that records historical monthly sales of items across multiple branches.

sale_month branch_id item_id sales_quantity
2023-01-01 B001 AC100         120
2023-02-01 B001 AC100         135
2023-03-01 B001 AC100         110
2023-01-01 B002 AC100         90
2023-02-01 B002 AC100         105

  • sale_month: The month of sale.

  • branch_id: The branch where the sale occurred.

  • item_id: Unique identifier for the product.

  • sales_quantity: Number of units sold.

The goal is to forecast future sales_quantity per (branch_id, item_id) pair for upcoming months.

Here is the Demo

https://youtu.be/Z1NPmXakh1c

Why HeatWave AutoML Regression?

HeatWave AutoML supports regression tasks, which are ideal for predicting numerical outcomes such as sales quantity.

Advantages for manufacturers:

  • In-Database Learning: No ETL required, models run inside HeatWave.

  • Auto Feature Engineering: Automatically detects time-series features (lags, rolling averages).

  • Model Selection: Trains and tunes multiple regression algorithms (XGBoost, Linear, Random Forest) and picks the best one.

  • Deployment: Prediction functions are published as SQL UDFs, enabling forecasts in real time.

  • Scalability: Handles millions of rows across branches/items with distributed execution.

Step 1: Data Preparation

We start with a cleaned dataset inside MySQL HeatWave.

CREATE TABLE branch_item_sales (

    sale_month DATE,

    branch_id VARCHAR(20),

    item_id VARCHAR(20),

    sales_quantity INT,

    PRIMARY KEY (sale_month, branch_id, item_id)

);


Load historical sales data using MySQL Shell’s util.loadDump() or directly from cloud object storage.

Step 2: Train Regression Model with HeatWave AutoML

We now invoke HeatWave AutoML to train a regression model to forecast sales quantity.

mysql> CALL sys.ML_TRAIN('census_data.census_train', 'sales_quantity', JSON_OBJECT('task', 'regression'), @census_model);

This command automates:

  • Feature generation (e.g., sales lag from previous month).

  • Model training and hyperparameter tuning.

  • Cross-validation to select the best regression model.

Step 3: Evaluate the Model

We can assess the model’s performance using:

CALL sys.ML_SCORE('myTVSPartsmart.KiSales_year2024_2025_final_testdata', 'sales_total_quantity', @models12345, 'r2', @score12345, NULL);

mysql> CALL sys.ML_MODEL_LOAD(@census_model, NULL);

mysql> CALL sys.ML_SCORE('census_data.census_test', 'sales_quantity', @census_model, 'accuracy', @score, NULL);

Step 4: Deploy Forecasting Model

Deploy the trained regression model as a callable SQL function:

mysql> CALL sys.ML_PREDICT_TABLE('census_data.census_test', @census_model, 'census_data.census_test_predictions', NULL);

Step 5: Make Predictions

We can now predict next month’s sales for each branch-item pair:

SELECT

    branch_id,

    item_id,

    sale_month,

    predict_sales_quantity(branch_id, item_id, sale_month) AS forecasted_quantity

FROM census_test_predictions

WHERE sale_month = '2023-04-01';

branch_id item_id sale_month forecasted_quantity
B001 AC100 2023-04-01         128
B002 AC100 2023-04-01         112
This provides actionable insights for production and distribution planning.

Step 6: Business Integration

Predictions can be integrated into downstream systems:

  1. ERP/Production Planning: Adjust manufacturing schedules.

  2. Inventory Management: Stock warehouses based on forecasted demand.

  3. Branch Allocation: Distribute finished goods to branches accordingly.

  4. BI Dashboards: Visualize trends for management.

  5. Alerts & Triggers: Automatically notify supply chain teams if demand is projected to exceed capacity.

Example Scenario

Suppose a company sells air conditioners across 50 branches. In the past 12 months:

  • Average monthly demand per branch = 120 units.

  • Standard deviation = 15 units.

HeatWave regression forecasts next month’s demand for Branch B001 = 128 units.

The factory can then schedule production, ensuring raw material procurement and supply chain logistics are aligned.

The outcome: fewer stockouts in hot summer months, improved customer satisfaction, and optimized working capital.

Benefits of Using HeatWave for Demand Forecasting

  • End-to-End Simplicity: One SQL call replaces weeks of data science pipelines.

  • Real-Time Forecasts: Deploy models directly into transactional systems.

  • Scalability: Handle millions of rows across items and branches.

  • Accuracy: AutoML ensures best-fit regression model (e.g., XGBoost vs Linear Regression).

  • Cost-Efficiency: Eliminates need for external ML platforms.

Best Practices

  1. Granularity Choice: Forecast monthly at branch-item level for balance of accuracy and interpretability.

  2. Rolling Retraining: Retrain models quarterly to capture new demand shifts.

  3. Feature Enrichment: Add external drivers like promotions, holidays, or weather for better accuracy.

  4. Error Thresholds: Define acceptable MAPE levels for different product categories.

  5. Scenario Planning: Generate optimistic vs pessimistic forecasts to prepare contingency plans.


Conclusion

Demand forecasting is no longer a luxury — it’s a necessity for competitive advantage in manufacturing. By adopting MySQL HeatWave AutoML regression, companies can:

  • Predict monthly sales quantities per branch-item with high accuracy.

  • Embed forecasts directly into operational workflows.

  • Optimize production, reduce costs, and improve customer service.

HeatWave enables manufacturing leaders to move from reactive to proactive decision-making, ensuring that every branch is stocked with the right products at the right time.

In short: faster insights, better accuracy, and simpler operations 




Telco's Customer Churn Prediction using HeatWave AutoML

Introduction

In today’s hyper-competitive telecom landscape, customer churn—the likelihood of a subscriber leaving a service provider—has emerged as one of the biggest challenges. Acquiring new customers is expensive, while retaining existing ones directly boosts profitability. According to industry benchmarks, reducing churn by even 5% can increase profits by 25%–95%.

For telecom operators (telcos), predicting churn accurately and acting before customers leave is critical. Traditional approaches require a team of data scientists, complex machine learning pipelines, and weeks of effort. But with Oracle MySQL HeatWave AutoML, churn prediction can be simplified, automated, and scaled—all directly inside the database.

This blog explains how telcos can leverage HeatWave AutoML for churn prediction, from data ingestion to model deployment, and how it transforms customer retention strategies.


What is HeatWave AutoML?

HeatWave AutoML is a fully automated machine learning capability built into the MySQL HeatWave service. It allows users to:

  • Train ML models directly inside MySQL without moving data.

  • Automate the entire ML pipeline—feature selection, model training, hyperparameter tuning, and model evaluation.

  • Deploy models as SQL functions callable within queries.

This eliminates data movement, reduces latency, and allows DBAs, analysts, and application developers to create ML models .



Why Churn Prediction for Telcos?

Telco customers generate a wealth of data—usage patterns, billing history, payment behaviors, complaints, and demographics. However, converting this raw data into actionable insights requires machine learning.

Key benefits of churn prediction in telecom:

  1. Proactive retention – Identify customers at high risk of leaving before they switch providers.

  2. Personalized offers – Recommend tailored plans, discounts, or loyalty rewards.

  3. Optimized marketing spend – Target campaigns only at customers with high churn probability.

  4. Customer satisfaction – Resolve pain points leading to churn (network quality, billing disputes, etc.)


Here is the Demo which i built using the Streamlit and python.
 


Churn Prediction Workflow with HeatWave AutoML

Let’s walk through the end-to-end workflow of building a churn prediction solution for a telco using HeatWave AutoML.

1. Data Preparation

The churn dataset typically includes:

  • Customer Demographics – Age, gender, location, tenure.

  • Service Usage – Call minutes, SMS count, data usage, roaming activity.

  • Billing & Payments – Monthly charges, late payments, outstanding dues.

  • Support Interactions – Complaints raised, resolution status.

  • Churn Label – Binary variable (Yes/No).

Example table in MySQL:

CREATE TABLE telco_churn_data (

    customer_id VARCHAR(20) PRIMARY KEY,

    gender VARCHAR(10),

    tenure INT,

    monthly_charges DECIMAL(10,2),

    total_charges DECIMAL(10,2),

    contract_type VARCHAR(20),

    payment_method VARCHAR(50),

    internet_service VARCHAR(20),

    tech_support VARCHAR(10),

    churn VARCHAR(3) -- 'Yes' or 'No'

);


Data can be loaded using MySQL Shell Dump & Load or directly from Object Storage (OCI, AWS S3, Azure Blob, GCP) into HeatWave.

Once data is loaded into Heatwave then next step is data pre-processing which include data cleaning ,data scaling,normalization and making sure data is enrich .

you can use the jupyter notebook to visualize the data using seaborn, plotly etc.

basis your data understanding in the visualization you might need to add additional features to ensure model is covering the seasonality ,and hidden patterns likewise as an example Add recency-based features .

Basically your focus should be more towards:-

1.Data Completeness & Coverage

2.Data Quality & Cleaning

3.Feature Engineering Improvements

4. trying different Algorithms

Once you get new table with all the required features it's important to split into training set and testing set.

create table customer_churn.churn_data_train as select * from customer_churn.churn_data limit 0,8000;

create table customer_churn.churn_data_test as select * from customer_churn.churn_data limit 8001,10000;


2. AutoML Training

With the data in place, we use HeatWave AutoML to train a churn prediction model.

###Train the Classification Model
SET @model='classification_use_case_1';
CALL sys.ML_TRAIN('customer_churn.churn_data_train', 'Exited', JSON_OBJECT('task', 'classification'), @model);
This single command triggers:
  • Feature Engineering – Detects categorical/numerical features and encodes them.

  • Model Training – Trains multiple classification models (XGBoost, Random Forest, Logistic Regression, etc.).

  • Hyperparameter Tuning – Optimizes model performance.

  • Model Selection – Picks the best model based on accuracy and F1 score.

3. Model Evaluation


####Load the model
CALL sys.ML_MODEL_LOAD(@model, NULL);

####Score the model
CALL sys.ML_SCORE('customer_churn.churn_data_test', 'Exited', @model, 'accuracy', @classification_score, NULL);
SELECT @classification_score;


 4.Model Prediction

Once satisfied with the model score, call the model prediction it as a SQL function.

####Generate Predictions .

CALL sys.ML_PREDICT_TABLE('customer_churn.churn_data_test', @model, 'customer_churn.churn_data_test_predictions',NULL);

select * from customer_churn.churn_data_test_predictions limit\5\G;

above table will have the output of whether churn is there or not.

customer_id churn_probability
C10001 0.82
C10002 0.15
C10003 0.67

5. Integration into Telco Systems

Telcos can integrate the model predictions into:

  • CRM Systems – Flagging high-risk customers for agent follow-ups.

  • Marketing Platforms – Triggering personalized offers.

  • Dashboards – Visualization of churn trends by region, plan type, or tenure.

  • Real-Time Alerts – Immediate notification when churn probability spikes.


Business Impact for Telcos

By deploying churn prediction with HeatWave AutoML, telcos gain:

  1. Speed to Insight – Models trained in minutes vs. weeks of manual effort.

  2. Cost Efficiency – No need for external ML platforms or complex ETL pipelines.

  3. Actionable Intelligence – Real-time churn scores available inside MySQL queries.

  4. Operational Simplicity – DBAs and analysts can run AutoML without ML expertise.

  5. Scalability – Supports millions of subscribers with HeatWave’s distributed in-memory engine.

Example Scenario

Imagine a telco with 10 million subscribers. Historical data shows:

  • Monthly churn rate: 3% (≈300,000 customers).

  • Average revenue per user (ARPU): $25/month.

By identifying and retaining just 20% of churners (60,000 subscribers), the telco saves:

Best Practices

  • Balance the dataset: Ensure churn and non-churn customers are proportionally represented.

  • Regular retraining: Customer behavior evolves; retrain monthly or quarterly.

  • Feature enrichment: Add network usage, complaints, and sentiment data for better predictions.

  • Threshold tuning: Adjust churn probability cut-off (0.7, 0.8, etc.) based on business tolerance for false positives.

Conclusion

Customer churn is one of the biggest threats to telcos, but it is also a solvable problem. With MySQL HeatWave AutoML, telcos can predict churn accurately, act proactively, and retain revenue—all while simplifying operations and reducing costs.

The beauty of this approach lies in its accessibility: no data science team, no complex ML pipelines, just SQL and AutoML. For telcos, this means turning raw subscriber data into real-time retention strategies that directly impact profitability.

HeatWave AutoML doesn’t just predict churn—it transforms how telcos compete in the digital era.