gluonts.model.forecast 模块#
- class gluonts.model.forecast.ExponentialTailApproximation(x_coord: List[float], y_coord: List[numpy.ndarray], tol: float = 1e-08)[source]#
- 基类: - object- 基于节点近似尾部函数并在查询点进行推断。可用于尾部的插值或外推。 - 参数
- x_coord – 数据点的 x 坐标,必须按升序排列。 
- y_coord – 数据点的 y 坐标 - 可以是高维 numpy 数组。 
- tol – 在执行指数外推中的除法和计算对数时的容差。 
 
 - init_exponential_tail_weights() Tuple[float, float][source]#
- 分别基于左右两个极值点初始化指数衰减尾部函数的权重。 - 返回值
- 左尾和右尾的 beta 系数。 
- 返回类型
- Tuple 
 
 - left(x: float) numpy.ndarray[source]#
- 返回在指数衰减尾部函数上进行的推断。 - 对于左尾,x = exp(beta * (q - alpha));对于右尾,x = 1 - exp(-beta * (q - alpha)) - 例如,对于 x = self.x_coord[0] 或 self.x_coord[1],返回的值分别为 self.y_coord[0] 或 self.y_coord[1]。 - 参数
- x – 用于评估右尾的 x 坐标。 
 
 
- class gluonts.model.forecast.Forecast[source]#
- 基类: - object- 表示预测的抽象类。 - copy_aggregate(agg_fun: Callable)[source]#
- 返回一个新的 Forecast 对象,其时间序列沿维度轴进行了聚合。 - 参数
- agg_fun – 定义聚合操作的聚合函数(通常是均值或总和)。 
 
 - property freq#
 - property index: pandas.core.indexes.period.PeriodIndex#
 - info: Optional[Dict]#
 - item_id: Optional[str]#
 - property mean: numpy.ndarray#
 - property median: numpy.ndarray#
 - plot(*, intervals=(0.5, 0.9), ax=None, color=None, name=None, show_label=False)[source]#
- 使用 - matplotlib绘制预测中位数和预测区间。- 默认情况下,绘制 0.5 和 0.9 预测区间。可以通过设置 intervals 选择其他区间。 - 这会绘制到当前的轴对象(通过 - plt.gca()),如果提供了- ax则绘制到- ax。类似地,如果未设置显式的- color,则颜色使用 matplotlib 内部的颜色循环。- 可以设置 - name作为预测中位数的- label。除非将- show_label设置为- True,否则区间不会被标记。
 - prediction_length: int#
 - quantile(q: Union[float, str]) numpy.ndarray[source]#
- 从预测分布中计算分位数。 - 参数
- q – 要计算的分位数。 
- 返回值
- 预测范围内分位数的值。 
- 返回类型
- numpy.ndarray 
 
 - start_date: pandas._libs.tslibs.period.Period#
 
- class gluonts.model.forecast.Quantile(value: float, name: str)[source]#
- 基类: - object- classmethod from_float(quantile: float) gluonts.model.forecast.Quantile[source]#
 - classmethod from_str(quantile: str) gluonts.model.forecast.Quantile[source]#
 - name: str#
 - classmethod parse(quantile: Union[gluonts.model.forecast.Quantile, float, str]) gluonts.model.forecast.Quantile[source]#
- 生成给定分位数级别的等效浮点数和字符串表示。 - >>> Quantile.parse(0.1) Quantile(value=0.1, name='0.1') - >>> Quantile.parse('0.2') Quantile(value=0.2, name='0.2') - >>> Quantile.parse('0.20') Quantile(value=0.2, name='0.20') - >>> Quantile.parse('p99') Quantile(value=0.99, name='0.99') - 参数
- quantile – 分位数,可以是浮点数、表示浮点数的字符串(例如 '0.1')或形式为 'p10' 的分位数字符串。 
- 返回值
- 一个包含输入分位数级别的浮点数和字符串表示的元组。 
- 返回类型
 
 - value: float#
 
- class gluonts.model.forecast.QuantileForecast(forecast_arrays: numpy.ndarray, start_date: pandas._libs.tslibs.period.Period, forecast_keys: List[str], item_id: Optional[str] = None, info: Optional[Dict] = None)[source]#
- 基类: - gluonts.model.forecast.Forecast- 一个包含分位数和均值数组(即时间序列)的 Forecast 对象。 - 参数
- forecast_arrays – 预测数组 
- start_date (pandas._libs.tslibs.period.Period) – 预测的开始日期 
- forecast_keys – 分位数列表,形式如 '0.1', '0.9' 等,可能包含 'mean'。每个条目对应 forecast_arrays 中的一个数组。 
- item_id (Optional[str]) – 被预测项目的标识符。 
- info (Optional[Dict]) – 预测器可能提供的附加信息,例如估计参数、运行的迭代次数等。 
 
 - copy_dim(dim: int) gluonts.model.forecast.QuantileForecast[source]#
- 返回仅包含选定子维度的新 Forecast 对象。 - 参数
- dim – 返回的 Forecast 对象将仅表示此维度。 
 
 - info: Optional[Dict]#
 - item_id: Optional[str]#
 - property mean: numpy.ndarray#
- 预测均值。 
 - prediction_length: int#
 - quantile(inference_quantile: Union[float, str]) numpy.ndarray[source]#
- 从预测分布中计算分位数。 - 参数
- q – 要计算的分位数。 
- 返回值
- 预测范围内分位数的值。 
- 返回类型
- numpy.ndarray 
 
 - start_date: pandas._libs.tslibs.period.Period#
 
- class gluonts.model.forecast.SampleForecast(samples: numpy.ndarray, start_date: pandas._libs.tslibs.period.Period, item_id: Optional[str] = None, info: Optional[Dict] = None)[source]#
- 基类: - gluonts.model.forecast.Forecast- 基类: - gluonts.model.forecast.Forecast- 参数
- 一个 Forecast 对象,其中预测分布在内部以样本表示。 
- samples – 大小为 (num_samples, prediction_length) (一维情况) 或 (num_samples, prediction_length, target_dim) (多维情况) 的数组 
- item_id (Optional[str]) – 被预测项目的标识符。 
- info (Optional[Dict]) – 预测器可能提供的附加信息,例如估计参数、运行的迭代次数等。 
 
 - start_date (pandas._libs.tslibs.period.Period) – 预测的开始日期。
- 返回一个新的 Forecast 对象,其时间序列沿维度轴进行了聚合。 - 参数
- agg_fun – 定义聚合操作的聚合函数(通常是均值或总和)。 
 
 - copy_aggregate(agg_fun: Callable) gluonts.model.forecast.SampleForecast[source]#
- 返回仅包含选定子维度的新 Forecast 对象。 - 参数
- dim – 返回的 Forecast 对象将仅表示此维度。 
 
 - copy_dim(dim: int) gluonts.model.forecast.SampleForecast[source]#
- 返回 Forecast 对象的维度。 
 - info: Optional[Dict]#
 - item_id: Optional[str]#
- 预测均值。 
 - 预测均值,作为 pandas.Series 对象。
- property num_samples# 
 - 表示预测的样本数量。
- property prediction_length# 
 - 预测的时间长度。
- 从预测分布中计算分位数。 - 参数
- q – 要计算的分位数。 
- 返回值
- 预测范围内分位数的值。 
- 返回类型
- numpy.ndarray 
 
 - to_quantile_forecast(quantiles: List[str]) gluonts.model.forecast.QuantileForecast[source]#