Skip to content

Commit cd47c9d

Browse files
williambdeanjuanitorduz
authored andcommitted
add to docstrings tanh saturation (#657)
Co-authored-by: Juan Orduz <juanitorduz@gmail.com>
1 parent b129833 commit cd47c9d

File tree

1 file changed

+45
-12
lines changed

1 file changed

+45
-12
lines changed

pymc_marketing/mmm/transformers.py

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -420,34 +420,67 @@ def logistic_saturation(x, lam: npt.NDArray[np.float_] | float = 0.5):
420420

421421

422422
class TanhSaturationParameters(NamedTuple):
423-
b: pt.TensorLike
424-
"""Saturation.
423+
"""Container for tanh saturation parameters.
424+
425+
Parameters
426+
----------
427+
b : pt.TensorLike
428+
Saturation
429+
c : pt.TensorLike
430+
Customer Aquisition Cost at 0.
431+
425432
"""
433+
434+
b: pt.TensorLike
426435
c: pt.TensorLike
427-
"""Customer Aquisition Cost at 0.
428-
"""
429436

430437
def baseline(self, x0: pt.TensorLike) -> "TanhSaturationBaselinedParameters":
431-
"""Change the parameterization to baselined at :math:`x_0`."""
438+
"""Change the parameterization to baselined at :math:`x_0`.
439+
440+
Parameters
441+
----------
442+
x0 : pt.TensorLike
443+
Baseline spend.
444+
445+
Returns
446+
-------
447+
TanhSaturationBaselinedParameters
448+
Baselined parameters.
449+
450+
"""
432451
y_ref = tanh_saturation(x0, self.b, self.c)
433452
gain_ref = y_ref / x0
434453
r_ref = y_ref / self.b
435454
return TanhSaturationBaselinedParameters(x0, gain_ref, r_ref)
436455

437456

438457
class TanhSaturationBaselinedParameters(NamedTuple):
439-
x0: pt.TensorLike
440-
"""Baseline spend.
458+
"""Representation of tanh saturation parameters in baselined form.
459+
460+
Parameters
461+
----------
462+
x0 : pt.TensorLike
463+
Baseline spend.
464+
gain : pt.TensorLike
465+
ROAS at :math:`x_0`.
466+
r : pt.TensorLike
467+
Overspend Fraction.
468+
441469
"""
470+
471+
x0: pt.TensorLike
442472
gain: pt.TensorLike
443-
"""ROAS at :math:`x_0`.
444-
"""
445473
r: pt.TensorLike
446-
"""Overspend Fraction.
447-
"""
448474

449475
def debaseline(self) -> TanhSaturationParameters:
450-
"""Change the parameterization to baselined to be classic saturation and cac."""
476+
"""Change the parameterization to baselined to be classic saturation and cac.
477+
478+
Returns
479+
-------
480+
TanhSaturationParameters
481+
Classic saturation and cac parameters.
482+
483+
"""
451484
saturation = (self.gain * self.x0) / self.r
452485
cac = self.r / (self.gain * pt.arctanh(self.r))
453486
return TanhSaturationParameters(saturation, cac)

0 commit comments

Comments
 (0)