我正在尝试对时间序列数据进行分类,并遇到了 sktime,它提供了许多可用于对时间序列进行分类的算法。
但是,我只设法让 RandomIntervalSpectralForest 运行。所有其他算法都给我以下错误:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_17944/639170790.py in <module>
12 cboss_params={"n_parameter_samples": 25, "max_ensemble_size": 5},
13 )
---> 14 clf.fit(X_sk, y)
~\anaconda3\lib\site-packages\pandas\core\series.py in __init__(self, data, index, dtype, name, copy, fastpath)
353 name = ibase.maybe_extract_name(name, data, type(self))
354
--> 355 if is_empty_data(data) and dtype is None:
356 # gh-17261
357 warnings.warn(
~\anaconda3\lib\site-packages\pandas\core\construction.py in is_empty_data(data)
794 is_none = data is None
795 is_list_like_without_dtype = is_list_like(data) and not hasattr(data, "dtype")
--> 796 is_simple_empty = is_list_like_without_dtype and not data
797 return is_none or is_simple_empty
798
~\anaconda3\lib\site-packages\pandas\core\generic.py in __nonzero__(self)
1535 @final
1536 def __nonzero__(self):
-> 1537 raise ValueError(
1538 f"The truth value of a {type(self).__name__} is ambiguous. "
1539 "Use a.empty, a.bool(), a.item(), a.any() or a.all()."
ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
我首先尝试运行的代码采用普通 csv 并将其转换为 pandas 数据框,其中行用于观察,列作为时间点。然后我正在使用 sktime 的实用程序函数将此数据帧转换为 sktime 可以使用并嵌套的数据帧:
X_sk = from_2d_array_to_nested(X)
如果我现在正在运行:
from sktime.classification.hybrid import HIVECOTEV2
hc2 = HIVECOTEV2()
hc2.fit(X_sk, pd.Series(y))
我收到上述错误。然而,RandomIntervalSpectralForest 使用完全相同的数据集运行。我已经将https://www.sktime.org/en/stable/api_reference/auto_generated/sktime.classification.hybrid.HIVECOTEV1.html上给出的示例代码和数据集与我的数据集进行了比较,找不到任何区别。示例代码为我运行,但我不知道为什么我的代码不运行。
我正在尝试使用另一个数据集重新创建问题,并在我有一个工作示例后编辑该帖子。