tslearn.utils.to_time_series_dataset¶
- tslearn.utils.to_time_series_dataset(dataset, dtype=<class 'float'>, be=None)[source]¶
转换时间序列数据集,使其适应
tslearn模型中使用的格式。- Parameters:
- datasetarray-like, shape=(n_ts, sz, d) or (n_ts, sz) or (sz,)
要转换的时间序列数据集。单个时间序列将自动包装成一个包含单个条目的数据集。
- dtypedata type (default: float)
返回数据集的数据类型。
- Returns:
- dataset_outarray-like, shape=(n_ts, sz, d)
时间序列的转换数据集。
另请参阅
to_time_series转换单个时间序列
示例
>>> to_time_series_dataset([[1, 2]]) array([[[1.], [2.]]]) >>> to_time_series_dataset([1, 2]) array([[[1.], [2.]]]) >>> to_time_series_dataset([[1, 2], [1, 4, 3]]) array([[[ 1.], [ 2.], [nan]], [[ 1.], [ 4.], [ 3.]]]) >>> to_time_series_dataset([]).shape (0, 0, 0)