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.










Sunday, September 1, 2024

Check MySQL InnoDB Settings using MySQL Shell Utility


 Check and review recommended MySQL InnoDB setting using MySQL Shell for optimal Performance. 


Performance of MySQL is always top priority for each organisations because data holds valuable insight into organizational productivity and proactive decision making. 
High-performing databases help organizations stay ahead by enabling faster insights, quicker adaptation to changes, and superior customer experiences. 
When performance of MySQL is slow it impacts user experience and data driven innovation. 
Performance has different meaning at different context however it’s important to keep MySQL instance healthy by balancing the hardware vis-à-vis InnoDB settings. 
I have been asked multiple times by MySQL customer about 
  1. Does MySQL has right set of InnoDB configurations ? 
  2. What are the InnoDB parameters to tune ? 

Great news!!! , MySQL Shell starting with 8.4.x version will check MySQL InnoDB configurations and suggest the possible recommendations. 

I suggest you to follow below steps to review the current settings. 


 Step 1:- Download MySQL shell 8.4.x version from below links. 


             https://dev.mysql.com/downloads/shell/ 


 Step 2:- Install downloaded MySQL shell 


             rpm -Uhv mysql-shell-8.4.1-1.el7.x86_64.rpm 


 Step 3:- Connect the MySQL Instance which you wanted to review the recommendations 

                mysqlsh -hxxxxx -uxxxx -pxxxx -P3306 


    Step 4:- check for upgrade compatibility issues and InnoDB settings 


             JS > util.checkForServerUpgrade() 


 Step 5:- Review the output 

Conclusion :- 

These above settings require benchmark against your workloads , you might have to try each parameters one by one to check how MySQL server is performing in testing environment and then eventually move into production. 



Saturday, June 22, 2024

Building Modern Data Platform using Heatwave as Query Processing Engine


 Building Modern Data Platform using Heatwave as Query Processing Engine. 

In this tutorial we will explore about Heatwave as query processing engine as part of “modern data platform”. 

MySQL HeatWave is the only service that enables developers, database administrators, and data analysts to run OLTP, OLAP, and machine learning (ML) workloads directly from MySQL Database or else object storage/S3 as part of multi-cloud hybrid model 



 Current Challenges with traditional Data Warehouse Solutions 

In the contemporary landscape of data-driven decision-making, organizations face numerous challenges in effectively managing, analysing, and deriving insights from the vast volumes of data available to them. 


Traditional data management approaches often prove inadequate in addressing the evolving needs of businesses, including the 

need for real-time insights, scalability, and interoperability across diverse data sources and formats. 

“Noisy neighbours” multiple databases for different kind of workloads which includes RDBMS for OLTP , specialize analytics for OLAP, ML tools for machine learning etc,additional cost ,complexities , ETL jobs etc. 

Furthermore, siloed data environments hinder collaboration and inhibit the ability to derive holistic insights from disparate datasets. 


In light of these challenges, there is a growing imperative for organizations to adopt a modern data platform that can seamlessly integrate, process, and analyze data from various sources while ensuring security, governance, and compliance. 

Such a platform should enable organizations to harness the full potential of their data assets to drive innovation, improve operational efficiency, and gain a competitive edge in the marketplace. 


 Key considerations in designing and implementing a modern data platform 

Key considerations in designing and implementing a modern data platform include - 

  • scalability to handle growing data volumes, 
  • flexibility to accommodate diverse data types and sources, 
  • interoperability to support integration with existing systems and technologies, 
  • real-time processing capabilities for timely insights, 
  • Competitive price/performance 
  • No application level changes 
  • robust security measures to protect sensitive data, and comprehensive governance frameworks to ensure regulatory compliance and data quality. 

Addressing these challenges and requirements with Heatwave Service 

Addressing these challenges and requirements demands a strategic approach to building a modern data platform that aligns with the organization's goals, fosters a data-driven culture, and empowers users across the enterprise to derive actionable insights from data. 

I recommend Heatwave as query processing engine ,which is in-memory hybrid columnar data store with multi-node ,more core parallel processing model processes the partitioned data in parallel with machine learning based workload optimization using Oracle AUTO ML . 

Today, Heatwave can immediately replace five different services of AWS with single service of Heatwave to drive workload which require solutions for transactional processing ,analytical processing, machine learning,lakehouse,GenAI. 

In AWS, organization depends on RDS/Aurora for OLTP , Redshift for analytics ,Sage maker for ML etc and multiple services of AWS increases cost ,complexity and noisy neighbours. 


Key technical feature makes Heatwave way Faster 

There are multiple technical features which accelerate heatwave query performance, some of those are. 


1. In-Memory Hybrid Columnar Format 

HeatWave stores data in main memory in a hybrid columnar format. Hybrid columnar format enables the use of efficient query processing algorithms designed to operate on fixed-width data, and permits vectorized query processing. 


2. Push based vectorized data processing model 


HeatWave processes queries by pushing vector blocks (slices of columnar data) through the query execution plan from one operator to another. A push-based execution model avoids deep call stacks and saves valuable resources compared to tuple-based processing models. 


3. Massive Parallel Architecture 


The HeatWave massively parallel architecture uses internode and intranode partitioning of data. Each node within a HeatWave Cluster, and each CPU core within a node, processes the partitioned data in parallel. 

This massively parallel architecture, combined with high-fanout, workload-aware partitioning, accelerates query processing. 

4. ML-based Workload Optimization 


MySQL Autopilot provides workload-aware, machine learning–powered automation. It improves performance and scalability without requiring database 

tuning expertise, increases the productivity of developers and DBAs, and helps eliminate human errors. MySQL Autopilot automates many of the most important and often challenging aspects of achieving high query performance at scale—including provisioning, data loading, query execution, and failure handling. 

5. Scale out data management 


When analytics data is loaded into HeatWave, the HeatWave Storage Layer automatically persists the data for pause and resume of the HeatWave Cluster and for fast recovery in case of a HeatWave node or cluster failure. Data is automatically restored by the HeatWave Storage Layer when the HeatWave Cluster resumes after a pause or recovers a failed node or cluster. This automated, self-managing storage layer scales to the size required for your HeatWave Cluster and operates independently in the background. 

MySQL HeatWave Service persists the data to OCI Object Storage. 

MySQL HeatWave on AWS persists the data to AWS S3. 


Architecture for Modern Data Platform with Heatwave Service 

Below architecture depicts one of “modern data platform “on AWS 

  1. Input Source:- where multiple data sources streamlined the raw data into S3 as primary storage and then data is extracted to curated layer for further data processing. Tools you may use for data streaming -Solace , Kafka ,Golden Gate , OCI data Integration service. 
  2. Query Processing Layer: Heatwave accept data automatically from S3 by calling the auto-pilot stored procedure first time and then automatically data streamlined into heatwave by the system. 
  3. Data Visualization Layer:- Processed data can be used for further insights and apply business analysis to be used by external application or else we can understand the data by using various data visualization technique – OAC,looker,tableau etc. 


Below architecture is an example which caters to multi-zone ,active-active/passive heatwave cluster with DR site utilizing multiple availability zone/regions of AWS. 

















Below architecture is an example which caters to multi-zone ,active-active/passive heatwave cluster with DR site utilizing multiple availability zone/regions of OCI.















What kind of use case Heatwave is suitable for ? 

Use HeatWave service to eliminate the complexity, latency, costs, 

and risks of using separate cloud services for transactions, 

analytics, GenAI and ML. This use case will be most effective in 

accounts with MySQL on-premises, including Azure and AWS 

customers who have MySQL estates on-premises. 

Common use cases: 

  1. Digital Payment and Retail PoS applications 
  2. Fraud detection 
  3. Digital Marketing 
  4. Logistics applications and E-commerce app 
  5. ‘content management 

Some of additional areas you may focus on to :- 

  1. Build cloud native applications 
  2. Move existing OLTP/OLAP workloads 
  3. Run mixed kind of workloads where real-time analytics require 
  4. Power SaaS applications 
  5. Anomaly detection ,classification, time-series ML applications 

Heatwave Case Studies : https://www.mysql.com/products/mysqlheatwave/case-studies/

 

Conclusion 

By investing in a modern data platform, organizations can unlock the full potential of their data assets and drive sustainable growth and innovation in today's data-driven world 

MySQL HeatWave is the only cloud service that combines transactions, realtime analytics across data warehouses and data lakes, and machine learning in one MySQL database—without the complexity, latency, risks, and cost of ETL duplication. It delivers unmatched performance and price-performance. HeatWave AutoML enables native, in-database machine learning, allowing users to build, train, deploy, and explain machine learning models inside MySQL, without machine learning expertise. 

MySQL HeatWave can be deployed in OCI, AWS, Azure, in a hybrid environment, and in customers’ data centers with OCI Dedicated Region