BFNet

Bases: EconomicNetwork

Source code in wt_ml/networks/bfnet.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class BFNet(EconomicNetwork):
    result_type: ClassVar[type] = EconomicIntermediaries
    num_mask_steps: ClassVar[int] = 1

    def get_baseline(self, impacts: ImpactsIntermediaries, training=False) -> tuple[tf.Tensor, dict]:  # noqa: U100
        """Getting baseline from the previous week actual sales by removing impacts

        Args:
            impacts (ImpactsIntermediaries): Intermediaries object which contains additive and multiplicative impacts.
            training (bool, optional):  Flag to set the trainable params. Defaults to False.

        Returns:
            tuple[tf.Tensor, dict[str, tf.Tensor]] : Returning the baseline by removing the additive and
             multiplicative effect of previous week
        """
        additive_shifted_impacts = [impact[:, :-1] for impact in impacts.additive_impacts]
        multiplicative_shifted_impacts = [impact[:, :-1] for impact in impacts.multiplicative_impacts]
        baseline = apply_inverse_impacts(
            self.yph[:, :-1],
            additive_impacts=additive_shifted_impacts,
            multiplicative_impacts=multiplicative_shifted_impacts,
        )
        return tf.concat([tf.zeros_like(baseline[:, :1]), baseline], axis=1), {}

get_baseline(impacts, training=False)

Getting baseline from the previous week actual sales by removing impacts

Parameters:

Name Type Description Default
impacts ImpactsIntermediaries

Intermediaries object which contains additive and multiplicative impacts.

required
training bool

Flag to set the trainable params. Defaults to False.

False

Returns:

Type Description
tuple[Tensor, dict]

tuple[tf.Tensor, dict[str, tf.Tensor]] : Returning the baseline by removing the additive and multiplicative effect of previous week

Source code in wt_ml/networks/bfnet.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
def get_baseline(self, impacts: ImpactsIntermediaries, training=False) -> tuple[tf.Tensor, dict]:  # noqa: U100
    """Getting baseline from the previous week actual sales by removing impacts

    Args:
        impacts (ImpactsIntermediaries): Intermediaries object which contains additive and multiplicative impacts.
        training (bool, optional):  Flag to set the trainable params. Defaults to False.

    Returns:
        tuple[tf.Tensor, dict[str, tf.Tensor]] : Returning the baseline by removing the additive and
         multiplicative effect of previous week
    """
    additive_shifted_impacts = [impact[:, :-1] for impact in impacts.additive_impacts]
    multiplicative_shifted_impacts = [impact[:, :-1] for impact in impacts.multiplicative_impacts]
    baseline = apply_inverse_impacts(
        self.yph[:, :-1],
        additive_impacts=additive_shifted_impacts,
        multiplicative_impacts=multiplicative_shifted_impacts,
    )
    return tf.concat([tf.zeros_like(baseline[:, :1]), baseline], axis=1), {}