Unhashable type: 'DataArray' error when using sklearn_xarray Splitter()

Viewed 431

I'm discovering the xarray and sklearn_xarray Python libraries and I can't figure out how to use the Splitter() function. I'm working on this DataArray (included in the sklearn_xarray library):

import numpy as np
from sklearn_xarray.preprocessing import Splitter
from sklearn_xarray.datasets import load_wisdm_dataarray

X = load_wisdm_dataarray()

This DataArray contains raw accelerometer data and the WISDM activity prediction dataset which contains the activities walking, jogging, walking upstairs, walking downstairs, sitting and standing from 36 different subjects :

print(X)

<xarray.DataArray (sample: 1098204, axis: 3)>
array([[-0.6946377 , 12.680544  ,  0.50395286],
       [ 5.012288  , 11.264028  ,  0.95342433],
       [ 4.903325  , 10.882658  , -0.08172209],
       ...,
       [ 9.08      , -1.38      ,  1.69      ],
       [ 9.        , -1.46      ,  1.73      ],
       [ 8.88      , -1.33      ,  1.61      ]])
Coordinates:
    subject   (sample) int64 33 33 33 33 33 33 33 33 ... 19 19 19 19 19 19 19 19
    activity  (sample) object 'Jogging' 'Jogging' ... 'Sitting' 'Sitting'
  * sample    (sample) datetime64[ns] 1970-01-01 ... 1970-01-01T15:15:10.150000
  * axis      (axis) <U1 'x' 'y' 'z'

Before using some machine learning algorithms to predict the activities, I want to do some pre-preprocessing on the data by using the Splitter() function from sklearn_xarray. However, I get this error:

Splitter(new_dim="timepoint",new_len=30,groupby=["subject","activity"]).fit_transform(X)

TypeError: unhashable type: 'DataArray'

I have been trying to change the parameters of the Splitter() function but nothing changes, I still get this error. Does anyone know how to fix it ?

Moreover, this example comes from the sklearn_xarray documentation here. I think it could be useful.

Thanks everyone !

0 Answers
Related