blue-yonder / tsfresh

Automatic extraction of relevant features from time series:
http://tsfresh.readthedocs.io
MIT License
8.36k stars 1.21k forks source link

AttributeError: `np.PINF` was removed in the NumPy 2.0 release. Use `np.inf` instead. #1088

Open giordanocolombi opened 1 month ago

giordanocolombi commented 1 month ago

The problem: I am using the extract_features function

settings = MinimalFCParameters()
feat =  extract_features(df_prices.iloc[0:n_day],
                        column_id='Id',
                        default_fc_parameters=settings,
                        impute_function=impute, disable_progressbar=True)

and I've got the following error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[10], line 2
      1 settings = MinimalFCParameters()
----> 2 feat =  extract_features(df_prices.iloc[0:n_day],
      3                         column_id='Id',
      4                         default_fc_parameters=settings,
      5                         impute_function=impute, disable_progressbar=True)

File [~\AppData\Local\anaconda3\envs\xbg\lib\site-packages\tsfresh\feature_extraction\extraction.py:182](http://localhost:8889/lab/tree/notebook/~/AppData/Local/anaconda3/envs/xbg/lib/site-packages/tsfresh/feature_extraction/extraction.py#line=181), 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)
    180     # Impute the result if requested
    181     if impute_function is not None:
--> 182         impute_function(result)
    184 # Turn off profiling if it was turned on
    185 if profile:

File [~\AppData\Local\anaconda3\envs\xbg\lib\site-packages\tsfresh\utilities\dataframe_functions.py:73](http://localhost:8889/lab/tree/notebook/~/AppData/Local/anaconda3/envs/xbg/lib/site-packages/tsfresh/utilities/dataframe_functions.py#line=72), in impute(df_impute)
     70     return df_impute
     72 col_to_max, col_to_min, col_to_median = get_range_values_per_column(df_impute)
---> 73 df_impute = impute_dataframe_range(df_impute, col_to_max, col_to_min, col_to_median)
     75 # Ensure a type of "np.float64"
     76 df_impute.astype(np.float64, copy=False)

File [~\AppData\Local\anaconda3\envs\xbg\lib\site-packages\tsfresh\utilities\dataframe_functions.py:168](http://localhost:8889/lab/tree/notebook/~/AppData/Local/anaconda3/envs/xbg/lib/site-packages/tsfresh/utilities/dataframe_functions.py#line=167), in impute_dataframe_range(df_impute, col_to_max, col_to_min, col_to_median)
    163 col_to_min = pd.DataFrame([col_to_min] * len(df_impute), index=df_impute.index)
    164 col_to_median = pd.DataFrame(
    165     [col_to_median] * len(df_impute), index=df_impute.index
    166 )
--> 168 df_impute.where(df_impute.values != np.PINF, other=col_to_max, inplace=True)
    169 df_impute.where(df_impute.values != np.NINF, other=col_to_min, inplace=True)
    170 df_impute.where(~np.isnan(df_impute.values), other=col_to_median, inplace=True)

File [~\AppData\Local\anaconda3\envs\xbg\lib\site-packages\numpy\__init__.py:411](http://localhost:8889/lab/tree/notebook/~/AppData/Local/anaconda3/envs/xbg/lib/site-packages/numpy/__init__.py#line=410), in __getattr__(attr)
    408     raise AttributeError(__former_attrs__[attr])
    410 if attr in __expired_attributes__:
--> 411     raise AttributeError(
    412         f"`np.{attr}` was removed in the NumPy 2.0 release. "
    413         f"{__expired_attributes__[attr]}"
    414     )
    416 if attr == "chararray":
    417     warnings.warn(
    418         "`np.chararray` is deprecated and will be removed from "
    419         "the main namespace in the future. Use an array with a string "
    420         "or bytes dtype instead.", DeprecationWarning, stacklevel=2)

AttributeError: `np.PINF` was removed in the NumPy 2.0 release. Use `np.inf` instead.

Anything else we need to know?:

Environment:

nils-braun commented 1 month ago

Thanks @giordanocolombi! I just released a new version of tsfresh (0.20.3) that is compatible with the newest version of numpy.

giordanocolombi commented 1 month ago

thank you @nils-braun!