supplychainpy.demand package¶
Submodules¶
supplychainpy.demand.regression module¶
-
class
supplychainpy.demand.regression.
LinearRegression
(orders: list)¶ Bases:
object
Linear Regression Statistics
-
least_squared_error
(slice_end: int = 0, slice_start: int = 0)¶ Calculate simple linear regression values and two_tail pvalue to determine linearity.
Parameters: - slice_end – Start value for slicing the orders list. Default value is zero.
- slice_start – End value for slicing the orders list. Default value is Zero. The length of the orders list as supplied to the constructor is then used as the length of the orders.
Returns: Regression results.
Return type: dict
Examples: >>> from supplychainpy.demand._forecast_demand import Forecast >>> orders = [165, 171, 147, 143, 164, 160, 152, 150, 159, 169, 173, 203, 169, 166, 162, 147, … 188, 161, 162, 169, 185, 188, 200, 229, 189, 218, 185, 199, 210, 193, 211, 208, 216, 218, … 264, 304] >>> total_orders = 0 >>> for order in orders[:12]: >>> total_orders += order >>> avg_orders = total_orders / 12 >>> forecasting_demand = Forecast(orders, avg_orders) >>> forecast = [i for i in forecasting_demand.simple_exponential_smoothing(0.5)] >>> regression = LinearRegression(forecast) >>> regression_statistics = regression.least_squared_error()
-