biolab / orange3-timeseries

🍊 :chart_with_upwards_trend: Orange add-on for analyzing, visualizing, manipulating, and forecasting time series data.
Other
62 stars 41 forks source link

Moving Transform: fails internally on sparse #276

Open ajdapretnar opened 9 months ago

ajdapretnar commented 9 months ago
Timeseries version

0.6.2

Orange version

3.37.0.dev

Expected behavior

Moving Transform either:

Actual behavior

Moving Transform silently fails.

Steps to reproduce the behavior

Corpus - Bag of Words - Form Timeseries (sequence) - Moving Transform

Additional info (worksheets, data, screenshots, ...)

StackTrace:

2024-02-29 11:44:36,550:ERROR:resdk: 
Traceback (most recent call last):
  File "/Users/ajda/orange/orange3-timeseries/orangecontrib/timeseries/widgets/owmovingtransform.py", line 323, in _checkbox_changed
    self.commit.deferred()
  File "/Users/ajda/orange/orange-widget-base/orangewidget/gui.py", line 2006, in conditional_commit
    do_commit()
  File "/Users/ajda/orange/orange-widget-base/orangewidget/gui.py", line 2014, in do_commit
    commit.call()
  File "/Users/ajda/orange/orange-widget-base/orangewidget/gui.py", line 1879, in call
    acting_func(instance)
  File "/Users/ajda/orange/orange3-timeseries/orangecontrib/timeseries/widgets/owmovingtransform.py", line 375, in commit
    ts = [self._compute_sliding_window,
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ajda/orange/orange3-timeseries/orangecontrib/timeseries/widgets/owmovingtransform.py", line 425, in _compute_sliding_window
    add_aggregates(attr, column)
  File "/Users/ajda/orange/orange3-timeseries/orangecontrib/timeseries/widgets/owmovingtransform.py", line 416, in add_aggregates
    agg_column = agg.transform(column, self.window_width, 1)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ajda/orange/orange3-timeseries/orangecontrib/timeseries/aggregate.py", line 17, in moving_sum
    s = np.nancumsum(x)
        ^^^^^^^^^^^^^^^
  File "/Users/ajda/miniconda3/envs/o3/lib/python3.11/site-packages/numpy/lib/nanfunctions.py", line 876, in nancumsum
    a, mask = _replace_nan(a, 0)
              ^^^^^^^^^^^^^^^^^^
  File "/Users/ajda/miniconda3/envs/o3/lib/python3.11/site-packages/numpy/lib/nanfunctions.py", line 100, in _replace_nan
    mask = np.not_equal(a, a, dtype=bool)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ajda/miniconda3/envs/o3/lib/python3.11/site-packages/scipy/sparse/_base.py", line 332, in __bool__
    raise ValueError("The truth value of an array with more than one "
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all().
ajdapretnar commented 9 months ago

Potentially, also Form Timeseries fails on sparse. ~Investigate~. Perhaps Form Timeseries can do the proper converting to non-sparse.

Another Moving Transform issue:

Traceback (most recent call last):
  File "/Users/ajda/miniconda3/envs/o3/lib/python3.11/site-packages/orangecanvas/scheme/signalmanager.py", line 1180, in __process_next
    if self.__process_next_helper(use_max_active=True):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ajda/miniconda3/envs/o3/lib/python3.11/site-packages/orangecanvas/scheme/signalmanager.py", line 1218, in __process_next_helper
    self.process_node(selected_node)
  File "/Users/ajda/miniconda3/envs/o3/lib/python3.11/site-packages/orangecanvas/scheme/signalmanager.py", line 846, in process_node
    self.send_to_node(node, signals_in)
  File "/Users/ajda/orange/orange-widget-base/orangewidget/workflow/widgetsscheme.py", line 806, in send_to_node
    self.process_signals_for_widget(node, widget, signals)
  File "/Users/ajda/orange/orange-widget-base/orangewidget/workflow/widgetsscheme.py", line 820, in process_signals_for_widget
    process_signals_for_widget(widget, signals, workflow)
  File "/Users/ajda/miniconda3/envs/o3/lib/python3.11/functools.py", line 909, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ajda/orange/orange-widget-base/orangewidget/workflow/widgetsscheme.py", line 923, in process_signals_for_widget
    process_signal_input(input_meta, widget, signal, workflow)
  File "/Users/ajda/miniconda3/envs/o3/lib/python3.11/functools.py", line 909, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ajda/orange/orange-widget-base/orangewidget/workflow/widgetsscheme.py", line 886, in process_signal_input_default
    notify_input_helper(
  File "/Users/ajda/miniconda3/envs/o3/lib/python3.11/functools.py", line 909, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ajda/orange/orange-widget-base/orangewidget/utils/signals.py", line 735, in set_input_helper
    handler(*args)
  File "/Users/ajda/orange/orange-widget-base/orangewidget/utils/signals.py", line 208, in summarize_wrapper
    method(widget, value)
  File "/Users/ajda/orange/orange3-timeseries/orangecontrib/timeseries/widgets/owmovingtransform.py", line 362, in set_data
    self.commit.now()
  File "/Users/ajda/orange/orange-widget-base/orangewidget/gui.py", line 2014, in do_commit
    commit.call()
  File "/Users/ajda/orange/orange-widget-base/orangewidget/gui.py", line 1879, in call
    acting_func(instance)
  File "/Users/ajda/orange/orange3-timeseries/orangecontrib/timeseries/widgets/owmovingtransform.py", line 375, in commit
    ts = [self._compute_sliding_window,
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ajda/orange/orange3-timeseries/orangecontrib/timeseries/widgets/owmovingtransform.py", line 441, in _compute_sliding_window
    return Timeseries.from_numpy(
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ajda/orange/orange3-timeseries/orangecontrib/timeseries/timeseries.py", line 176, in from_numpy
    return cls.convert_from_data_table(table, time_attr=time_attr)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ajda/orange/orange3-timeseries/orangecontrib/timeseries/timeseries.py", line 156, in convert_from_data_table
    if new.base is orig:
       ^^^^^^^^
AttributeError: 'csc_matrix' object has no attribute 'base'
ajdapretnar commented 9 months ago

Yet another issue. This happens after introducing Select Columns between BoW and Form TS, which outputs DENSE X.

TypeError: float() argument must be a string or a real number, not 'csr_matrix'

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

Traceback (most recent call last):
  File "/Users/ajda/miniconda3/envs/o3/lib/python3.11/site-packages/orangecanvas/scheme/signalmanager.py", line 1180, in __process_next
    if self.__process_next_helper(use_max_active=True):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ajda/miniconda3/envs/o3/lib/python3.11/site-packages/orangecanvas/scheme/signalmanager.py", line 1218, in __process_next_helper
    self.process_node(selected_node)
  File "/Users/ajda/miniconda3/envs/o3/lib/python3.11/site-packages/orangecanvas/scheme/signalmanager.py", line 846, in process_node
    self.send_to_node(node, signals_in)
  File "/Users/ajda/orange/orange-widget-base/orangewidget/workflow/widgetsscheme.py", line 806, in send_to_node
    self.process_signals_for_widget(node, widget, signals)
  File "/Users/ajda/orange/orange-widget-base/orangewidget/workflow/widgetsscheme.py", line 820, in process_signals_for_widget
    process_signals_for_widget(widget, signals, workflow)
  File "/Users/ajda/miniconda3/envs/o3/lib/python3.11/functools.py", line 909, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ajda/orange/orange-widget-base/orangewidget/workflow/widgetsscheme.py", line 923, in process_signals_for_widget
    process_signal_input(input_meta, widget, signal, workflow)
  File "/Users/ajda/miniconda3/envs/o3/lib/python3.11/functools.py", line 909, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ajda/orange/orange-widget-base/orangewidget/workflow/widgetsscheme.py", line 886, in process_signal_input_default
    notify_input_helper(
  File "/Users/ajda/miniconda3/envs/o3/lib/python3.11/functools.py", line 909, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ajda/orange/orange-widget-base/orangewidget/utils/signals.py", line 735, in set_input_helper
    handler(*args)
  File "/Users/ajda/orange/orange-widget-base/orangewidget/utils/signals.py", line 208, in summarize_wrapper
    method(widget, value)
  File "/Users/ajda/orange/orange3-timeseries/orangecontrib/timeseries/widgets/owmovingtransform.py", line 362, in set_data
    self.commit.now()
  File "/Users/ajda/orange/orange-widget-base/orangewidget/gui.py", line 2014, in do_commit
    commit.call()
  File "/Users/ajda/orange/orange-widget-base/orangewidget/gui.py", line 1879, in call
    acting_func(instance)
  File "/Users/ajda/orange/orange3-timeseries/orangecontrib/timeseries/widgets/owmovingtransform.py", line 375, in commit
    ts = [self._compute_sliding_window,
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ajda/orange/orange3-timeseries/orangecontrib/timeseries/widgets/owmovingtransform.py", line 441, in _compute_sliding_window
    return Timeseries.from_numpy(
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ajda/orange/orange3-timeseries/orangecontrib/timeseries/timeseries.py", line 175, in from_numpy
    table = Table.from_numpy(*args, **kwargs)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ajda/orange/orange3/Orange/data/table.py", line 919, in from_numpy
    X, Y, W = _check_arrays(X, Y, W, dtype='float64')
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ajda/orange/orange3/Orange/data/table.py", line 2455, in _check_arrays
    array = np.asarray(array, dtype=dtype)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: setting an array element with a sequence.
ajdapretnar commented 9 months ago

Data for convenience: test-text.xlsx