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

TVP example fails #1531

Closed
fonnesbeck opened this issue Feb 28, 2025 · 3 comments · Fixed by #1533
Closed

TVP example fails #1531

fonnesbeck opened this issue Feb 28, 2025 · 3 comments · Fixed by #1533
Labels
docs Improvements or additions to documentation MMM

Comments

@fonnesbeck
Copy link

Running the example associated with the tvp entry in the API docs fails:

AttributeError                            Traceback (most recent call last)
Cell In[1], line 12
      9 sales = np.random.normal(100, 10, size=len(dates))
     11 # Infer time index
---> 12 time_index = infer_time_index(dates, dates, time_resolution=5)
     14 # Define model configuration
     15 model_config = {
     16     "sales_tvp_config": {
     17         "m": 200,
   (...)
     23     }
     24 }

File ~/labs/pymc-marketing/pymc_marketing/mmm/tvp.py:261, in infer_time_index(date_series_new, date_series, time_resolution)
    237 def infer_time_index(
    238     date_series_new: pd.Series,
    239     date_series: pd.Series,
    240     time_resolution: int,
    241 ) -> npt.NDArray[np.int_]:
    242     """Infer the time-index given a new dataset.
    243 
    244     Infers the time-indices by calculating the number of days since the first date in the dataset.
   (...)
    259 
    260     """
--> 261     return (date_series_new - date_series.iloc[0]).dt.days.values // time_resolution

AttributeError: 'DatetimeIndex' object has no attribute 'iloc'

Environment details:
Python version : 3.10.16
pymc_marketing: 0.11.1
pymc : 5.21.0
arviz : 0.20.0
numpy : 1.26.4
pandas : 2.2.3

@wd60622 wd60622 added docs Improvements or additions to documentation MMM and removed Needs Triage labels Feb 28, 2025
@wd60622
Copy link
Contributor

wd60622 commented Feb 28, 2025

I cannot find this in the notebook. Can you link? Is it latest docs? or stable?

@fonnesbeck
Copy link
Author

https://www.pymc-marketing.io/en/stable/api/generated/pymc_marketing.mmm.tvp.html

@wd60622
Copy link
Contributor

wd60622 commented Mar 1, 2025

@wd60622 wd60622 linked a pull request Mar 1, 2025 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to documentation MMM
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants