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

backtests' example: AttributeError: 'numpy.float64' object has no attribute 'width' #244

Closed
juanpabloaj opened this issue Nov 29, 2020 · 3 comments
Labels
bug Something isn't working triage Issue waiting for triaging

Comments

@juanpabloaj
Copy link

When I was trying to follow the article backtests' example

https://medium.com/unit8-machine-learning-publication/darts-time-series-made-easy-in-python-5ac2947a8878

I got this error

AttributeError                            Traceback (most recent call last)
<ipython-input-14-9213dab113d8> in <module>
      2 series.plot(label='data')
      3 for i, m in enumerate(models):
----> 4     err = mape(backtests[i], series)
      5     backtests[i].plot(lw=3, label='{}, MAPE={:.2f}%'.format(m, err))
      6 plt.title('Backtests with 3-months forecast horizon')

~/.pyenv/versions/3.8.3/envs/keras/lib/python3.8/site-packages/darts/metrics/metrics.py in wrapper_multivariate_support(*args, **kwargs)
     31         series2 = kwargs['series2'] if 'series2' in kwargs else args[0] if 'series1' in kwargs else args[1]
     32 
---> 33         raise_if_not(series1.width == series2.width, "The two TimeSeries instances must have the same width.", logger)
     34 
     35         num_series_in_args = int('series1' not in kwargs) + int('series2' not in kwargs)

AttributeError: 'numpy.float64' object has no attribute 'width'

To Reproduce

I used this part of the code

from darts.models import Prophet
models = [ExponentialSmoothing(), Prophet()]
backtests = [model.backtest(series,
                            start=pd.Timestamp('19550101'),
                            forecast_horizon=3)
             for model in models]

from darts.metrics import mape
series.plot(label='data')
for i, m in enumerate(models):
    err = mape(backtests[i], series)
    backtests[i].plot(lw=3, label='{}, MAPE={:.2f}%'.format(m, err))
plt.title('Backtests with 3-months forecast horizon')
plt.legend()

Expected behavior
I would like to get the article's plot and results.

System (please complete the following information):
u8darts==0.5.0
fbprophet==0.6
Python 3.8.3

Additional context

I don't know if this message is expected but in this part of the code

backtests = [model.backtest(series,
                            start=pd.Timestamp('19550101'),
                            forecast_horizon=3)
             for model in models]

I get this message many times

INFO:fbprophet:Disabling weekly seasonality. Run prophet with weekly_seasonality=True to override this.
@juanpabloaj juanpabloaj added bug Something isn't working triage Issue waiting for triaging labels Nov 29, 2020
@pennfranc
Copy link
Contributor

Hi @juanpabloaj, nice catch! We recently updated the name of the backtest function to historical_forecasts, which is not yet reflected in the medium article. In the meantime you can just replace model.backtest with model.historical_forecasts and that should do the trick!
If you still run into problems please let us know.

@hrzn
Copy link
Contributor

hrzn commented Nov 30, 2020

The Medium article has been updated, thanks for raising the issue @juanpabloaj

@hrzn hrzn closed this as completed Nov 30, 2020
@juanpabloaj
Copy link
Author

thanks, maybe in some part of the article you could add the version of darts used in this demo to avoid future confusion.

thanks again for your fast answer, the project, and your work in general 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage Issue waiting for triaging
Projects
None yet
Development

No branches or pull requests

3 participants