"This tutorial will guide your through predicting orders in ERP5 using an ARIMA model. The orders will be exported by ERP5 in CSV format (comma-sepparated values), and accessed and processed locally in a Jupyter Notebook.\n",
"This tutorial will guide your through predicting orders in ERP5 using an ARIMA model. The orders will be exported by ERP5 in CSV format (comma-sepparated values), and accessed and processed **locally** in a **Jupyter Notebook**.\n",
"\n",
"\n",
"Please note that **Pandas** and **NumPy** can also be used inside ERP5 Wendelin software release, but Jupyter notebook adds more convenience. Soon ERP5 integration with Jupyter will be released and merged into Wendelin software release, which will make everything much easier."
"Please note that **Pandas** and **NumPy** can also be used inside ERP5 Wendelin software release, but Jupyter notebook adds more convenience. Soon ERP5 integration with Jupyter will be released and merged into Wendelin software release, which will make everything much easier."
]
]
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
"\n",
"\n",
"The first step in our experimentation is to create a sample data which will be used to generate the batch of data on which the statistic method will be applied. \n",
"The first step in our experimentation is to create a sample data which will be used to generate the batch of data on which the statistic method will be applied. \n",
"\n",
"\n",
"Imagine that our company is called 'Demo Clothes' and we are a supply swimsuits for a company named 'Test Company'.So first go to Product Module and create one product named 'Swimsuit'. Then go to the Organisation Module and create two different organisations: 'Test Company' and 'Demo Clothes'. Now go to Sales Order Module and fill an order as it is shown in the example below. Keep the order very simple and use the product and organisations you just created. Remember to add the 'Trade Condition' as shown in the picture below. \n",
"Imagine that our company is called 'Demo Clothes' and we are a supplier of swimsuits for a company named 'Test Company'. So first go to Product Module and create one product named 'Swimsuit'. Then go to the Organisation Module and create two different organisations: 'Test Company' and 'Demo Clothes'. Now go to Sales Order Module and fill an order as it is shown in the example below. Keep the order very simple and use the product and organisations you just created. Remember to add 'General Trade Condition' as 'Trade Condition', like it's shown in the picture below. \n",
"When the instalation is finished you should be able to start Jupyter notebook server by running `jupyter notebook`. \n",
"When the instalation is finished you should be able to start Jupyter notebook server by running `jupyter notebook`. \n",
...
@@ -142,7 +142,7 @@
...
@@ -142,7 +142,7 @@
"source": [
"source": [
"# Basic Jupyter imports and setup\n",
"# Basic Jupyter imports and setup\n",
"\n",
"\n",
"To start working with Jupyter you need a few imports and some setup first. So you activate `matploblib` inline plotting to allow Jupyter to render beautiful charts inside Jupyter. Then you import some basic modules: csv, requests (to make a request to ERP5 and get the csv data), matplotplib (to customize the backend), pandas, the plot object from matplotlib, scikit learn (for linear models), statsmodels' api and StringIO. See the code below."
"To start working with Jupyter you need a few imports and some setup first. So you activate `matploblib` inline plotting to allow Jupyter to render beautiful charts. Then you import some basic modules: csv, requests (to make a request to ERP5 and get the csv data), matplotplib (to customize the backend), pandas, the plot object from matplotlib, scikit learn (for linear models), statsmodels' api and StringIO. See the code below."
]
]
},
},
{
{
...
@@ -289,6 +289,21 @@
...
@@ -289,6 +289,21 @@
"cell_type": "markdown",
"cell_type": "markdown",
"metadata": {},
"metadata": {},
"source": [
"source": [
"All scikit-learn's `fit` methods require a 2D array of size `[n_samples x n_features]`. So we transform our `Pandas.DateTimeIndex` into an array of time deltas describing how many days have passed since the first observation and call the days method to get just the numbers of days instead of a TimeDelta object. Something like this:\n",
"\n",
"```python\n",
"[1 ,2 ,3 , 4, ..., n_samples]\n",
"```\n",
"\n",
"Then, we reshape it using `(-1, 1)` shape, where -1 will tell numpy to infer the array size and use it there. This reshape is used because we have only 1 feature (the number of the day of the order). The result will be an array like below:\n",
"\n",
"```python\n",
"[[1], [2], [3], ..., [n_samples]]\n",
"```\n",
"\n",
"If we had more features, each element of the outter array \n",
"would have more than one element. \n",
"\n",
"But, not everything are flowers. As you can see this prediction is really, really bad. Consering that you will have almost the same sales in the next year, you won't be able to fulfil the same demands you did before and you will keep a very high stock during the lower demand period. \n",
"But, not everything are flowers. As you can see this prediction is really, really bad. Consering that you will have almost the same sales in the next year, you won't be able to fulfil the same demands you did before and you will keep a very high stock during the lower demand period. \n",
"\n",
"\n",
"To solve this you can use another model, like an ARIMA model. It will require some statistics knowledge, but it will be worth it. "
"To solve this you can use another model, like an ARIMA model. It will require some statistics knowledge, but it will be worth it. "
...
@@ -354,7 +369,7 @@
...
@@ -354,7 +369,7 @@
"source": [
"source": [
"# Statistical analysis (auto correlation and partial auto correlation)\n",
"# Statistical analysis (auto correlation and partial auto correlation)\n",
"\n",
"\n",
"Now you need to idenfity which ARIMA model order fits better your data. So you will need to plot both the auto correlation and partial correlation graphs and analyse them. 'statsmodels' provide an easy to use method to plot both these graphs, check the snippet below."
"Now you need to idenfity which ARIMA model order fits better your data. So you will need to plot both the auto correlation and partial auto correlation graphs and analyse them. 'statsmodels' provide an easy to use method to plot both these graphs, check the snippet below."