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

[BUG] Fitting errors using WEASEL #640

Closed
isma3ilsamir opened this issue Jan 31, 2021 · 6 comments
Closed

[BUG] Fitting errors using WEASEL #640

isma3ilsamir opened this issue Jan 31, 2021 · 6 comments
Labels
bug Something isn't working

Comments

@isma3ilsamir
Copy link

Describe the bug
I am trying to train WEASEL on different datasets, but I seem to get errors on many of them. Below is a table with the names of datasets that failed and their corresponding errors.

There seems to be 2 main errors

  • NO matching definition for argument type(s) readonly array(float64, 1d, C), int64, int64, array(float64, 1d, C)
  • Input contains NaN, infinity or a value too large for dtype('float64')

For the second error I checked the PLAID dataset and it does contain missing values. As per my understanding, I thought since the data_io utils have a replace_missing_vals_with='NaN' option that algorithms will be able to learn on data with missing values. Am I correct ? or do I have I handle missing values myself ?

dataset                   error
RefrigerationDevices	"NO matching definition for argument type(s) readonly array(float64, 1d, C), int64, int64, array(float64, 1d, C)"
ScreenType	"NO matching definition for argument type(s) readonly array(float64, 1d, C), int64, int64, array(float64, 1d, C)"
ElectricDevices	"NO matching definition for argument type(s) readonly array(float64, 1d, C), int64, int64, array(float64, 1d, C)"
Computers	"NO matching definition for argument type(s) readonly array(float64, 1d, C), int64, int64, array(float64, 1d, C)"
LargeKitchenAppliances	"NO matching definition for argument type(s) readonly array(float64, 1d, C), int64, int64, array(float64, 1d, C)"
SmallKitchenAppliances	"NO matching definition for argument type(s) readonly array(float64, 1d, C), int64, int64, array(float64, 1d, C)"
PLAID	"Input contains NaN, infinity or a value too large for dtype('float64')"
ACSF1	"NO matching definition for argument type(s) readonly array(float64, 1d, C), int64, int64, array(float64, 1d, C)"

To Reproduce

from sktime.classification.dictionary_based import WEASEL
from sklearn.model_selection import train_test_split
from sktime.utils.data_io import load_from_arff_to_dataframe as load_arff

## I import the desired dataset
X_train, y_train = load_arff(f'{dataset}_TRAIN.arff')
X_test, y_test = load_arff(f'{dataset}_TEST.arff')

classifier = WEASEL(p_threshold=0.05, n_jobs=-1)
classifier.fit(X_train, y_train)

Expected behavior

Additional context

Versions

System: python: 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)] executable: C:\Users\Ismail\.virtualenvs\Code-h9r8g-fJ\Scripts\python.exe machine: Windows-10-10.0.18362-SP0

Python dependencies:
pip: 20.3.3
setuptools: 51.3.3
sklearn: 0.24.1
sktime: 0.5.2
statsmodels: 0.12.1
numpy: 1.19.5
scipy: 1.6.0
Cython: 0.29.21
pandas: 1.2.1
matplotlib: 3.3.4
joblib: 1.0.0
numba: 0.52.0
pmdarima: None
tsfresh: 0.17.0

@isma3ilsamir isma3ilsamir added the bug Something isn't working label Jan 31, 2021
@mloning
Copy link
Contributor

mloning commented Jan 31, 2021

Thanks @isma3ilsamir for raising the issue!

Current implementations cannot handle missing values as far as I know. I'll also ping @patrickzib the author of WEASEL.

@patrickzib
Copy link
Contributor

Thank you. It seems to be a bug related to the Numba-signatures of the methods. I will look into it.

@patrickzib
Copy link
Contributor

@mloning :

There are .ts files in the default distribution of sktime for the PLAID, etc datasets. However, after loading these with:

  X_train, y_train = load_from_tsfile_to_dataframe(os.path.join(DATA_PATH, "PLAID/PLAID_TRAIN.ts"))
   X_test, y_test = load_from_tsfile_to_dataframe(os.path.join(DATA_PATH, "PLAID/PLAID_TEST.ts"))

   weasel = WEASEL(p_threshold=0.05, n_jobs=-1)
   weasel.fit(X_train, y_train)

I do get an error in

X, y = check_X_y(X, y, enforce_univariate=True, coerce_to_numpy=True)
shapes = {arr.shape for arr in arrays}
       if len(shapes) != 1:
>           raise ValueError('all input arrays must have the same shape')
E           ValueError: all input arrays must have the same shape

It seems like variable length in combination with check_X_y is not supported?

@patrickzib
Copy link
Contributor

patrickzib commented Feb 1, 2021

@mloning
These errors are easily fixable:
"NO matching definition for argument type(s) readonly array(float64, 1d, C), int64, int64, array(float64, 1d, C)"

However, this one requires data-manipulation:
"Input contains NaN, infinity or a value too large for dtype('float64')"
It can be fixed by:
X = np.nan_to_num(X)
But I do not want to add the latter in WEASEL. Maybe this should be handled more globally?

@mloning
Copy link
Contributor

mloning commented Feb 1, 2021

Yes, thanks @patrickzib for looking into this. I'm not too with these data sets, but if the problem is that they are variable-length and/or contain missing values, I agree that we should check this in a globally defined function for input checks and raise more informative errors.

mloning pushed a commit that referenced this issue Feb 4, 2021
Co-authored-by: Patrick Schäfer <patrick.schaefer@zib.de>
@mloning
Copy link
Contributor

mloning commented Feb 4, 2021

Closed by #642

@mloning mloning closed this as completed Feb 4, 2021
uhbuhb pushed a commit to MLH-Fellowship/sktime that referenced this issue Feb 8, 2021
Co-authored-by: Patrick Schäfer <patrick.schaefer@zib.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants