Skip to content

frozen mlfinlab.util.volatility #548

@urrx101

Description

@urrx101

Image

I encountered a couple of frozen module warning.
Earlier today, it was from from mlfinlab.ensemble.sb_bagging import SequentiallyBootstrappedBaggingClassifier
Most recently, from get_daily_vol function. It worked perfectly a couple of weeks ago.

Below is the error.
I also attached a screenshot.

TypeError Traceback (most recent call last)
Cell In[4], line 2
1 # Filter events using the CUSUM filter
----> 2 daily_vol = get_daily_vol(close = data["Close"], lookback = 50)
3 cusum_events = cusum_filter(data["Close"], threshold = daily_vol.mean() * 0.5)
5 # Do triple-barrier labelling

File :41, in get_daily_vol(close, lookback)

File c:\Users\Charles\miniconda3\envs\mlfinlab\Lib\site-packages\pandas\core\ops\common.py:81, in _unpack_zerodim_and_defer..new_method(self, other)
77 return NotImplemented
79 other = item_from_zerodim(other)
---> 81 return method(self, other)

File c:\Users\Charles\miniconda3\envs\mlfinlab\Lib\site-packages\pandas\core\arraylike.py:194, in OpsMixin.sub(self, other)
192 @unpack_zerodim_and_defer("sub")
193 def sub(self, other):
--> 194 return self._arith_method(other, operator.sub)

File c:\Users\Charles\miniconda3\envs\mlfinlab\Lib\site-packages\pandas\core\indexes\range.py:979, in RangeIndex._arith_method(self, other, op)
975 return NotImplemented
976 elif isinstance(other, (timedelta, np.timedelta64)):
977 # GH#19333 is_integer evaluated True on timedelta64,
978 # so we need to catch these explicitly
--> 979 return super()._arith_method(other, op)
980 elif is_timedelta64_dtype(other):
981 # Must be an np.ndarray; GH#22390
982 return super()._arith_method(other, op)

File c:\Users\Charles\miniconda3\envs\mlfinlab\Lib\site-packages\pandas\core\indexes\base.py:6814, in Index._arith_method(self, other, op)
6804 if (
6805 isinstance(other, Index)
6806 and is_object_dtype(other.dtype)
(...)
6810 # a chance to implement ops before we unwrap them.
6811 # See pandas-dev/pandas#31109
6812 return NotImplemented
-> 6814 return super()._arith_method(other, op)

File c:\Users\Charles\miniconda3\envs\mlfinlab\Lib\site-packages\pandas\core\base.py:1348, in IndexOpsMixin._arith_method(self, other, op)
1345 rvalues = ensure_wrapped_if_datetimelike(rvalues)
1347 with np.errstate(all="ignore"):
-> 1348 result = ops.arithmetic_op(lvalues, rvalues, op)
1350 return self._construct_result(result, name=res_name)

File c:\Users\Charles\miniconda3\envs\mlfinlab\Lib\site-packages\pandas\core\ops\array_ops.py:217, in arithmetic_op(left, right, op)
204 # NB: We assume that extract_array and ensure_wrapped_if_datetimelike
205 # have already been called on left and right,
206 # and maybe_prepare_scalar_for_op has already been called on right
207 # We need to special-case datetime64/timedelta64 dtypes (e.g. because numpy
208 # casts integer dtypes to timedelta64 when operating with timedelta64 - GH#22390)
210 if (
211 should_extension_dispatch(left, right)
212 or isinstance(right, (Timedelta, BaseOffset, Timestamp))
(...)
215 # Timedelta/Timestamp and other custom scalars are included in the check
216 # because numexpr will fail on it, see GH#31457
--> 217 res_values = op(left, right)
218 else:
219 # TODO we should handle EAs consistently and move this check before the if/else
220 # (pandas-dev/pandas#41165)
221 _bool_arith_check(op, left, right)

TypeError: unsupported operand type(s) for -: 'numpy.ndarray' and 'Timedelta'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions