Code Documentation

class inventory.InventoryOptim(df, units_costs, date_fld='date', start_date=None, num_intrvl=(0.0, 10.0), projection_date=None, c_limit=0.95, min_samples=5, error_tol=0.0001)[source]
Parameters:
  • df – the DataFrame containing data point
  • units_costs – a list of pairs \((G_i, C_i)\).
  • date_fldstring the name of the column keeping each row’s date
  • start_dateNone or datetime`the start date of the analysis; if `None the minimum date found in date_fld is used.
  • num_intrvl2-tuple the numerical range to be used for converting dates to numbers
  • projectioni_datedatetime the target date of the analysis
  • c_limit – float between 0 and 1, the confidence interval
  • min_samplesint minimum number of samples to perform Monte Carlo sampling
  • error_tolfloat error tolerance
adjust_system(tbo='u')[source]

Forms and solves the optimization problem for trend adjustment

Parameters:tbochar if ‘u’ only trends will be adjusted regardless of unit costs. if ‘b’ costs of units will be used to adjust trends
constraint(fld, value, dt)[source]

Suggest a constraint for future.

Parameters:
  • fldstr the column whose values is about to be adjusted
  • valuefloat the suggested value for the given date
  • dtdatetime the suggested date for adjustment
date2num(dt)[source]

Converts a datetime to a number according to self.num_intrvl

Parameters:dtdatetime
fit_regressors()[source]

Initializes the regression objects and fit them on training data

make_date_interval_val(dt, n_days)[source]

Converts the outcome of self.make_date_interval into a list of floats

plot_analysis()[source]

Plots the outcome of the adjustment.

plot_init_system()[source]

Plots the initial data points and regression curves for projection date

refit(fld, val, dt, n_points)[source]

Refits the regressor of the fld after producing n_points samples points around dt using a normal distribution centered at val

Parameters:
  • fld – the regression associated to fld will be refitted
  • val – the suggested value for the regression curve at dt
  • dt – the suggested datetime to make adjustments to the values of fld
  • n_points – number of samples to be generated for refitting
set_cost_regressor(regressor)[source]

Sets the regressor for unit costs. Any regression inherited from sk-learn.RegressorMixin is acceptable

Parameters:regressorRegressorMixin
set_unit_count_regressor(regressor)[source]

Sets the regressor for unit counts. Any regression inherited from sk-learn.RegressorMixin is acceptable

Parameters:regressorRegressorMixin