DataCanvasIO / HyperTS

A Full-Pipeline Automated Time Series (AutoTS) Analysis Toolkit.
https://hyperts.readthedocs.io
Apache License 2.0
257 stars 27 forks source link

Some Issues on Time Series Prediction Results #110

Closed Layonhuuu closed 8 months ago

Layonhuuu commented 8 months ago

Why is my prediction only positive?And I think if the predicted results have been scaled, how can we restore the predicted results to before being scaled?I hope someone can help me. QAQ

perdict_result test_target data

zhangxjohn commented 8 months ago

This issue has been resolved. You can now pull the latest code into your site-packages.

Layonhuuu commented 8 months ago

thanks!Can I just reinstall it directly?pip install hyperts?

zhangxjohn commented 8 months ago

This issue has been resolved. However, the latest version has not been released yet, so you cannot install it at the moment. You only pull the dev code.

Layonhuuu commented 8 months ago

你好,再次打扰一下, 我能问下修改的这个bug具体在开发代码( dev code)哪个模块里面吗?是在hyperts\utils\transformers.py里面吗?

zhangxjohn commented 8 months ago

hyperts/framework/wrappers/dl_wrappers.py and hyperts/framework/wrappers/stats_wrappers.py

Layonhuuu commented 8 months ago

Thanks!

Layonhuuu commented 8 months ago

抱歉再次打扰到你,我按照你说的将GitHub上的代码下载下来(zip文件包),然后将zip压缩文件中Hyperts文件夹中的文件替换为我环境site-packages里的对应文件 仍然出现同样的问题,预测结果只有正值没有负值,且峰值对应不上的问题,请问该如何解决呢?

zhangxjohn commented 8 months ago

我猜测你打开的方式不对:( 可以看看version是0.2.0, 还是 0.2.1. 如果是0.2.0说明你的环境没有适配。建议用一下方式替换:

git clone git@github.com:DataCanvasIO/HyperTS.git
cd HyperTS
pip install -e . 
pip install tensorflow #optional
Layonhuuu commented 8 months ago

十分感谢!问题解决了

Layonhuuu commented 8 months ago

抱歉再次打扰你,我有个问题是,我在我自己的自定义搜索空间(custom_search_space)里,只保留了其中一个模型(例如enable_lstnet = True,其他三个模型均为false,只定义对应的模型的参数搜索空间)然而在实验进行时,控制台给出的信息显示,仍调用了其他模型(例如enable_hybirdrnn),我想请教一下这个问题是如何产生的?以及如何避免呢?调用参数如下 custom_search_space = DLForecastSearchSpace(enable_deepar = False, enable_hybirdrnn = False, enable_lstnet = True, enable_nbeats=False, lstnet_init_kwargs={ 'optimizer': 'adam', 'loss': Choice(['mae', 'mse', 'huber_loss']), 'rnn_type': Choice(['gru', 'lstm']), 'skip_rnn_type': Choice(['gru', 'lstm']), 'cnn_filters': Choice([64]2+[128]3+[256]*2)})

experiment = make_experiment(train_data=train_data.copy(), task='forecast', eval_data=eval_data, mode='dl', timestamp='时间(s)', max_trials=5, covariables=['xxx', ‘aaa’ ], reward_metric='rmse', optimize_direction='min', ensemble_size=None, search_space=custom_search_space, searcher=MCTSSearcher(custom_search_space, use_meta_learner=True, max_node_space=1000,candidates_size=10, optimize_direction='min'), log_level='INFO', random_state=0)

model = experiment.run(epochs=2, final_train_epochs=5,batch_size=1024,)

zhangxjohn commented 8 months ago

你把searcher=MCTSSearcher(custom_search_space, use_meta_learner=True, max_node_space=1000,candidates_size=10, optimize_direction='min')删除看看。

Layonhuuu commented 8 months ago

还是会应用hybirdrnn模型,但是定义了enable_hybirdrnn = False.

zhangxjohn commented 8 months ago

按道理应该是不会走hybirdrnn了。如果可以的话,你可以Debug一下,看看问题出现在哪,我目前想象不到问题位置。

zhangxjohn commented 8 months ago

断点位置:HyperTS/hyperts/framework/search_space /macro_search_space.py 754行和851行。

Layonhuuu commented 8 months ago

你好,抱歉再次打扰,在构建实验时,我尝试自定义损失函数,模式为“dl”,运行时给出如下信息 11-15 14:12:41 W hyperts.f.d._base.py 689 - In dl model, ['custom_metric'] is not supported, so ['rmse'] will be called. 所以在深度学习里不能自定义损失函数(loss)吗?

zhangxjohn commented 8 months ago

是的。

Layonhuuu commented 8 months ago

你好,再次叨扰^.^,在结果绘制中,采用提供的接口 model.plot(forecast=forecast, actual=test_data, var_id='xxx', interactive=False,show_forecast_interval=False) 我只传输了forecast与actual,为和图片中还有一条数据是historical?请问一下这个historical的结果在哪里能看呢?我采用 forecast = model.predict(X_test) 输出的结果也只有时间戳与预测列,并没有Historical。所以就想请教一下QAQ。此外还有个小问题是,之前模型调用窗口的问题解决之后,我只调用了DeepAR模型 这模型应该会返回两列数据,均值与方差?在预测结果中也只有一列,没有方差,请问哪里能找到呢? Figure 2023-11-15 165820

zhangxjohn commented 8 months ago

1、默认historical会显示训练集的一小段数据,可能你的测试数据比较长,好像看不到了historical了。想看的话,可以传入更多的historical。 2、DeepAR这个模型理论上是有均值与方差,不过为了统一所有模型的输出,DeepAR只输出了均值,所以方差没有了。

Layonhuuu commented 8 months ago

"historical会显示训练集的一小段数据",对这句话有点小疑问呢?因为如果是训练集的数据的话,以前的代码试验结果绘制的图像里含有的Historical数据峰值都很小,在1.5-3.5之间,而给模型训练的数据集的峰值分布不可能这么小QAQ,请问可以在hyperts框架的哪里看到关于这个Historica数据的调用哇?

Layonhuuu commented 8 months ago

“为了统一所有模型的输出,DeepAR只输出了均值”,那就有个小问题就是,在示例结果展示里,图片有upperbound与lowerbound,这俩值是怎么算出来的呢? Actual_vs_Forecast

zhangxjohn commented 8 months ago

那就说来话长了。

zhangxjohn commented 8 months ago

plot的调用可以查看一下文档里的API。

Layonhuuu commented 8 months ago

那就说来话长了。

请问能方便透露下吗?QAQ

zhangxjohn commented 8 months ago

通过贝叶斯推断的。

Layonhuuu commented 8 months ago

感谢!