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:
-
Production Planning: Aligns factory output with expected demand.
-
Inventory Optimization: Reduces carrying costs by avoiding overproduction.
-
Branch-level Allocation: Ensures each regional warehouse or retail branch is stocked appropriately.
-
Cost Efficiency: Prevents both stockouts (lost sales) and overstocks (wasted capital).
-
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
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)
);
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 |
Step 6: Business Integration
Predictions can be integrated into downstream systems:
-
ERP/Production Planning: Adjust manufacturing schedules.
-
Inventory Management: Stock warehouses based on forecasted demand.
-
Branch Allocation: Distribute finished goods to branches accordingly.
-
BI Dashboards: Visualize trends for management.
-
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
-
Granularity Choice: Forecast monthly at branch-item level for balance of accuracy and interpretability.
-
Rolling Retraining: Retrain models quarterly to capture new demand shifts.
-
Feature Enrichment: Add external drivers like promotions, holidays, or weather for better accuracy.
-
Error Thresholds: Define acceptable MAPE levels for different product categories.
-
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
No comments:
Post a Comment