Product Demand Estimation and Stock Optimization
Predict demand for products and optimize stock availability.
The use case described in this experiment is an estimation of demand for products sold in store, in order to optimize their stock availability in prediction of future sales.
Estimation is based on customer-oriented features, such as age or gender, and environmental features like weather condition or location, and specific products previously acquired by customers.
The **dataset is labelled**, which allows for **supervised learning** algorithms, and the label column being trained contains numerical values.
The following estimation - regression - algorithms are tested:
* **Linear Regression**: This algorithm attempts to establish a linear relationship between one or more independent variables and the numeric outcome.
* **Boosted Decision Tree Regression**: Boosting is a machine learning technique for regression problems that builds each regression tree in a step-wise fashion, using a predefined loss function to measure the error in each step and then select the optimal tree
#Dataset
Data is sourced from a Dynamics 365 for Sales application (a sample copy is provided in this experiment), and contains the following columns:
- Age Range
- Gender
- Skin Type
- Weather
- Temperature
- Product
- Applied
- Bought
![Dataset sample][1]
#Training
This experiment selects a sub-set of features for training:
- Gender
- Skin Type
- Weather
- Product
- Bought: Indicated how many products have been bought, for the indicated features.
The **Bought** column is used for training the model, that is for identify patterns of bought products in the provided historical data.
Feel free to modify the selected columns for trying alternative prediction models based on different features.
![Training experiment][2]
#Scoring
Two models are trained and scored, using **Linear Regression** and **Boosted Decision Tree Regression**. For regression models, the **Score Model** action generates the predicted numeric value, which is identified in the scored dataset as "Scored Labels".
![Scored dataset][3]
#Evaluation
To generate a set of metrics used for evaluating the model's accuracy (performance), the two scored datasets are connected to an **Evaluate Model** action. The metrics returned for regression models are designed to estimate the amount of error in the scored value.
For more information on the generated metrics and how to interpret them, please refer to [Evaluate Model][4]
#Web Service
Once you run the **Predictive Experiment** and deploy it as a **Web Service**, it is possible to interact with the prediction service programmatically.
![Predictive experiment][5]
Based on the selected columns in the Training experiment, testing the service asks for the following values in input:
- Gender
- Skin Type
- Weather
- Product
![Test the service][6]
And it generates an estimated number of products that will be bought by customer matching the indicated conditions.
To consume the Web Service programmatically, this is the expected format of the **request message**:
{
"Inputs": {
"inputData": {
"ColumnNames": [
"Gender",
"Skin Type",
"Weather",
"Product"
],
"Values": [
[
"value",
"value",
"value",
"value"
],
[
"value",
"value",
"value",
"value"
]
]
}
},
"GlobalParameters": {}
}
And this is the format of the **response message**, containing the **Scored Labels** value.
{
"Results": {
"outputData": {
"type": "DataTable",
"value": {
"ColumnNames": [
"Gender",
"Skin Type",
"Weather",
"Product",
"Scored Labels"
],
"ColumnTypes": [
"String",
"String",
"String",
"String",
"Numeric"
],
"Values": [
[
"value",
"value",
"value",
"value",
"0"
],
[
"value",
"value",
"value",
"value",
"0"
]
]
}
}
}
}
The predicted value, that is the estimated number of products that will be sold under the identified conditions, can be used to update stock availability of the given product in store.
[1]: https://knosmq-db3pap001.files.1drv.com/y4mtIH3gnuJPDqF6qba992oXNxsd-sB7dI0hyR9EnV8bGLs5EatywMjYp_L_uxA_82L48k5YcQyU0WktN9XbAHlZ0KNGmL7ugVvUeVXxmrT-b5BFMILiWWX6w9m20RKZG9Zk3zliAw0goN7Ib__w4394vvKHxM8xtJlbclSuO6jnnxw2yc76kWQt9OAkNOlfiwoX2pijGPfoq6LHQmXTVvuLw?width=929&height=497&cropmode=none
[2]: https://mcfxxg-db3pap001.files.1drv.com/y4mA5FWGPF8yn_W1jra9fffuS-eM1XapqvVIvtexFYiHsJNIeKDSYmZCpx2MnAcdwjiQL9eUEEYnkLq79Ha65E3jhy7q4tNiJR7PPbbKLJ79EmSvZuiZR3P-qEN0l544hJ69VpBS9z4E8Hb1mZc-fexjnvDbgLmleJFJAaHW3Ti8nN_zh47fSEhkVGS8SBwqRmgyKpG3c6IkCM7XN16ADTMBw?width=1135&height=667&cropmode=none
[3]: https://y9gigq-db3pap001.files.1drv.com/y4mUJdBNAE5FEysbUp__yGBGkiuXh4HGCuw5y0YRNYwyJbLAxRf5n06VIVW3BpGMDszV5fzQvKe_HNNNzsM5b00VhyEBYWo1k3feiMY2WK7Rvhm8xscTiNkF59ReW2Zp9BDW-qPWIQiHf6W4lsn5s7KDih6rJPB2M7_sU5efMVpjrtBAC4nZe5X1f7j4fbOutuaJntoJcJVZeHHeSnf5gI80Q?width=750&height=318&cropmode=none
[4]: https://docs.microsoft.com/en-us/azure/machine-learning/studio-module-reference/evaluate-model
[5]: https://9wvr9g-db3pap001.files.1drv.com/y4mgc55rNQKmYgD3hYFCh5dhOHxiBwepgO9mO5lt2SMJIPn6pVxNAB-OD44XH8eb_K83XNOlOCRl-r-uh0COa_BRsB4kjcK-wH29NI3KJXO4vBot89L2tG_HFGaktMCIyksxAotB-19Pvjd5BPQTusytqzNerRo7O4pvAUeOeeAIbVE_CCvvpeyqUH6YdXtM9apMTnVQWyhQE6VFVWh7mtQIg?width=792&height=662&cropmode=none
[6]: https://ndbqaa.db.files.1drv.com/y4mcAoIF9GwdJBS841B_peD3VE4LAOnoES3rj_EyV_aJ0UUUSy1CNKRDbdiwzSpDkb8cc8OPdfdKs4hxirYUd5SyXbkZN6lWHzb5gccvOiteF7DQYRmHVbriwo7EB-CCCI2bdhdClxyg1yWbG3t0cvQpGnC0UVjVVq7-2StKCuXAziKON5TGmz9L-zFfOrbUWoOa59iwzgH1tTG_it3nABq8w?width=456&height=480&cropmode=none