johannfaouzi / pyts

A Python package for time series classification

Home Page:https://pyts.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

VisibleDeprecationWarning

jmrichardson opened this issue · comments

Description

Hi, I am getting many of these warnings with ShapeletTransform:

D:\Anaconda3\envs\tipjar\lib\site-packages\numpy\core\_asarray.py:83: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
  return array(a, dtype, copy=False, order=order)

Steps/Code to Reproduce

st = ShapeletTransform(n_jobs=cpus)
    features = st.fit_transform(X_trn_seg, y_trn_seg)

Versions

NumPy 1.19.1
SciPy 1.4.1
Scikit-Learn 0.23.1
Numba 0.49.1
Pyts 0.11.0

Hi,

Thanks for the report. If I had to guess, I would say that this warning is raised when the shapelets are saved as an array of arrays and the dtype is not specified when creating this array:

shapelets = np.asarray(list(chain.from_iterable(shapelets)))

If I add a dtype='object' when creating this array, there is no warning anymore.

One temporary fix for your project is to simply suppress this warning. I won't probably make a release that just fixes this issue.

PR welcomed if you want to do it, otherwise I'll do it ;)