我正在创建具有外部可控功能的时间序列预测模型,该功能类似于在https://medium.com/tensorflow/structural-time-series-modeling-in-tensorflow-probability-344edac24083中找到的“电力需求预测”示例。为了建模外部因素的影响,我使用sts.LinearRegression()作为模型的组成部分,但是这些外部因素本质上是非常非线性的,这会在模型中引起不必要的负面预测。

我尝试在TFP STS之外创建(更简单的)预测,发现对于这些外部功能,RandomForestRegressor更好地适用于LinearRegressor。我想做的是将sts.LinearRegression()替换为sts.RandomForestRegressor(),但这在sts库中不可用。实际上,sts库几乎没有可用的选项:https://www.tensorflow.org/probability/api_docs/python/tfp/sts/LinearRegression

我也尝试过将目标变量转换为日志格式,但是有很多零实例(对于日志来说是inf),但这并不是一个有用的转换。

我的TFP STS模型架构如下所示:

def build_model(observed_time_series):

season_effect = sts.Seasonal(
                num_seasons = 4, num_steps_per_season = 13, observed_time_series = observed_time_series,
                name = 'season_effect')
marketing_effect = sts.LinearRegression(
                design_matrix = tf.stack([recent_publicity - np.mean(recent_publicity),
                active_ad - np.mean(active_ad)], axis = -1),
                name = 'marketing_effect')
autoregressive = sts.Autoregressive(order=1,
                observed_time_series = observed_time_series,
                name = 'autoregressive')
model = sts.Sum([season_effect,
                 marketing_effect,
                 autoregressive],
                 observed_time_series = observed_time_series)
return model


我要将模型的“ marketing_effect”组件更改为非线性组件的地方。

在这里,我唯一的选择是克隆TFP STS库并创建一个自定义函数来处理诸如Random Forest Regressor之类的非线性数据吗?有谁知道更好的选择?

最佳答案

我对sts模型中随机森林的用法不熟悉。您可以指出存在该系统的系统吗? tfp.sts的诀窍在于,所有数学运算都很好且具有解析性,因为所有内容都处于高斯状态。如果我们能够做到这一点,我认为我们绝对可以引入其他模型。

关于python - 如何使用Tensorflow概率结构化时间序列模型组件的非线性模型替换sts.LinearRegression,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57626828/

10-12 22:11