Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1063 Pareto_nbd distribution enhancements #1067

Merged

Conversation

Ishaanjolly
Copy link
Contributor

@Ishaanjolly Ishaanjolly commented Sep 24, 2024

Distribution new customer enhancements

Description

I added n_samples: int = 1000 to _distribution_new_customers and modified this line within:

        if dataset.sizes["chain"] == 1 and dataset.sizes["draw"] == 1:
            # For map fit add a dummy draw dimension
            dataset = dataset.squeeze("draw").expand_dims(draw=range(n_samples))

Additionally:
I added n_samples: int = 1 to distribution_new_customer_recency_frequency and modified this:

self._distribution_new_customers(
            data=data,
            T=T,
            random_seed=random_seed,
            var_names=["recency_frequency"],
            n_samples=n_samples,
        )["recency_frequency"]

Related Issue

Checklist

Modules affected

  • MMM
  • CLV

Type of change

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

📚 Documentation preview 📚: https://pymc-marketing--1067.org.readthedocs.build/en/1067/

Copy link
Contributor Author

@Ishaanjolly Ishaanjolly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

had to do this again as not updated the branch!

@juanitorduz
Copy link
Collaborator

Thanks @Ishaanjolly !

We need to fix one test that is failing

 tests/clv/models/test_pareto_nbd.py::TestParetoNBDModel::test_posterior_distributions[map] - assert (1, 1, 2357, 2) == (1, 1000, 2357, 2)

Let me know if you need help this that :)

@Ishaanjolly
Copy link
Contributor Author

Ishaanjolly commented Sep 28, 2024

Thanks @Ishaanjolly !

We need to fix one test that is failing

 tests/clv/models/test_pareto_nbd.py::TestParetoNBDModel::test_posterior_distributions[map] - assert (1, 1, 2357, 2) == (1, 1000, 2357, 2)

Let me know if you need help this that :)

I had set n_samples = 1 in the _distribution_new_customers_frequency method without looking at the requirement.. think it's good now!

@wd60622 wd60622 added CLV enhancement New feature or request labels Sep 28, 2024
@ColtAllen
Copy link
Collaborator

Have you checked the Pareto/NBD notebook to make sure no changes need to be made?

@juanitorduz
Copy link
Collaborator

Have you checked the Pareto/NBD notebook to make sure no changes need to be made?

The notebooks are running on the CI so everything looks good :)

@@ -1052,6 +1056,8 @@ def distribution_new_customer_recency_frequency(
Not required if `data` Dataframe contains a `T` column.
random_seed : ~numpy.random.RandomState, optional
Random state to use for sampling.
n_samples : int, optional
Number of samples to generate. Defaults to 1.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defaults to 1_000 right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1000, yeah sorry missed it. will correct it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

@juanitorduz juanitorduz merged commit 7a2b13f into pymc-labs:main Sep 30, 2024
11 checks passed
@juanitorduz
Copy link
Collaborator

Thanks @Ishaanjolly !

jsnyde0 pushed a commit to jsnyde0/pymc-marketing that referenced this pull request Sep 30, 2024
* feat: test.txt added for commit check

* feat: replaced plot_curve with plot_samples within ./mmm/plot.py

* feat: n_samples added to distributions_new_customers

* feat: added n_samples to distributions_new_customer and distribution_new_customer_frequency

* remove test.txt

* redo commit before samples from sample in ./mmm/plot.py

* feat(pareto_nbd.py): changed n_samples = 1000 from 1

* fix (pareto_nbd.py): corrected the doc string for dis_new_cust_freq with n_samples = 1000 default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLV enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants