gluonts.zebras 包#
- class gluonts.zebras.BatchSplitFrame(_past: 'dict', _future: 'dict', index: 'List[Optional[Periods]]', static: 'dict', past_length: 'int', future_length: 'int', tdims: 'dict', metadata: 'List[Optional[dict]]', _pad: 'List[Pad]')[source]#
基类:
object
- property batch_size#
- property future#
- future_length: int#
- index: List[Optional[gluonts.zebras._period.Periods]]#
- metadata: List[Optional[dict]]#
- property past#
- past_length: int#
- static: dict#
- tdims: dict#
- class gluonts.zebras.BatchTimeFrame(columns: 'dict', index: 'Collection[Optional[Periods]]', static: 'dict', length: 'int', tdims: 'dict', metadata: 'Collection[Optional[dict]]', _pad: 'Collection[Pad]')[source]#
基类:
object
- property batch_size#
- columns: dict#
- index: Collection[Optional[gluonts.zebras._period.Periods]]#
- length: int#
- metadata: Collection[Optional[dict]]#
- static: dict#
- tdims: dict#
- class gluonts.zebras.BatchTimeSeries(values: 'np.ndarray', index: 'List[Optional[Periods]]', name: 'List[Optional[str]]', tdim: 'int', metadata: 'List[Optional[dict]]', _pad: 'List[Pad]')[source]#
基类:
gluonts.zebras._base.TimeBase
- property batch_size#
- index: List[Optional[gluonts.zebras._period.Periods]]#
- metadata: List[Optional[dict]]#
- name: List[Optional[str]]#
- pad(value, left: int = 0, right: int = 0) gluonts.zebras._time_series.TimeSeries [source]#
- property shape: Tuple[int, ...]#
- tdim: int#
- values: numpy.ndarray#
- class gluonts.zebras.Freq(name: str, n: int, suffix: Optional[str] = None)[source]#
基类:
object
表示频率(例如 n 天)的类。
注意:使用
freq
构造Freq
的实例。我们使用 pandas 中的频率别名,而非 numpy 定义的频率名称。例如,分钟频率的名称是“min”或“T”,而“m”和“M”表示月度频率。相比之下,numpy 使用“m”表示分钟,使用“M”表示月度。此外,pandas 定义了一些 numpy 中不存在的频率,例如季度频率。
然而,在内部我们使用
numpy.datetime64
对象,因此我们也必须支持 numpy 的频率名称。为此,我们通常使用基本频率(乘数为 1),因为否则 numpy 会对我们不想要的时间戳进行对齐。每周频率需要特别处理,因为 numpy 计算自 1970 年 1 月 1 日星期四以来的周数,并使用星期四对时间戳进行对齐。因此,我们在内部使用每日频率并对齐到星期一。
- align(timestamp: numpy.datetime64) numpy.datetime64 [source]#
根据频率对齐
timestamp
。例如,对于每日频率,任何落在同一天的时间戳都将对齐到相同的值。
- classmethod from_pandas(freq) gluonts.zebras._freq.Freq [source]#
- n: int#
- name: str#
- property np_freq: Tuple[str, int]#
- property step#
- suffix: Optional[str] = None#
- class gluonts.zebras.Period(data: 'np.datetime64', freq: 'Freq')[source]#
基类:
gluonts.zebras._period._BasePeriod
- data: numpy.datetime64#
- property shape: Tuple[int, ...]#
- class gluonts.zebras.Periods(data: 'np.ndarray', freq: 'Freq')[source]#
基类:
gluonts.zebras._period._BasePeriod
- data: numpy.ndarray#
- property end: gluonts.zebras._period.Period#
最后一个时间戳。
>>> p = periods("2021", "D", 365) >>> assert p.end == period("2021-12-31", "D")
- extend(count: int) gluonts.zebras._period.Periods [source]#
包含
count
个未来时间戳的副本。>>> p = periods("2021", "D", 365) >>> assert p.extend(5) == periods("2021", "D", 370)
- future(count: int) gluonts.zebras._period.Periods [source]#
接下来的
count
个时间戳。>>> p = periods("2021", "D", 365) >>> assert p.future(5) == periods("2022-01-01", "D", 5)
- head(count: int) gluonts.zebras._period.Periods [source]#
前
count
个时间戳。>>> p = periods("2021", "D", 365) >>> assert p.head(5) == periods("2021-01-01", "D", 5)
- index_of(period: Union[str, gluonts.zebras._period.Period])[source]#
返回
period
的索引>>> p = periods("2021", "D", 365) >>> assert p.index_of(period("2021-02-01", "D")) == 31
- past(count: int) gluonts.zebras._period.Periods [source]#
前
count
个时间戳。>>> p = periods("2021", "D", 365) >>> assert p.past(5) == periods("2020-12-27", "D", 5)
- prepend(count: int) gluonts.zebras._period.Periods [source]#
包含
count
个过去时间戳的副本。>>> p = periods("2021", "D", 365) >>> assert p.prepend(5) == periods("2020-12-27", "D", 370)
- property shape: Tuple[int, ...]#
- property start: gluonts.zebras._period.Period#
- tail(count: int) gluonts.zebras._period.Periods [source]#
最后
count
个时间戳。>>> p = periods("2021", "D", 365) >>> assert p.tail(5) == periods("2021-12-27", "D", 5)
- class gluonts.zebras.SplitFrame(_past: 'dict', _future: 'dict', index: 'Optional[Periods]', static: 'dict', past_length: 'int', future_length: 'int', tdims: 'dict', metadata: 'Optional[dict]' = None, default_tdim: 'int' = - 1, _pad: 'Pad' = Pad(left=0, right=0))[source]#
基类:
object
- default_tdim: int = -1#
- property future#
- future_length: int#
- index: Optional[gluonts.zebras._period.Periods]#
- metadata: Optional[dict] = None#
- property past#
- past_length: int#
- resize(past_length: Optional[int] = None, future_length: Optional[int] = None, pad_value=0.0) gluonts.zebras._split_frame.SplitFrame [source]#
- static: dict#
- tdims: dict#
- class gluonts.zebras.TimeFrame(columns: 'dict', index: 'Optional[Periods]', static: 'dict', length: 'int', tdims: 'dict', metadata: 'Optional[dict]' = None, default_tdim: 'int' = - 1, _pad: 'Pad' = Pad(left=0, right=0))[source]#
基类:
gluonts.zebras._base.TimeBase
- astype(type, columns=None) gluonts.zebras._time_frame.TimeFrame [source]#
- columns: dict#
- default_tdim: int = -1#
- eq_shape(other: gluonts.zebras._time_frame.TimeFrame) bool [source]#
- eq_to(other: gluonts.zebras._time_frame.TimeFrame) bool [source]#
- index: Optional[gluonts.zebras._period.Periods]#
- length: int#
- metadata: Optional[dict] = None#
- pad(value, left: int = 0, right: int = 0) gluonts.zebras._time_frame.TimeFrame [source]#
- rename(mapping=None, **kwargs)[source]#
重命名
TimeFrame
的columns
。mapping
中的键表示目标列名,例如rename({"target": "source"})
。为了方便,可以使用关键字参数 (`.rename(target=”source”))。
- rename_static(mapping=None, **kwargs)[source]#
重命名
TimeFrame
的static
字段。mapping
中的键表示目标列名,例如rename({"target": "source"})
。为了方便,可以使用关键字参数 (`.rename(target=”source”))。
- rolsplit(index, *, distance: int = 1, past_length: Optional[int] = None, future_length: Optional[int] = None, n: Optional[int] = None, pad_value=0.0)[source]#
创建过去/未来对的滚动分割。
- 参数
index – 表示生成分割的截止点的起始索引。
distance – 对移动的距离。默认为
1
。为了避免样本重叠,distance
必须至少设置为past_length
。future_length – 可选地强制未来长度。请注意,
rolsplit
永远不会填充未来范围内的值。optional – 可选地强制未来长度。请注意,
rolsplit
永远不会填充未来范围内的值。past_length – 如果提供,所有过去的对将具有
past_length
,如果需要则用pad_value
填充。optional – 如果提供,所有过去的对将具有
past_length
,如果需要则用pad_value
填充。n – 如果提供,将对的数量限制为
n
。optional – 如果提供,将对的数量限制为
n
。pad_value – 如果需要,用于填充过去的值,默认为
0.0
。
- 返回类型
zebras.SplitFrame
对象的流。
- stack(select: List[str], into: str, drop: bool = True) gluonts.zebras._time_frame.TimeFrame [source]#
- static: dict#
- tdims: dict#
- class gluonts.zebras.TimeSeries(values: 'np.ndarray', index: 'Optional[Periods]' = None, name: 'Optional[str]' = None, tdim: 'int' = - 1, metadata: 'Optional[dict]' = None, _pad: 'Pad' = Pad(left=0, right=0))[source]#
基类:
gluonts.zebras._base.TimeBase
- index: Optional[gluonts.zebras._period.Periods] = None#
- metadata: Optional[dict] = None#
- name: Optional[str] = None#
- pad(value, left: int = 0, right: int = 0) gluonts.zebras._time_series.TimeSeries [source]#
- property shape: Tuple[int, ...]#
- tdim: int = -1#
- values: numpy.ndarray#
- gluonts.zebras.freq(arg) gluonts.zebras._freq.Freq [source]#
- gluonts.zebras.period(data: Union[gluonts.zebras._period.Period, str], freq: Optional[Union[gluonts.zebras._freq.Freq, str]] = None) gluonts.zebras._period.Period [source]#
创建表示时间段的
zebras.Period
对象。- 参数
data – 表示时间段的字符串(例如,“2023-01-01”)或另一个 Period 对象。
freq – 时间段的频率,例如小时频率的“H”,默认为 None。
optional – 时间段的频率,例如小时频率的“H”,默认为 None。
- 返回类型
一个
zebras.Period
对象。
- gluonts.zebras.periods(start: Union[gluonts.zebras._period.Period, str], freq: Union[gluonts.zebras._freq.Freq, str], count: int) gluonts.zebras._period.Period [source]#
创建表示多个连续时间段的
zebras.Periods
对象。- 参数
start – 表示起始时间段的字符串(例如,“2023-01-01”)或另一个 Period 对象。
freq – 时间段的频率,例如小时频率的“H”。
count – 时间段的数量。
- 返回类型
一个
zebras.Periods
对象。
- gluonts.zebras.split_frame(full=None, *, past=None, future=None, past_length=None, future_length=None, static=None, index=None, start=None, freq=None, tdims=None, metadata=None, default_tdim=- 1)[source]#
创建一个
zebras.SplitFrame
,其中列可以是 past(过去)、future(未来)或 full(完整),涵盖过去和未来。past_length
和future_length
会尽可能从输入数据中导出,如果不存在相应数据,则默认为0
。可以显式设置这些值以强制保持一致性,或者在没有时间序列覆盖该范围的情况下提供长度。- 参数
full – 跨越过去和未来的时间序列列。
optional – 跨越过去和未来的时间序列列。
past – 仅包含过去的时间序列列。
optional – 仅包含过去的时间序列列。
future – 仅包含未来的时间序列列。
optional – 仅包含未来的时间序列列。
past_length – 设置过去部分的长度,如果未提供则从数据中导出。
optional – 设置过去部分的长度,如果未提供则从数据中导出。
future_length – 设置未来部分的长度,如果未提供则从数据中导出。
optional – 设置未来部分的长度,如果未提供则从数据中导出。
static – 与时间无关的值。
optional – 与时间无关的值。
index – 表示时间戳的
zebras.Periods
对象。必须与完整范围具有相同的长度。optional – 表示时间戳的
zebras.Periods
对象。必须与完整范围具有相同的长度。start – 表示起始时间的字符串(例如,“2023-01-01”)或
zebras.Period
对象。将使用此起始时间和指定的频率构建索引。optional – 表示起始时间的字符串(例如,“2023-01-01”)或
zebras.Period
对象。将使用此起始时间和指定的频率构建索引。freq – 用于构建索引的频率。
optional – 用于构建索引的频率。
tdims – 指定每列时间维度的字典,适用于过去、未来和完整部分。
optional – 指定每列时间维度的字典,适用于过去、未来和完整部分。
default_tdim – 默认的时间维度,默认为 -1
optional – 默认的时间维度,默认为 -1
metadata – 与 TimeFrame 关联的元数据字典,默认为 None
optional – 与 TimeFrame 关联的元数据字典,默认为 None
- 返回类型
一个
zebras.SplitFrame
对象。
- gluonts.zebras.time_frame(columns: Optional[Mapping[str, Collection]] = None, *, index: Optional[gluonts.zebras._period.Periods] = None, start: Optional[Union[gluonts.zebras._period.Period, str]] = None, freq: Optional[Union[gluonts.zebras._freq.Freq, str]] = None, static: Optional[Mapping[str, Any]] = None, tdims: Optional[Mapping[str, int]] = None, length: Optional[int] = None, default_tdim: int = - 1, metadata: Optional[Mapping] = None)[source]#
创建表示一个或多个时间序列的
zebras.TimeFrame
对象。- 参数
columns – 一个字典,其中键是表示列名的字符串,值是序列(例如,列表、numpy 数组)。所有列在时间维度上必须具有相同的长度,默认为 None。
optional – 一个字典,其中键是表示列名的字符串,值是序列(例如,列表、numpy 数组)。所有列在时间维度上必须具有相同的长度,默认为 None。
index – 表示时间戳的
zebras.Periods
对象。必须与列具有相同的长度,默认为 None。optional – 表示时间戳的
zebras.Periods
对象。必须与列具有相同的长度,默认为 None。start – 表示起始时间的字符串(例如,“2023-01-01”)或
zebras.Period
对象。将使用此起始时间和指定的频率构建索引,默认为 None。optional – 表示起始时间的字符串(例如,“2023-01-01”)或
zebras.Period
对象。将使用此起始时间和指定的频率构建索引,默认为 None。freq – 时间段的频率,例如小时频率的“H”,默认为 None。
optional – 时间段的频率,例如小时频率的“H”,默认为 None。
static – 与时间无关的特征字典,默认为 None。
optional – 与时间无关的特征字典,默认为 None。
tdims – 指定每列时间维度的字典。键应与 columns 中的键匹配。如果未指定列的时间维度,则使用 default_tdim,默认为 None。
optional – 指定每列时间维度的字典。键应与 columns 中的键匹配。如果未指定列的时间维度,则使用 default_tdim,默认为 None。
length – TimeFrame 的长度(时间维度),默认为 None。
optional – TimeFrame 的长度(时间维度),默认为 None。
default_tdim – 默认的时间维度,默认为 -1
optional – 默认的时间维度,默认为 -1
metadata – 与 TimeFrame 关联的元数据字典,默认为 None
optional – 与 TimeFrame 关联的元数据字典,默认为 None
- 返回类型
一个
zebras.TimeFrame
对象。
- gluonts.zebras.time_series(values: Collection, *, index: Optional[gluonts.zebras._period.Periods] = None, start: Optional[Union[gluonts.zebras._period.Period, str]] = None, freq: Optional[str] = None, tdim: int = - 1, name: Optional[str] = None, metadata: Optional[Dict] = None)[source]#
创建表示时间序列的
zebras.TimeSeries
对象。- 参数
values – 表示时间序列值的序列(例如,列表、numpy 数组)。
index – 表示时间戳的
zebras.Periods
对象。必须与 values 具有相同的长度,默认为 None。optional – 表示时间戳的
zebras.Periods
对象。必须与 values 具有相同的长度,默认为 None。start – 表示起始时间的字符串(例如,“2023-01-01”)或
zebras.Period
对象。将使用此起始时间和指定的频率构建索引,默认为 None。optional – 表示起始时间的字符串(例如,“2023-01-01”)或
zebras.Period
对象。将使用此起始时间和指定的频率构建索引,默认为 None。freq – 时间段的频率,例如小时频率的“H”,默认为 None。
optional – 时间段的频率,例如小时频率的“H”,默认为 None。
tdim – values 中的时间维度,默认为 -1。
optional – values 中的时间维度,默认为 -1。
name (optional) – 时间序列的描述。这将是
TimeFrame
返回时的列名。metadata – 与时间序列关联的元数据字典,默认为 None。
optional – 与时间序列关联的元数据字典,默认为 None。
- 返回类型
一个
zebras.TimeSeries
对象。