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

TypeError: acf() got an unexpected keyword argument 'unbiased' #1045

Closed
YWU99u opened this issue Sep 19, 2023 · 11 comments
Closed

TypeError: acf() got an unexpected keyword argument 'unbiased' #1045

YWU99u opened this issue Sep 19, 2023 · 11 comments
Labels

Comments

@YWU99u
Copy link

YWU99u commented Sep 19, 2023

I faced this issue when I tried to use extract_features function from this package.This seemed to be an old, but I still could not figure out the solution for this problem. I've tried to downgrade my statsmodel to 0.12.1, but it turns out it gave me another error saying my pandas package had a compatibility issue as "ImportError: cannot import name 'Int64Index' from 'pandas'".
Does anyone have a solution on how to use this package?

@YWU99u YWU99u added the bug label Sep 19, 2023
@nils-braun
Copy link
Collaborator

Hi @YWU99u - which version of tsfresh, python and statsmodel are you using? Unfortunately, I can not reproduce this issue.

@XudongWang97
Copy link

XudongWang97 commented Sep 27, 2023

I got the similar error, and I found the message showed file feature_extraction/feature_calculators.py different from current main branch.

Package versions:
python 3.7
tsfresh 0.20.1
statsmodels 0.13.2

Error message:
Traceback (most recent call last):
File "/opt/conda/lib/python3.7/multiprocessing/pool.py", line 121, in worker
result = (True, func(*args, **kwds))
File "/opt/conda/lib/python3.7/site-packages/tsfresh/utilities/distribution.py", line 43, in _function_with_partly_reduce
results = list(itertools. chain. from_iterable(results))
File "/opt/conda/lib/python3.7/site-packages/tsfresh/utilities/distribution.py", line 42, in
results = (map_function(chunk, **kwargs) for chunk in chunk_list)
File "/opt/conda/lib/python3.7/site-packages/tsfresh/feature_extraction/extraction.py", line 328, in _do_extraction_on_chunk
return list(_f())
File "/opt/conda/lib/python3.7/site-packages/tsfresh/feature_extraction/extraction.py", line 314, in _f
result = func(x, param=parameter_list)
File "/opt/conda/lib/python3.7/site-packages/tsfresh/feature_extraction/feature_calculators.py", line 400, in agg_autocorrelation
a = acf(x, unbiased=True, fft=n > THRESHOLD_TO_USE_FFT, nlags=max_maxlag)[1:]
TypeError: acf() got an unexpected keyword argument 'unbiased '

@nils-braun
Copy link
Collaborator

Hi @XudongWang97!
Thanks for sharing those details. The respective file was changes approximately 2 years ago to not contain the "unbiased" parameter anymore, so I am confused why this shows up in version 0.20.1 (3 months ago) again. Are you sure you are using this version and not maybe an older one (just want to double check). How did you install tsfresh? Via pip or conda?

@XudongWang97
Copy link

Thank you @nils-braun
I install tsfresh by pip. Now I create a new py3.9 environment and it works. It's strange that I cannot reproduce the error in the old py3.7 one. Some dependency issue?

@nils-braun
Copy link
Collaborator

Thanks for looking into this. If you have some time, could you check the package versions in both environments (e.g. with pip freeze) and see if there are significant differences? Thank you!

@kiraminnie
Copy link

kiraminnie commented Apr 8, 2024

Hi,

I'm experiencing the same troubles in two different operative systems (Mac OS X and Windows).
This is the error message:

<<
Feature Extraction:   0%|                                 | 0/1 [00:03<?, ?it/s]
---------------------------------------------------------------------------
RemoteTraceback                           Traceback (most recent call last)
RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/Users/andrea/opt/anaconda3/envs/ts_fresh/lib/python3.9/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/Users/andrea/opt/anaconda3/envs/ts_fresh/lib/python3.9/site-packages/tsfresh/utilities/distribution.py", line 43, in _function_with_partly_reduce
    results = list(itertools.chain.from_iterable(results))
  File "/Users/andrea/opt/anaconda3/envs/ts_fresh/lib/python3.9/site-packages/tsfresh/utilities/distribution.py", line 42, in <genexpr>
    results = (map_function(chunk, **kwargs) for chunk in chunk_list)
  File "/Users/andrea/opt/anaconda3/envs/ts_fresh/lib/python3.9/site-packages/tsfresh/feature_extraction/extraction.py", line 337, in _do_extraction_on_chunk
    return list(_f())
  File "/Users/andrea/opt/anaconda3/envs/ts_fresh/lib/python3.9/site-packages/tsfresh/feature_extraction/extraction.py", line 317, in _f
    result = func(x, param=parameter_list)
  File "/Users/andrea/opt/anaconda3/envs/ts_fresh/lib/python3.9/site-packages/tsfresh/feature_extraction/feature_calculators.py", line 404, in agg_autocorrelation
    a = acf(x, unbiased=True, fft=n > THRESHOLD_TO_USE_FFT, nlags=max_maxlag)[1:]
TypeError: acf() got an unexpected keyword argument 'unbiased'
"""

The above exception was the direct cause of the following exception:

TypeError                                 Traceback (most recent call last)
Cell In[4], line 18
     15 df_for_extraction.columns = ['x', 'y', 'id']
     17 #features extraction
---> 18 extracted_features=extract_features(df_for_extraction, column_id="id", column_sort="x", show_warnings=None)
     20 #NaN values removal
     21 impute(extracted_features)

File ~/opt/anaconda3/envs/ts_fresh/lib/python3.9/site-packages/tsfresh/feature_extraction/extraction.py:152, in extract_features(timeseries_container, default_fc_parameters, kind_to_fc_parameters, column_id, column_sort, column_kind, column_value, chunksize, n_jobs, show_warnings, disable_progressbar, impute_function, profile, profiling_filename, profiling_sorting, distributor, pivot)
    149 else:
    150     warnings.simplefilter("default")
--> 152 result = _do_extraction(df=timeseries_container,
    153                         column_id=column_id, column_value=column_value,
    154                         column_kind=column_kind,
    155                         column_sort=column_sort,
    156                         n_jobs=n_jobs, chunk_size=chunksize,
    157                         disable_progressbar=disable_progressbar,
    158                         show_warnings=show_warnings,
    159                         default_fc_parameters=default_fc_parameters,
    160                         kind_to_fc_parameters=kind_to_fc_parameters,
    161                         distributor=distributor,
    162                         pivot=pivot)
    164 # Impute the result if requested
    165 if impute_function is not None:

File ~/opt/anaconda3/envs/ts_fresh/lib/python3.9/site-packages/tsfresh/feature_extraction/extraction.py:255, in _do_extraction(df, column_id, column_value, column_kind, column_sort, default_fc_parameters, kind_to_fc_parameters, n_jobs, chunk_size, disable_progressbar, show_warnings, distributor, pivot)
    249     raise ValueError("the passed distributor is not an DistributorBaseClass object")
    251 kwargs = dict(default_fc_parameters=default_fc_parameters,
    252               kind_to_fc_parameters=kind_to_fc_parameters,
    253               show_warnings=show_warnings)
--> 255 result = distributor.map_reduce(_do_extraction_on_chunk, data=data,
    256                                 chunk_size=chunk_size,
    257                                 function_kwargs=kwargs)
    259 if not pivot:
    260     return result

File ~/opt/anaconda3/envs/ts_fresh/lib/python3.9/site-packages/tsfresh/utilities/distribution.py:213, in IterableDistributorBaseClass.map_reduce(self, map_function, data, function_kwargs, chunk_size, data_length)
    210 else:
    211     result = self.distribute(_function_with_partly_reduce, chunk_generator, map_kwargs),
--> 213 result = list(itertools.chain.from_iterable(result))
    215 self.close()
    217 return result

File ~/opt/anaconda3/envs/ts_fresh/lib/python3.9/site-packages/tqdm/std.py:1178, in tqdm.__iter__(self)
   1175 time = self._time
   1177 try:
-> 1178     for obj in iterable:
   1179         yield obj
   1180         # Update and possibly print the progressbar.
   1181         # Note: does not call self.update(1) for speed optimisation.

File ~/opt/anaconda3/envs/ts_fresh/lib/python3.9/multiprocessing/pool.py:870, in IMapIterator.next(self, timeout)
    868 if success:
    869     return value
--> 870 raise value

File ~/opt/anaconda3/envs/ts_fresh/lib/python3.9/multiprocessing/pool.py:125, in worker()
    123 job, i, func, args, kwds = task
    124 try:
--> 125     result = (True, func(*args, **kwds))
    126 except Exception as e:
    127     if wrap_exception and func is not _helper_reraises_exception:

File ~/opt/anaconda3/envs/ts_fresh/lib/python3.9/site-packages/tsfresh/utilities/distribution.py:43, in _function_with_partly_reduce()
     41 kwargs = kwargs or {}
     42 results = (map_function(chunk, **kwargs) for chunk in chunk_list)
---> 43 results = list(itertools.chain.from_iterable(results))
     44 return results

File ~/opt/anaconda3/envs/ts_fresh/lib/python3.9/site-packages/tsfresh/utilities/distribution.py:42, in <genexpr>()
     25 """
     26 Small helper function to call a function (map_function)
     27 on a list of data chunks (chunk_list) and convert the results into
   (...)
     39 :rtype: list
     40 """
     41 kwargs = kwargs or {}
---> 42 results = (map_function(chunk, **kwargs) for chunk in chunk_list)
     43 results = list(itertools.chain.from_iterable(results))
     44 return results

File ~/opt/anaconda3/envs/ts_fresh/lib/python3.9/site-packages/tsfresh/feature_extraction/extraction.py:337, in _do_extraction_on_chunk()
    334 else:
    335     warnings.simplefilter("default")
--> 337 return list(_f())

File ~/opt/anaconda3/envs/ts_fresh/lib/python3.9/site-packages/tsfresh/feature_extraction/extraction.py:317, in _f()
    314     x = data.values
    316 if func.fctype == "combiner":
--> 317     result = func(x, param=parameter_list)
    318 else:
    319     if parameter_list:

File ~/opt/anaconda3/envs/ts_fresh/lib/python3.9/site-packages/tsfresh/feature_extraction/feature_calculators.py:404, in agg_autocorrelation()
    402     a = [0] * len(x)
    403 else:
--> 404     a = acf(x, unbiased=True, fft=n > THRESHOLD_TO_USE_FFT, nlags=max_maxlag)[1:]
    405 return [("f_agg_\"{}\"__maxlag_{}".format(config["f_agg"], config["maxlag"]),
    406          getattr(np, config["f_agg"])(a[:int(config["maxlag"])])) for config in param]

TypeError: acf() got an unexpected keyword argument 'unbiased'

I have python 3.9.19 installed but anything works.

I tried to change the python version but still no solution.
Can you help me?

The strange things is that the same script works in an old computer with the following configuration:
tsfresh: 0.20.2
pandas: 2.0.1
matplotlib: 3.7.1
statamodels: 0.14.1
python: 3.9.16

@nils-braun
Copy link
Collaborator

Hi @kiraminnie - can you check the version of tsfresh you are using? It looks like this is a (rather) old version.

@kiraminnie
Copy link

Hi @nils-braun , thank you for your support. I have installed the 0.18.0 version. Do you think this is the problem? I don't understand the right combination of versions for Python, tsfresh, statsmodels. It seems there is a combination of libraries working...

Thank you again for your support.

@nils-braun
Copy link
Collaborator

Yes, tsfresh 0.18.0 is from 2021 (!), so it definitely will not work with any recent packages. I would recommend updating to the newest version (0.20.2). In general, the newest version of a package is usually the best one. If all package authors have their dependencies declared correctly, you do not need to sort out a combination yourself and pip will do it for you.

@kiraminnie
Copy link

Thank @nils-braun, I think the problem is that I'm unable to upgrade tsfresh.

I installed many times, all the times using a new environment but the version is always the same: 0.18.0

(WGM_tsfresh) andrea@pcdyn-sl-143 ~ % pip install --upgrade tsfresh
Requirement already satisfied: tsfresh in ./opt/anaconda3/envs/WGM_tsfresh/lib/python3.12/site-packages (0.20.2)
Requirement already satisfied: requests>=2.9.1 in ./opt/anaconda3/envs/WGM_tsfresh/lib/python3.12/site-packages (from tsfresh) (2.31.0)
Requirement already satisfied: numpy>=1.15.1 in ./opt/anaconda3/envs/WGM_tsfresh/lib/python3.12/site-packages (from tsfresh) (1.26.4)
Requirement already satisfied: pandas>=0.25.0 in ./opt/anaconda3/envs/WGM_tsfresh/lib/python3.12/site-packages (from tsfresh) (2.2.1)
Requirement already satisfied: scipy>=1.2.0 in ./opt/anaconda3/envs/WGM_tsfresh/lib/python3.12/site-packages (from tsfresh) (1.13.0)
Requirement already satisfied: statsmodels>=0.13 in ./opt/anaconda3/envs/WGM_tsfresh/lib/python3.12/site-packages (from tsfresh) (0.14.1)
Requirement already satisfied: patsy>=0.4.1 in ./opt/anaconda3/envs/WGM_tsfresh/lib/python3.12/site-packages (from tsfresh) (0.5.6)
Requirement already satisfied: scikit-learn>=0.22.0 in ./opt/anaconda3/envs/WGM_tsfresh/lib/python3.12/site-packages (from tsfresh) (1.4.2)
Requirement already satisfied: tqdm>=4.10.0 in ./opt/anaconda3/envs/WGM_tsfresh/lib/python3.12/site-packages (from tsfresh) (4.66.2)
Requirement already satisfied: stumpy>=1.7.2 in ./opt/anaconda3/envs/WGM_tsfresh/lib/python3.12/site-packages (from tsfresh) (1.12.0)
Requirement already satisfied: cloudpickle in ./opt/anaconda3/envs/WGM_tsfresh/lib/python3.12/site-packages (from tsfresh) (3.0.0)
Requirement already satisfied: python-dateutil>=2.8.2 in ./opt/anaconda3/envs/WGM_tsfresh/lib/python3.12/site-packages (from pandas>=0.25.0->tsfresh) (2.9.0.post0)
Requirement already satisfied: pytz>=2020.1 in ./opt/anaconda3/envs/WGM_tsfresh/lib/python3.12/site-packages (from pandas>=0.25.0->tsfresh) (2024.1)
Requirement already satisfied: tzdata>=2022.7 in ./opt/anaconda3/envs/WGM_tsfresh/lib/python3.12/site-packages (from pandas>=0.25.0->tsfresh) (2024.1)
Requirement already satisfied: six in ./opt/anaconda3/envs/WGM_tsfresh/lib/python3.12/site-packages (from patsy>=0.4.1->tsfresh) (1.16.0)
Requirement already satisfied: charset-normalizer<4,>=2 in ./opt/anaconda3/envs/WGM_tsfresh/lib/python3.12/site-packages (from requests>=2.9.1->tsfresh) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in ./opt/anaconda3/envs/WGM_tsfresh/lib/python3.12/site-packages (from requests>=2.9.1->tsfresh) (3.6)
Requirement already satisfied: urllib3<3,>=1.21.1 in ./opt/anaconda3/envs/WGM_tsfresh/lib/python3.12/site-packages (from requests>=2.9.1->tsfresh) (2.2.1)
Requirement already satisfied: certifi>=2017.4.17 in ./opt/anaconda3/envs/WGM_tsfresh/lib/python3.12/site-packages (from requests>=2.9.1->tsfresh) (2024.2.2)
Requirement already satisfied: joblib>=1.2.0 in ./opt/anaconda3/envs/WGM_tsfresh/lib/python3.12/site-packages (from scikit-learn>=0.22.0->tsfresh) (1.4.0)
Requirement already satisfied: threadpoolctl>=2.0.0 in ./opt/anaconda3/envs/WGM_tsfresh/lib/python3.12/site-packages (from scikit-learn>=0.22.0->tsfresh) (3.4.0)
Requirement already satisfied: packaging>=21.3 in ./opt/anaconda3/envs/WGM_tsfresh/lib/python3.12/site-packages (from statsmodels>=0.13->tsfresh) (24.0)
Requirement already satisfied: numba>=0.55.2 in ./opt/anaconda3/envs/WGM_tsfresh/lib/python3.12/site-packages (from stumpy>=1.7.2->tsfresh) (0.59.1)
Requirement already satisfied: llvmlite<0.43,>=0.42.0dev0 in ./opt/anaconda3/envs/WGM_tsfresh/lib/python3.12/site-packages (from numba>=0.55.2->stumpy>=1.7.2->tsfresh) (0.42.0)
(WGM_tsfresh) andrea@pcdyn-sl-143 ~ % conda search tsfresh
Loading channels: done

Name Version Build Channel

tsfresh 0.18.0 pyhd3eb1b0_0 pkgs/main

@kiraminnie
Copy link

Hi @nils-braun I've reinstalled Anaconda and now I was able to install the right version of tsfresh, which is working. Thank you very much for your help

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

No branches or pull requests

4 participants