DAY 22 – Customer Sales Order Delivery Time Prediction Using Neural Network

We have seen in our previous blog posts Customer Price Prediction on Machine Learning Scikit Learn Linear Regression and Random Forest models. These models can be used to implement data intelligence in any SAP ERP, SAP ECC, SAP S/4 HANA, Oracle, Microsoft, or any ERP systems with a few custom function calls and may add additional features.

Also, we have gone through also Customer Sales Order delivery time/days prediction using the Machine Learning Scikit Decision Tree model Scikit Linear Regression and Random Forest Linear Regression models.

This post will work on Customer Sales Order Delivery time/Days Prediction using the Tensorflow Keras Neural Network Regression model. We will check how it works (I couldn’t complete more codes due to time constraints (because of 100 days challenge); however, I will add more functions in the blog or cover them in Part II).

Let’s start and see how the Tensorflow Keras Neural Network Regression model predicts “Delivery days data,” You can also download from GitHub on my repository SODeliverDaysPredictionNeuralNetwork.

Note: The whole code executed in Google Colab.

Copy to Clipboard

delivery_days.csv(application/vnd.ms-excel) – 68664 bytes, last modified: n/a – 100% done

Saving delivery_days.csv to delivery_days.csv
Copy to Clipboard

Delivery Days Head Data

Copy to Clipboard
Copy to Clipboard
Copy to Clipboard
Copy to Clipboard
Copy to Clipboard

700

Copy to Clipboard

300

Copy to Clipboard
[[ 1014574489.0  2023227582.0  40322838435.0  1323.0  9.0  11907.0]
 [ 1024513305.0  2024972236.0  40326745519.0  27.0  58.0  1566.0]
 [ 1010497257.0  2015105168.0  40323841642.0  634.0  97.0  61498.0]
 ...
 [ 1026584187.0  2017931603.0  40322403388.0  340.0  63.0  21420.0]
 [ 1014944383.0  2013028697.0  40326705150.0  1339.0  42.0  56238.0]
 [ 1021173035.0  2026818698.0  40329897632.0  1085.0  72.0  78120.0]]
Copy to Clipboard
[[ 1011627632.0  2027544468.0  40327541308.0  1219.0  52.0  63388.0]
 [ 1025267774.0  2027593030.0  40326545666.0  933.0  1.0  933.0]
 [ 1025634677.0  2024513382.0  40330535224.0  1167.0  55.0  64185.0]
 ...
 [ 1018725301.0  2014307274.0  40330102393.0  819.0  95.0  77805.0]
 [ 1027343417.0  2024199933.0  40325775424.0  795.0  93.0  73935.0]
 [ 1024227697.0  2021989936.0  40323273226.0  1217.0  6.0  7302.0]]
Copy to Clipboard
[ 5828232.2  5786546.4  2709093.9  427.1  28.3  32403.2]
[ 1020214477.7  2019961009.5  40325920697.1  771.1  53.0  40802.0]
Copy to Clipboard
[[-1.0  0.6 -1.1  1.3 -1.6 -0.9]
 [ 0.7  0.9  0.3 -1.7  0.2 -1.2]
 [-1.7 -0.8 -0.8 -0.3  1.6  0.6]
 [ 1.5  1.5  0.4  0.2  1.0  0.9]
 [-1.4 -1.1  0.6  1.4 -1.3 -0.5]]
[[ 0.8  0.6  0.5  0.6  0.6]]
Copy to Clipboard
Epoch 1/1000
1/1 - 1s - loss: 0.5947 - mae: 0.5947
Epoch 2/1000
1/1 - 0s - loss: 0.5913 - mae: 0.5913
Epoch 3/1000
1/1 - 0s - loss: 0.5857 - mae: 0.5857
Epoch 4/1000
1/1 - 0s - loss: 0.5769 - mae: 0.5769
Epoch 5/1000
1/1 - 0s - loss: 0.5639 - mae: 0.5639
Epoch 6/1000
1/1 - 0s - loss: 0.5465 - mae: 0.5465
Epoch 7/1000
1/1 - 0s - loss: 0.5273 - mae: 0.5273
Epoch 8/1000
1/1 - 0s - loss: 0.5096 - mae: 0.5096
Epoch 9/1000
1/1 - 0s - loss: 0.4935 - mae: 0.4935
Epoch 10/1000
1/1 - 0s - loss: 0.4784 - mae: 0.4784
.......
Epoch 994/1000
1/1 - 0s - loss: 0.1269 - mae: 0.1269
Epoch 995/1000
1/1 - 0s - loss: 0.1269 - mae: 0.1269
Epoch 996/1000
1/1 - 0s - loss: 0.1269 - mae: 0.1269
Epoch 997/1000
1/1 - 0s - loss: 0.1281 - mae: 0.1281
Epoch 998/1000
1/1 - 0s - loss: 0.1298 - mae: 0.1298
Epoch 999/1000
1/1 - 0s - loss: 0.1309 - mae: 0.1309
Epoch 1000/1000
1/1 - 0s - loss: 0.1298 - mae: 0.1298
<tensorflow.python.keras.callbacks.History at 0x7f0dc245e610>
Copy to Clipboard
Training - Actual Delivery Days:
[[ 0.8  0.6  0.5  0.6  0.6  0.6  0.6  0.8  1.0  0.7]]
Training - Predicted Delivery Days :
[[ 0.6  0.6  0.4  0.6  0.6  0.6  0.7  0.8  0.7  0.5]]
Copy to Clipboard

Predicted vs Actual Delivery Days

Copy to Clipboard
[[ 0.2  0.0  0.1  0.0  0.0  0.0  0.1  0.0  0.3  0.2  0.0  0.4  0.1  0.3
   0.1  0.4  0.1  0.0  0.3  0.2  0.1  0.0  0.2  0.3  0.0  0.2  0.1  0.0
   0.1  0.1  0.2  0.3  0.1  0.0  0.5  0.0  0.1  0.3  0.1  0.3  0.4  0.2
   0.0  0.1  0.1  0.0  0.0  0.1  0.0  0.3]]

Conclusion:

The above data shows 0.1 to 0.4 MAE.

We need to check with more epochs, early stop etc., to see the prediction accuracy in future blogs.

This model looks good, however, Random forest is much better

We will compare all four models in next blog and see the outcome and decide which one is a better model with this data.

By |2021-05-11T03:46:52+00:00May 10th, 2021|Artificial Intelligence, Machine Learning|0 Comments

About the Author:

Leave A Comment