Application of ML to optimize inventory

Machine learning enables logistics and the supply chain to optimize capacity utilization, reduce risk and create new business models

article preview

Many believe that the concept of logistics involves the movement of goods from point A to point B. In fact, logistics — the process of planning and ensuring effective and continuous supply of goods, services and related information from wherever they are to the consumers and aimed at meeting customer demands. Logistics ensures that the right product is in the right place at the right time. Therefore, in modern companies, it is an important task of inventory management.

Inventory control may be regarded as balancing between the high cost of maintaining inventories and the loss of unmet demand. For effective inventory management in modern business, you need the demand forecasting model. This allows to determine optimum inventory levels and plan supply company based on customer needs. Small companies can calculate the data using spreadsheet-based tools MS Excel and its own logic, but the larger the company becomes, the larger the area of ​​consumers and a wider portfolio of products, the more difficult to effectively simulate the supply process.

Machine learning enables logistics and the supply chain to optimize capacity utilization, reduce risk and create new business models. Advantages of using the ML algorithms in the inventory management system and planning of orders: 

  1. Increasing the accuracy and speed of the prediction.
  2. Optimize inventory levels, which affect the cost reduction of oversupply.
  3. Risk management in the supply.
  4. Automatic order planning and preparation of orders to suppliers.
  5. Optimization of the product range.

Operating such a system means regular collection the necessary data on the company’s sales, and based on them using ML techniques demand is forecast. Upon receipt of the forecast analysis of the supply conditions, the current state of stocks, data supplier, planned loading logistics infrastructure and supply plan are formed. Based on the orders delivery plan and statistics of generated orders, you can build a plan for providers.

The technology of Machine learning (ML) allows us to find patterns between parameters that have an unexpressed bond and adapt algorithms to changing market conditions, thus — we have great potential in the prediction of the time series. Methods of ML can solve not only the classic problem of time series prediction but to find more complex patterns, for example, to predict the timing of a supply increase based on data about the weather in the region or to correct data on demand based on the volatility of raw material prices. Such indirect dependence is difficult to people, but the neural network is not based on people’s logic, it only evaluates statistical relationships of different parameters. Everything depends on the quantity and quality of data and the architecture of the system and the quality of its training. Advanced algorithms can take into account dozens of options and look for correlations where the human brain simply cannot find them. Consider the simple use of ML in the problem of predicting the correct number of products in stock.

First step: Importing data

Before you build a model for predicting, we need to import historical data. In addition, we must have all the necessary packages that we use for cleaning, transforming, and modeling data. Here it will be useful skills such as Python libraries like NumPy and Pandas. NumPy library contains a large number of fast and high-level operations with mono-, bi- and multi-dimensional arrays (tensors) and a number of vector functions and matrix algebra. The main purpose of Pandas — is loading, preprocessing and exploratory data analysis. Data preparation and processing typically have a tabular format and stored as a CSV-files (as well as TSV, XLS, XLSX etc.). In this case, it is necessary to use the method read_csv. In addition, data may be tightened directly from the database table, and for this purpose, a method has Pandas read_sql. In other cases, it may be useful read_json and other methods.

Second step: Explore data

Once everything is loaded, it is necessary to examine the data to understand the structure and values ​​contained in them. You can see what is in our data set, from which the number of rows and columns, what are the variables that describe our data, etc. Here you can add a job with Matplotlib Seaborn and data visualization. High-quality graphics and diagrams help to see more than the boring and monotonous table. Matplotlib library provides many low-level graphics tools so that the researcher can control virtually everything: from colors to fonts points on the coordinate axes. Seaborn Library contains more high-end features and is designed to some extent, «make life easier» users Matplotlib, automating many routine things.

Third step: Prepare data for modeling

It is possible to focus only on those columns that will be useful. To do this, it makes sense to allocate them in a separate dataset, to get rid of the processing of large amounts of unnecessary data and speed up your ML model. The easiest sales forecasting, as an element of optimization, rests in a warehouse, a dataset, which can be composed of two columns. The first column indicates the time point, the second — the number of sales at this point in time.

The data should be converted to the correct format if they are not so.

The next important step is to divide the available dataset for training and test samples. If the data is a time series, you can use the date for data splitting. We got the dataset that will be used to train the model and dataset that will be used to test its effectiveness. Another way to split the dataset is split it in proportion 3: 1 (or another one).

Fourth step: Fitting the model prediction to the data training

While working with ML we can and we do need to test different models and find the best one. In this case, we can try exponential smoothing for forecasting sales and shipment of goods from the warehouse, Seasonal Decomposition and possibly a one-dimensional Fourier analysis.

Fifth step: Comparison of the model on test data

Once the models are ready, you can begin to compare them. To do this, run developed models to test data, we separated. Here the model will make its forecast, which will need to be compared with the actual data.

To compare the results, you can create a graph on which to build forecasts by model close to the actual data. It is also important to use the indicators forecast accuracy and error indicators. Subtracting the resulting data is predicted from the actual data obtain an error for each time point. Here you can look at these errors:

  • The mean error (ME): an average of all errors
  • The mean absolute error (MAE): the mean absolute error values
  • The mean percentage error (MPE): the average percentage error
  • The mean absolute percentage error (MAPE): Average of absolute values ​​of the error rate
  • The mean square error (RMSE): Squaring each error, take the average value, and then take the square root of this, and you get the RMSE

RMSE is considered the gold standard performance metrics for its ability to take into account the negative value and take into account the size of the error. 

Sixth step: Using the best model to predict sales in the next year

Now, the best model to help predict sales based on the following periods from which you can plan a schedule load warehouse goods. In addition, the model can show the results of a holiday, weekend spikes and seasonal fluctuations.

It is effective to focus on process automation when use ML in inventory management. This process can occur with little or no human intervention. In inventory management manager is only a function of the control and monitoring of new situations. To do this, a number of important elements:

  1. Completeness and correctness of the data used for the calculation.
  2. Stability and security of the exchange of information inside the company.
  3. Stability and security of the data suppliers of goods.
  4. A model with high predictive accuracy.

The process of implementing such a system — not a trivial task, and may require serious resources of a business, as well as flexibility with respect to changes. Implementation time depends on the prediction models, the state of the IT infrastructure of the company, but the average takes from six months to a year and a half.

Thus, for optimizing operational logistics enterprises we can effectively use machine learning. ML tools in the processing of large data allow rethinking the way we do business. By combining customer data, economic indicators, and geolocation, logistics companies can forecast demand, the accuracy of which each time will grow at the expense of additional training algorithms based on the information received. This will allow the optimal distribution of loads on vehicles and efficiently plan routes of deliveries of goods. Through the use of neural network technology and the ML, the analysis adapts and learns from past periods.