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

'UFuncTypeError' thrown in the DetrendedFeature function when changing the frequency to months or weeks #94

Open
ckae95 opened this issue Dec 31, 2019 · 0 comments

Comments

@ckae95
Copy link
Contributor

ckae95 commented Dec 31, 2019

Description

'UFuncTypeError' thrown in the DetrendedFeature function when changing the frequency to months or weeks

Steps/Code to Reproduce

import pandas as pd
from giottotime.feature_creation import DetrendedFeature
from giottotime.models import PolynomialTrend
model = PolynomialTrend(order=2)
detrend_feature = DetrendedFeature(trend_model=model)
time_index = pd.date_range("2011-01-01", "2011-11-01", freq='M')
X = pd.DataFrame(range(0, len(time_index)), index=time_index)
detrend_feature.transform(X)

Comment

It works e.g. if I set the frequency to days or hours but not for weeks or months.

Error message

UFuncTypeError Traceback (most recent call last)
in
4 detrend_feature = DetrendedFeature(trend_model=model)
5
----> 6 detrend_feature.transform(pd.DataFrame(test_all, index=time_index))

~/anaconda3/envs/time/lib/python3.7/site-packages/giottotime/feature_creation/index_dependent_features/trend_features.py in transform(self, time_series)
73 """
74 self.trend_model.fit(time_series)
---> 75 time_series_t = self.trend_model.transform(time_series)
76 time_series_t = self._rename_columns(time_series_t)
77 return time_series_t

~/anaconda3/envs/time/lib/python3.7/site-packages/giottotime/models/trend_models/polynomial_trend.py in transform(self, ts)
118
119 p = np.poly1d(self.model_weights_)
--> 120 time_steps = (ts.index - self.t0_) / self.period_
121
122 predictions = pd.Series(index=ts.index, data=[p(t) for t in time_steps])

~/anaconda3/envs/time/lib/python3.7/site-packages/pandas/core/indexes/timedeltas.py in method(self, other)
45
46 def method(self, other):
---> 47 result = meth(self._data, maybe_unwrap_index(other))
48 return wrap_arithmetic_op(self, other, result)
49

~/anaconda3/envs/time/lib/python3.7/site-packages/pandas/core/arrays/timedeltas.py in truediv(self, other)
531 elif lib.is_scalar(other):
532 # assume it is numeric
--> 533 result = self._data / other
534 freq = None
535 if self.freq is not None:

UFuncTypeError: ufunc 'true_divide' cannot use operands with types dtype('<m8[ns]') and dtype('O')

Versions

Darwin-18.7.0-x86_64-i386-64bit
Python 3.7.5 (default, Oct 25 2019, 10:52:18)
[Clang 4.0.1 (tags/RELEASE_401/final)]
NumPy 1.18.0
SciPy 1.4.1
joblib 0.14.1
Scikit-Learn 0.22
giotto-Learn 0.1.3
giotto-time 0.1.0

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

1 participant