ChristianSch/skml

fix support for sparse matrices

ChristianSch opened this issue · 2 comments

A good starting point would be to look at the failing tests regarding sparse matrices here.

sample_down_label_space of course has the same problem:

# class of "y": <class 'scipy.sparse.lil.lil_matrix'>
Traceback (most recent call last):
…
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 52, in _wrapfunc
    return getattr(obj, method)(*args, **kwds)
  File "/usr/lib/python3.6/site-packages/scipy/sparse/base.py", line 647, in __getattr__
    raise AttributeError(attr + " not found")
AttributeError: take not found

During handling of the above exception, another exception occurred:

  File "experimental_framework.py", line 117, in load_data
    y = sample_down_label_space(y, 10)
  File "/home/user/Documents/dev/skml/skml/datasets/sample_down_label_space.py", line 36, in sample_down_label_space
    return np.take(y, sampled_indices, axis=1)
  File "/usr/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 159, in take
    return _wrapfunc(a, 'take', indices, axis=axis, out=out, mode=mode)
  File "/usr/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 62, in _wrapfunc
    return _wrapit(obj, method, *args, **kwds)
  File "/usr/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 42, in _wrapit
    result = getattr(asarray(obj), method)(*args, **kwds)
numpy.core._internal.AxisError: axis 1 is out of bounds for array of dimension 1

Problem is, that not all formats of scipy sparse matrices support indexing (like coo or dok). Thus the indexing of columns to take might be a tad more complex than thought.