Anzeige

prediction of_inventory_management

FEG
Data Scientist um FEG
3. Jun 2021
Anzeige

Más contenido relacionado

Anzeige
Anzeige

prediction of_inventory_management

  1. 國立臺北護理健康大學 NTUHS Prediction of inventory management Orozco Hsu 2021-05-27 1
  2. About me • Education • NCU (MIS)、NCCU (CS) • Work Experience • Telecom big data Innovation • AI projects • Retail marketing technology • User Group • TW Spark User Group • TW Hadoop User Group • Taiwan Data Engineer Association Director • Research • Big Data/ ML/ AIOT/ AI Columnist 2 「How can you not get romantic about baseball ? 」
  3. Tutorial Content 3 Stationary of Time-Series Forecasting with Seasonal or Periodic data Homework An accurate inventory prediction
  4. Code • Download code • https://github.com/orozcohsu/ntunhs_2020/tree/master/alg_20210527 4
  5. An accurate inventory prediction 5
  6. An accurate inventory prediction 6 The blocks of Inventory Management System
  7. An accurate inventory prediction • Inventory forecasting, also known as demand planning, is the practice of using past data, trends and known upcoming events to predict needed inventory levels for a future period. • An accurate forecasting ensures businesses have enough product to fulfill customer orders and do not spend too little or too much on inventory. 7
  8. An accurate inventory prediction • Data elements required for a success inventory forecasting include • Current Inventory Levels • OUTSTANDING purchase orders • HISTORICAL TRENDLINES • Forecasting period requirements • Expected demand and SEASONALITY • MAXIMUM possible stock levels • Sales trends and velocity 8
  9. Accurate inventory prediction 9 01 Future forecast period 02 Base demand 03 Variables and trends 04 Build model 05 Model tuning
  10. Accurate inventory prediction • Demand Factors (Base, trends, seasonality, qualitative…) • An example of other demand factors that can impact or inflate your normal base demand. 10
  11. Accurate inventory prediction • Demand types • Demand of Product X, Y, Z varies considerably. • Some will have consistently high demand over time, for others there could be sporadic or low demand. 11 Quiz: What is the importance of demand forecasting? Hint: Watch the video from https://youtu.be/DKJfForHw-w What is demand forecasting?
  12. Stationary of Time-Series 12
  13. Stationary of Time-Series • Introduction to Stationarity • Stationarity is one of the most important concepts you will come across when working with time series data. A stationary series is one in which the properties – mean, variance and covariance, do not vary with time. (a) The mean varies (increases) with time which results in an upward trend (b) We do not see a trend in the series. A stationary series must have a constant variance (c) The spread becomes closer as the time increases, which implies that the covariance is a function of time. 13 (a) (b) (c)
  14. Stationary of Time-Series • Stationary • The mean, variance and covariance are constant with time. • Most statistical models require the series to be stationary to make effective and precise predictions. • A stationary time series is the one for which the properties (namely mean, variance and covariance) do not depend on time. 14
  15. Stationary of Time-Series • How to check the series is stationary? • Use the ADF (Augmented Dickey Fuller) Test • It helps us understand if the series is stationary or not • Null hypothesis: The series has a unit root • Alternate hypothesis: The series has no unit root. check_stationary.ipynb 15 Null and Alternative Hypotheses https://opentextbc.ca/introstatopenstax/chapter/null-and-alternative-hypotheses/
  16. Stationary of Time-Series • How to make our series to stationary: Differencing • Compute the difference of consecutive terms in the series. • Differencing is typically performed to get rid of the varying mean. • How to make our series to stationary: Seasonal Differencing • Calculate the difference between an observation and a previous observation from the same season. 16
  17. Stationary of Time-Series • Time series data are expected to contain some white noise component on top of the signal generated by the underlying process. • When forecast ERRORS (y hat and y) are white noise, it means that all of the signal information in the time series has been harnessed by the model in order to make predictions. y(t) = signal(t) + noise(t) 17 White noise: A time series is white noise if the variables are random and identically distributed with a mean of zero, autocorrelation is closer to 0.
  18. Stationary of Time-Series • How to make our series to stationary: Transformation • Used to stabilize the non-constant variance of a series. • Common transformation methods include power transform, square root, and log transform. • Check Durbin_Watson, ACF, Ljung box test of series after we process our series. making_a_time_series_stationary.ipynb 18
  19. Stationary of Time-Series 19 Start Random Stationary Non- Stationary White noise (no pattern) terminated Stationary (original series is stationary) Differencing stationary ARIMA model (Autoregressive Integrated Moving Average model) ARMA model (Autoregressive moving average model) Yes No No Differencing Yes
  20. Forecasting with Seasonal or Periodic data 20
  21. Forecasting with Seasonal or Periodic data • Some useful tools • Moving average forecasting (MA) • Simple Exponential Smoothing forecasting(SES; holtwinters) • Stepwise Autoregressive forecasting • Autoregressive Integrated Moving Average model forecasting (ARIMA) • A seasonal autoregressive integrated moving average (SARIMA) • Autoregressive conditional heteroskedasticity forecasting (ARCH) • Hidden Markov Model forecasting (HMM) 21
  22. Forecasting with Seasonal or Periodic data • A time series analysis focuses on a series of data points ordered in time. • If you’re a retailer, a time series analysis can help you forecast daily sales volumes to guide decisions around inventory and better timing for marketing efforts. • If you’re in the financial industry, a time series analysis can allow you to forecast stock prices for more effective investment decisions. • If you’re an agricultural company, a time series analysis can be used for weather forecasting to guide planning decisions around planting and harvesting. 22
  23. Forecasting with Seasonal or Periodic data • Check any time series data for patterns that can affect the results, and can inform which forecasting model to use. 23 Type Description Irregular Fluctuation No pattern Trend Increases, decreases, or stays the same over time Seasonal or Periodic Pattern repeats periodically over time Cyclical Pattern that increases and decreases but usually related to non- seasonal activity, like business cycles Level The average of value
  24. Forecasting with Seasonal or Periodic data 24
  25. Forecasting with Seasonal or Periodic data • Use my code and present those models 25 time_series_forecasting.ipynb
  26. Forecasting with Seasonal or Periodic data • Parameters: Additive model • Usually represents a linear time series with fixed fluctuations and a fixed period pattern. • y(t) = Level + Trend + Seasonality + Cyclical/Noise/Random • Parameters: Multiplicative model • The fluctuations and cycles of the time series will change with time. It is a non-linear time series, and most of the time series data of stocks fall into this category. • y(t) = Level * Trend * Seasonality * Cyclical/Noise/Random 26 We will use it for seasonal_decompose, check my code
  27. Forecasting with Seasonal or Periodic data • Simple Exponential Smoothing (SES) • Suitable for time series data without trend or seasonal components. • This model is using weighted averages of past observations to forecast new values. • Parameters: • Determine the smoothing level α: Between 0 and 1 (Level equation) • When α = 0, the forecasts are equal to the average of the historical data. • When α = 1, the forecasts will be equal to the value of the last observation. • Write the model RMSE in P33 table 27
  28. Forecasting with Seasonal or Periodic data • Holts Linear Trend Method • Suitable for time series data with a trend component but without a seasonal component. • Expanding the SES method, the Holt method helps you forecast time series data that HAS a trend. • Parameters: • Level smoothing parameter α: Between 0 and 1 (Level equation) • Trend smoothing parameter β*: Between 0 and 1 (Trend equation) • Write the model RMSE in P33 table 28
  29. Forecasting with Seasonal or Periodic data • Holt-Winters Seasonal Method • Suitable for time series data with trend and/or seasonal components. • Parameters: • Seasonality smoothing parameter: γ • Two general types of seasonality: Additive and Multiplicative (Check Page 26) • Identify the frequency of seasonality m: m=4 (Quarterly seasonal pattern) m=12 (Yearly seasonal pattern) • Box-Cox transformations for data normalization 29 https://www.statisticshowto.com/box-cox-transformation https://www.statsmodels.org/dev/generated/statsmodels.tsa.holtwinter s.ExponentialSmoothing.fit.html Homework2: Set use_boxcox to False, log, float to compare the result.
  30. Forecasting with Seasonal or Periodic data • SARIMA (Seasonal autoregressive integrated moving average) • Suitable for time series data with trend and/or seasonal components • ARIMA model looks at autocorrelations or serial correlations in the data, and it looks at differences between values in the time series. • SARIMA builds upon the concept of ARIMA but extends it to model the seasonal elements in your data. • Parameters (we need to find those SEVEN parameters): • Trend elements: • p: Trend autoregression order • d: Trend difference order • q: Trend moving average order 30 • Seasonal elements: • P: Seasonal autoregression order • D: Seasonal difference order • Q: Seasonal moving average order • m: The number of time steps for a single seasonal period
  31. Forecasting with Seasonal or Periodic data • Grid search • A python package. • It is a tuning technique that attempts to compute the optimum values of hyperparameters. • Find out the best value of (p, d, q, P, D, Q, m) • Evaluation metric • AIC (Akaike Information Criterion) • The AIC measures how well a model fits the data while taking into account the overall complexity of the model. • Pick the combination with the LOWEST AIC value. 31
  32. Forecasting with Seasonal or Periodic data 32 Check model’s residuals are near normally distributed. This indicates we have found a WELL-FIT model suitable for our dataset. Symmetry KDE line follow closely with N(0,1) N(0,1) => mean =0, variance =1 If residuals are normally distributed, the points will fall on the 45-degree https://desktop.arcgis.com/en/arcmap/10.3/guide- books/extensions/geostatistical-analyst/normal-qq-plot-and- general-qq-plot.htm Residuals have a low autocorrelation with the lagged versions of itself, the majority of dots fall into the blue shaded area
  33. Forecasting with Seasonal or Periodic data 33 Algorithm RMSE Simple Exponential Smoothing 108.63 Holts Linear Trend Method 305.25 Holt-Winters Seasonal Method (multiplicative) 25.78 SARIMA (dynamic=False) 17.9 Homework3: Try to use Holt-Winters Seasonal Method to predict future sales value
  34. Forecasting with Seasonal or Periodic data 34 Prediction: 1961-01-01 -> 1965-04-01
  35. Homework 35
  36. Homework • Continue to use square root or power transformation on Making_a_Time_Series_Stationary.ipynb series and compare with better results. • Set use_boxcox to False, log, float to compare the result. • Try to use Holt-Winters Seasonal Method to predict future sales value 36
Anzeige