sktime: [BUG] RocketClassifier SystemError: _PyEval_EvalFrameDefault

Please, how to fix this error when Training RocketClassifier on 3d data? When I run the basic example from Docs, it works perfectly. But just change data to 3d numpy array and error comes not allowing train. 3d data in shape [n_instances, n_dimensions, series_length] as specified in the Docs. X_train data shape: (2618, 2, 3) (2618 samples, 2 features, 3 lookback length). Thank you!

from sktime.classification.kernel_based import RocketClassifier

clf = RocketClassifier(num_kernels=500, rocket_transform='multirocket', use_multivariate='yes', n_jobs=-1)
clf.fit(X_train, y_train)
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
AssertionError: Sizes of $372binary_subscr.15, $390binary_subscr.26 do not match on /usr/local/lib/python3.10/dist-packages/sktime/transformations/panel/rocket/_multirocket_multi_numba.py (736)

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

SystemError                               Traceback (most recent call last)
[<ipython-input-50-bed19c0333df>](https://localhost:8080/#) in <cell line: 1>()
----> 1 clf.fit(rolling_X_train, y_train_seq)

9 frames
[/usr/local/lib/python3.10/dist-packages/sktime/transformations/panel/rocket/_multirocket_multivariate.py](https://localhost:8080/#) in _transform(self, X, y)
    171         set_num_threads(n_jobs)
    172 
--> 173         X = _transform(
    174             X,
    175             _X1,

SystemError: _PyEval_EvalFrameDefault returned a result with an exception set

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 16

Most upvoted comments

Yes, should have noticed - 3 is kind of short. Not much of a time series to talk about…

Probably better dealt with via tabular classification?

Until the error is fixed, I will try convert my data do 2d array.

That would be weird if that helps, as internally afaik it is reshaped to 3d again.

Can you update us whether 2d works?

This looks like a numba related error to me, although I cannot make sense of the traceback.

Full error traceback:

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
AssertionError: Sizes of $900binary_subscr.15, $926binary_subscr.26 do not match on [C:\Workspace\sktime\sktime\transformations\panel\rocket\_multirocket_multi_numba.py](file:///C:/Workspace/sktime/sktime/transformations/panel/rocket/_multirocket_multi_numba.py) (736)

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

SystemError                               Traceback (most recent call last)
Cell In[4], line 4
      1 from sktime.classification.kernel_based import RocketClassifier
      3 clf = RocketClassifier(num_kernels=500, rocket_transform='multirocket', use_multivariate='yes', n_jobs=-1)
----> 4 clf.fit(X_train, y_train)

File [C:\Workspace\sktime\sktime\classification\base.py:202](file:///C:/Workspace/sktime/sktime/classification/base.py:202), in BaseClassifier.fit(self, X, y)
    [197](file:///c%3A/Workspace/sktime/sktime/classification/base.py?line=196)         raise AttributeError(
    [198](file:///c%3A/Workspace/sktime/sktime/classification/base.py?line=197)             "self.n_jobs must be set if capability:multithreading is True"
    [199](file:///c%3A/Workspace/sktime/sktime/classification/base.py?line=198)         )
    [201](file:///c%3A/Workspace/sktime/sktime/classification/base.py?line=200) # pass coerced and checked data to inner _fit
--> [202](file:///c%3A/Workspace/sktime/sktime/classification/base.py?line=201) self._fit(X, y)
    [203](file:///c%3A/Workspace/sktime/sktime/classification/base.py?line=202) self.fit_time_ = int(round(time.time() * 1000)) - start
    [205](file:///c%3A/Workspace/sktime/sktime/classification/base.py?line=204) # this should happen last

File [C:\Workspace\sktime\sktime\classification\_delegate.py:65](file:///C:/Workspace/sktime/sktime/classification/_delegate.py:65), in _DelegatedClassifier._fit(self, X, y)
     [41](file:///c%3A/Workspace/sktime/sktime/classification/_delegate.py?line=40) """Fit time series classifier to training data.
     [42](file:///c%3A/Workspace/sktime/sktime/classification/_delegate.py?line=41) 
     [43](file:///c%3A/Workspace/sktime/sktime/classification/_delegate.py?line=42) private _fit containing the core logic, called from fit
   (...)
     [62](file:///c%3A/Workspace/sktime/sktime/classification/_delegate.py?line=61) self : Reference to self.
     [63](file:///c%3A/Workspace/sktime/sktime/classification/_delegate.py?line=62) """
     [64](file:///c%3A/Workspace/sktime/sktime/classification/_delegate.py?line=63) estimator = self._get_delegate()
---> [65](file:///c%3A/Workspace/sktime/sktime/classification/_delegate.py?line=64) estimator.fit(X=X, y=y)
     [66](file:///c%3A/Workspace/sktime/sktime/classification/_delegate.py?line=65) return self

File [C:\Workspace\sktime\sktime\classification\base.py:202](file:///C:/Workspace/sktime/sktime/classification/base.py:202), in BaseClassifier.fit(self, X, y)
    [197](file:///c%3A/Workspace/sktime/sktime/classification/base.py?line=196)         raise AttributeError(
    [198](file:///c%3A/Workspace/sktime/sktime/classification/base.py?line=197)             "self.n_jobs must be set if capability:multithreading is True"
    [199](file:///c%3A/Workspace/sktime/sktime/classification/base.py?line=198)         )
    [201](file:///c%3A/Workspace/sktime/sktime/classification/base.py?line=200) # pass coerced and checked data to inner _fit
--> [202](file:///c%3A/Workspace/sktime/sktime/classification/base.py?line=201) self._fit(X, y)
    [203](file:///c%3A/Workspace/sktime/sktime/classification/base.py?line=202) self.fit_time_ = int(round(time.time() * 1000)) - start
    [205](file:///c%3A/Workspace/sktime/sktime/classification/base.py?line=204) # this should happen last

File [C:\Workspace\sktime\sktime\classification\compose\_pipeline.py:522](file:///C:/Workspace/sktime/sktime/classification/compose/_pipeline.py:522), in SklearnClassifierPipeline._fit(self, X, y)
    [504](file:///c%3A/Workspace/sktime/sktime/classification/compose/_pipeline.py?line=503) def _fit(self, X, y):
    [505](file:///c%3A/Workspace/sktime/sktime/classification/compose/_pipeline.py?line=504)     """Fit time series classifier to training data.
    [506](file:///c%3A/Workspace/sktime/sktime/classification/compose/_pipeline.py?line=505) 
    [507](file:///c%3A/Workspace/sktime/sktime/classification/compose/_pipeline.py?line=506)     core logic
   (...)
    [520](file:///c%3A/Workspace/sktime/sktime/classification/compose/_pipeline.py?line=519)     creates fitted model (attributes ending in "_")
    [521](file:///c%3A/Workspace/sktime/sktime/classification/compose/_pipeline.py?line=520)     """
--> [522](file:///c%3A/Workspace/sktime/sktime/classification/compose/_pipeline.py?line=521)     Xt = self.transformers_.fit_transform(X=X, y=y)
    [523](file:///c%3A/Workspace/sktime/sktime/classification/compose/_pipeline.py?line=522)     Xt_sklearn = self._convert_X_to_sklearn(Xt)
    [524](file:///c%3A/Workspace/sktime/sktime/classification/compose/_pipeline.py?line=523)     self.classifier_.fit(Xt_sklearn, y)

File [C:\Workspace\sktime\sktime\transformations\base.py:621](file:///C:/Workspace/sktime/sktime/transformations/base.py:621), in BaseTransformer.fit_transform(self, X, y)
    [556](file:///c%3A/Workspace/sktime/sktime/transformations/base.py?line=555) """Fit to data, then transform it.
    [557](file:///c%3A/Workspace/sktime/sktime/transformations/base.py?line=556) 
    [558](file:///c%3A/Workspace/sktime/sktime/transformations/base.py?line=557) Fits the transformer to X and y and returns a transformed version of X.
   (...)
    [617](file:///c%3A/Workspace/sktime/sktime/transformations/base.py?line=616)         Example: i-th instance of the output is the i-th window running over `X`
    [618](file:///c%3A/Workspace/sktime/sktime/transformations/base.py?line=617) """
    [619](file:///c%3A/Workspace/sktime/sktime/transformations/base.py?line=618) # Non-optimized default implementation; override when a better
    [620](file:///c%3A/Workspace/sktime/sktime/transformations/base.py?line=619) # method is possible for a given algorithm.
--> [621](file:///c%3A/Workspace/sktime/sktime/transformations/base.py?line=620) return self.fit(X, y).transform(X, y)

File [C:\Workspace\sktime\sktime\transformations\base.py:535](file:///C:/Workspace/sktime/sktime/transformations/base.py:535), in BaseTransformer.transform(self, X, y)
    [532](file:///c%3A/Workspace/sktime/sktime/transformations/base.py?line=531) X_inner, y_inner, metadata = self._check_X_y(X=X, y=y, return_metadata=True)
    [534](file:///c%3A/Workspace/sktime/sktime/transformations/base.py?line=533) if not isinstance(X_inner, VectorizedDF):
--> [535](file:///c%3A/Workspace/sktime/sktime/transformations/base.py?line=534)     Xt = self._transform(X=X_inner, y=y_inner)
    [536](file:///c%3A/Workspace/sktime/sktime/transformations/base.py?line=535) else:
    [537](file:///c%3A/Workspace/sktime/sktime/transformations/base.py?line=536)     # otherwise we call the vectorized version of predict
    [538](file:///c%3A/Workspace/sktime/sktime/transformations/base.py?line=537)     Xt = self._vectorize("transform", X=X_inner, y=y_inner)

File [C:\Workspace\sktime\sktime\transformations\compose\_pipeline.py:302](file:///C:/Workspace/sktime/sktime/transformations/compose/_pipeline.py:302), in TransformerPipeline._transform(self, X, y)
    [300](file:///c%3A/Workspace/sktime/sktime/transformations/compose/_pipeline.py?line=299) for _, transformer in self.steps_:
    [301](file:///c%3A/Workspace/sktime/sktime/transformations/compose/_pipeline.py?line=300)     if not self.get_tag("fit_is_empty", False):
--> [302](file:///c%3A/Workspace/sktime/sktime/transformations/compose/_pipeline.py?line=301)         Xt = transformer.transform(X=Xt, y=y)
    [303](file:///c%3A/Workspace/sktime/sktime/transformations/compose/_pipeline.py?line=302)     else:
    [304](file:///c%3A/Workspace/sktime/sktime/transformations/compose/_pipeline.py?line=303)         Xt = transformer.fit_transform(X=Xt, y=y)

File [C:\Workspace\sktime\sktime\transformations\base.py:535](file:///C:/Workspace/sktime/sktime/transformations/base.py:535), in BaseTransformer.transform(self, X, y)
    [532](file:///c%3A/Workspace/sktime/sktime/transformations/base.py?line=531) X_inner, y_inner, metadata = self._check_X_y(X=X, y=y, return_metadata=True)
    [534](file:///c%3A/Workspace/sktime/sktime/transformations/base.py?line=533) if not isinstance(X_inner, VectorizedDF):
--> [535](file:///c%3A/Workspace/sktime/sktime/transformations/base.py?line=534)     Xt = self._transform(X=X_inner, y=y_inner)
    [536](file:///c%3A/Workspace/sktime/sktime/transformations/base.py?line=535) else:
    [537](file:///c%3A/Workspace/sktime/sktime/transformations/base.py?line=536)     # otherwise we call the vectorized version of predict
    [538](file:///c%3A/Workspace/sktime/sktime/transformations/base.py?line=537)     Xt = self._vectorize("transform", X=X_inner, y=y_inner)

File [C:\Workspace\sktime\sktime\transformations\panel\rocket\_multirocket_multivariate.py:173](file:///C:/Workspace/sktime/sktime/transformations/panel/rocket/_multirocket_multivariate.py:173), in MultiRocketMultivariate._transform(self, X, y)
    [170](file:///c%3A/Workspace/sktime/sktime/transformations/panel/rocket/_multirocket_multivariate.py?line=169)     n_jobs = self.n_jobs
    [171](file:///c%3A/Workspace/sktime/sktime/transformations/panel/rocket/_multirocket_multivariate.py?line=170) set_num_threads(n_jobs)
--> [173](file:///c%3A/Workspace/sktime/sktime/transformations/panel/rocket/_multirocket_multivariate.py?line=172) X = _transform(
    [174](file:///c%3A/Workspace/sktime/sktime/transformations/panel/rocket/_multirocket_multivariate.py?line=173)     X,
    [175](file:///c%3A/Workspace/sktime/sktime/transformations/panel/rocket/_multirocket_multivariate.py?line=174)     _X1,
    [176](file:///c%3A/Workspace/sktime/sktime/transformations/panel/rocket/_multirocket_multivariate.py?line=175)     self.parameter,
    [177](file:///c%3A/Workspace/sktime/sktime/transformations/panel/rocket/_multirocket_multivariate.py?line=176)     self.parameter1,
    [178](file:///c%3A/Workspace/sktime/sktime/transformations/panel/rocket/_multirocket_multivariate.py?line=177)     self.n_features_per_kernel,
    [179](file:///c%3A/Workspace/sktime/sktime/transformations/panel/rocket/_multirocket_multivariate.py?line=178) )
    [180](file:///c%3A/Workspace/sktime/sktime/transformations/panel/rocket/_multirocket_multivariate.py?line=179) X = np.nan_to_num(X)
    [182](file:///c%3A/Workspace/sktime/sktime/transformations/panel/rocket/_multirocket_multivariate.py?line=181) set_num_threads(prev_threads)

SystemError:  returned a result with an exception set

I have reproduced the error using the exact data, on windows, python 3.11, numba 0.57.1.

Versions:

System:
    python: 3.11.4 | packaged by Anaconda, Inc. | (main, Jul  5 2023, 13:47:18) [MSC v.1916 64 bit (AMD64)]
executable: [c:\ProgramData\Anaconda3\envs\sktime-skbase-numba-311\python.exe](file:///C:/ProgramData/Anaconda3/envs/sktime-skbase-numba-311/python.exe)
   machine: Windows-10-10.0.22621-SP0

Python dependencies:
          pip: 23.2.1
       sktime: 0.21.0
      sklearn: 1.3.0
       skbase: 0.4.6
        numpy: 1.24.4
        scipy: 1.11.1
       pandas: 2.0.3
   matplotlib: None
       joblib: 1.3.1
  statsmodels: None
        numba: 0.57.1
     pmdarima: None
      tsfresh: None
   tensorflow: None
tensorflow_probability: None

Useful code to load the files:

import numpy as np

PATH = "npy_files_are_here"

X_train = np.load(PATH + "X_train.npy")
y_train = np.load(PATH + "y_train.npy")

can you check:

  • is any entry nan or infinite?
  • if you generate a random numpy array of same size and pass it, do you still get the error?

Thanks!

Error only occurs with my data.

Well, that’s odd. If you can’t share your data, could you share the output of the following?

print(type(X_train))
print(X_train.dtype)
print(X_train.shape)

Well, that looks weird. Looks like some numba failure?

May I ask for diagnosis:

  • can you generate the error with sktime dummy data or random numpy arrays? Or is it only happening for your data?
  • can you please report your package versions, following the instructions in the bug reporting issue template?