Pricing
Bases: Module
, IMixedEffect
Source code in wt_ml/layers/pricing.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
|
__call__(batch, training=False, debug=False, skip_metrics=False)
Pricing Layer Forward Propagation.
We take in the mean normalized \(price\) signal of shape (num_time, num_granular, n_sim)
.
Then we take the \(offset\) and \(exponent\) learnt by the model, each of shape (num_granular,)
.
The impact is calculated as follows:
\(volume = \frac{normalization\_mult} {(price + offset) ^ {exponent}}\)
\(normalization\_{mult} = (1 + offset) ^ {exponent}\)
\(impact = volume * price\)
This \(impact\) is of shape (num_time, num_granular, n_sim)
NOTE: normalization_mult is a factor to neglect the impact of prices which equal the average price.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
price |
TensorLike
|
mean normalized price_per_hl for each granularity each week. Shape: (num_time, num_granular, n_sim) |
required |
hierarchy |
dict[str, TensorLike]
|
Hierarchical Placeholder for creating hierarchical variable. |
required |
training |
bool
|
Whether this is a training or inference run. Defaults to False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
PricingIntermediaries |
PricingIntermediaries
|
Intermediate calculations like offset, asymptote, exponent, etc., and final impact. |
Source code in wt_ml/layers/pricing.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
|
__init__(encodings, hierarchy_categories=None, hyperparameters=None, name=None)
Multiplicative price elasticity factor affecting baseline sales that also scales ROI of investments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hierarchy |
DataFrame
|
The hierarchy used to build features learnt by the model to generate impacts. |
required |
hyperparameters |
Hyperparams | None
|
An instance of |
None
|
name |
str | None
|
Name of the Pricing Layer.
|
None
|
Source code in wt_ml/layers/pricing.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
build(input_shapes)
Builds the price_params_emb_layer
hierarchical variable
for generating price elasticity curve for each granularity.
Shape of the variable: (num_granular, 2). 2 denotes offset and exponent.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_shapes |
InputShapes
|
A tuple of tensor shapes of |
required |
Source code in wt_ml/layers/pricing.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|