@@ -139,7 +139,12 @@ def batched_convolution(
139139
140140
141141def geometric_adstock (
142- x , alpha : float = 0.0 , l_max : int = 12 , normalize : bool = False , axis : int = 0
142+ x ,
143+ alpha : float = 0.0 ,
144+ l_max : int = 12 ,
145+ normalize : bool = False ,
146+ axis : int = 0 ,
147+ mode : ConvMode = ConvMode .After ,
143148):
144149 R"""Geometric adstock transformation.
145150
@@ -189,6 +194,17 @@ def geometric_adstock(
189194 Maximum duration of carryover effect.
190195 normalize : bool, by default False
191196 Whether to normalize the weights.
197+ axis : int
198+ The axis of ``x`` along witch to apply the convolution
199+ mode : ConvMode, optional
200+ The convolution mode determines how the convolution is applied at the boundaries
201+ of the input signal, denoted as "x." The default mode is ConvMode.Before.
202+
203+ - ConvMode.After: Applies the convolution with the "Adstock" effect, resulting in a trailing decay effect.
204+ - ConvMode.Before: Applies the convolution with the "Excitement" effect, creating a leading effect
205+ similar to the wow factor.
206+ - ConvMode.Overlap: Applies the convolution with both "Pull-Forward" and "Pull-Backward" effects,
207+ where the effect overlaps with both preceding and succeeding elements.
192208
193209 Returns
194210 -------
@@ -203,7 +219,7 @@ def geometric_adstock(
203219
204220 w = pt .power (pt .as_tensor (alpha )[..., None ], pt .arange (l_max , dtype = x .dtype ))
205221 w = w / pt .sum (w , axis = - 1 , keepdims = True ) if normalize else w
206- return batched_convolution (x , w , axis = axis , mode = ConvMode . After )
222+ return batched_convolution (x , w , axis = axis , mode = mode )
207223
208224
209225def delayed_adstock (
@@ -213,6 +229,7 @@ def delayed_adstock(
213229 l_max : int = 12 ,
214230 normalize : bool = False ,
215231 axis : int = 0 ,
232+ mode : ConvMode = ConvMode .After ,
216233):
217234 R"""Delayed adstock transformation.
218235
@@ -259,6 +276,17 @@ def delayed_adstock(
259276 Maximum duration of carryover effect.
260277 normalize : bool, by default False
261278 Whether to normalize the weights.
279+ axis : int
280+ The axis of ``x`` along witch to apply the convolution
281+ mode : ConvMode, optional
282+ The convolution mode determines how the convolution is applied at the boundaries
283+ of the input signal, denoted as "x." The default mode is ConvMode.Before.
284+
285+ - ConvMode.After: Applies the convolution with the "Adstock" effect, resulting in a trailing decay effect.
286+ - ConvMode.Before: Applies the convolution with the "Excitement" effect, creating a leading effect
287+ similar to the wow factor.
288+ - ConvMode.Overlap: Applies the convolution with both "Pull-Forward" and "Pull-Backward" effects,
289+ where the effect overlaps with both preceding and succeeding elements.
262290
263291 Returns
264292 -------
@@ -275,7 +303,7 @@ def delayed_adstock(
275303 (pt .arange (l_max , dtype = x .dtype ) - pt .as_tensor (theta )[..., None ]) ** 2 ,
276304 )
277305 w = w / pt .sum (w , axis = - 1 , keepdims = True ) if normalize else w
278- return batched_convolution (x , w , axis = axis , mode = ConvMode . After )
306+ return batched_convolution (x , w , axis = axis , mode = mode )
279307
280308
281309def weibull_adstock (
@@ -284,6 +312,7 @@ def weibull_adstock(
284312 k = 1 ,
285313 l_max : int = 12 ,
286314 axis : int = 0 ,
315+ mode : ConvMode = ConvMode .After ,
287316 type : WeibullType | str = WeibullType .PDF ,
288317):
289318 R"""Weibull Adstocking Transformation.
@@ -349,6 +378,17 @@ def weibull_adstock(
349378 Shape parameter of the Weibull distribution. Must be positive.
350379 l_max : int, by default 12
351380 Maximum duration of carryover effect.
381+ axis : int
382+ The axis of ``x`` along witch to apply the convolution
383+ mode : ConvMode, optional
384+ The convolution mode determines how the convolution is applied at the boundaries
385+ of the input signal, denoted as "x." The default mode is ConvMode.Before.
386+
387+ - ConvMode.After: Applies the convolution with the "Adstock" effect, resulting in a trailing decay effect.
388+ - ConvMode.Before: Applies the convolution with the "Excitement" effect, creating a leading effect
389+ similar to the wow factor.
390+ - ConvMode.Overlap: Applies the convolution with both "Pull-Forward" and "Pull-Backward" effects,
391+ where the effect overlaps with both preceding and succeeding elements.
352392 type : WeibullType or str, by default WeibullType.PDF
353393 Type of Weibull adstock transformation to be applied (PDF or CDF).
354394
@@ -374,7 +414,7 @@ def weibull_adstock(
374414 w = pt .cumprod (padded_w , axis = - 1 )
375415 else :
376416 raise ValueError (f"Wrong WeibullType: { type } , expected of WeibullType" )
377- return batched_convolution (x , w , axis = axis )
417+ return batched_convolution (x , w , axis = axis , mode = mode )
378418
379419
380420def logistic_saturation (x , lam : npt .NDArray [np .float_ ] | float = 0.5 ):
0 commit comments