Skip to content

Commit

Permalink
use fit_posterior
Browse files Browse the repository at this point in the history
  • Loading branch information
juanitorduz committed Apr 18, 2024
1 parent f9dc0dc commit 89ca035
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions pymc_marketing/clv/models/gamma_gamma.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ def expected_customer_spend(
mean_transaction_value, frequency = to_xarray(
customer_id, mean_transaction_value, frequency
)
if self.idata is None:
if (posterior := self.fit_result) is None:
raise ValueError("Model must be fitted first")

Check warning on line 60 in pymc_marketing/clv/models/gamma_gamma.py

View check run for this annotation

Codecov / codecov/patch

pymc_marketing/clv/models/gamma_gamma.py#L60

Added line #L60 was not covered by tests

posterior = self.idata.posterior
p = posterior["p"]
q = posterior["q"]
v = posterior["v"]
Expand Down Expand Up @@ -92,10 +91,9 @@ def distribution_new_customer_spend(
def expected_new_customer_spend(self) -> xarray.DataArray:
"""Expected transaction value for a new customer"""

if self.idata is None:
if (posterior := self.fit_result) is None:
raise ValueError("Model must be fitted first")

Check warning on line 95 in pymc_marketing/clv/models/gamma_gamma.py

View check run for this annotation

Codecov / codecov/patch

pymc_marketing/clv/models/gamma_gamma.py#L95

Added line #L95 was not covered by tests

posterior = self.idata.post
p_mean = posterior["p"]
q_mean = posterior["q"]
v_mean = posterior["v"]
Expand Down

0 comments on commit 89ca035

Please sign in to comment.