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

Fitting works but predicting doesn't if dtype=object #3

Closed
vhpietil opened this issue Nov 17, 2021 · 1 comment
Closed

Fitting works but predicting doesn't if dtype=object #3

vhpietil opened this issue Nov 17, 2021 · 1 comment

Comments

@vhpietil
Copy link

If I make my data like this y = np.array(df.cust), I have an array with dtype=object.
array([2280, 2158, 2067, ..., 1696, 2035, 2083], dtype=object)

With this array I am able to fit the model but predicting throws me an error

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/tmp/ipykernel_1721/2125226056.py in <module>
----> 1 predicted_output = boosted_model.predict(output, 100)
      2 boosted_model.plot_results(output, predicted_output, figsize = (18,12))

~/.local/lib/python3.8/site-packages/ThymeBoost/ThymeBoost.py in predict(self, fitted_output, forecast_horizon, future_exogenous, damp_factor, trend_cap_target)
    345             assert len(future_exogenous) == forecast_horizon, 'Given future exogenous not equal to forecast horizon'
    346         if self.ensemble_boosters is None:
--> 347             trend, seas, exo, predictions = predict_rounds(self.booster_obj,
    348                                                            forecast_horizon,
    349                                                            future_exogenous)

~/.local/lib/python3.8/site-packages/ThymeBoost/predict_functions.py in predict_rounds(booster_obj, forecast_horizon, future_exo)
    112                                            boosting_round,
    113                                            forecast_horizon)
--> 114         seasonal_predictions += predict_seasonality(booster_obj,
    115                                                     boosting_round,
    116                                                     forecast_horizon)

TypeError: ufunc 'add' output (typecode 'O') could not be coerced to provided output parameter (typecode 'd') according to the casting rule ''same_kind''

If I make my data like this y = np.array(df.cust, dtype=int), then dtype is not 'object' and both fitting and predicting work

@tblume1992
Copy link
Owner

Interesting, I can't even fit with an array with that datatype. One thing to note is that you can just pass a Pandas series as your y. I convert everything to a Series so I can add some code to convert data types to floats for the fitting procedure, that should address this. For now just make sure everything you pass is some sort of numerical type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants