|
|
@@ -25,10 +25,24 @@ comments: true
|
|
|
<td>DLinear</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b2/DLinear_infer.tar">推理模型</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/DLinear_pretrained.pdparams">训练模型</a></td>
|
|
|
<td>0.382</td>
|
|
|
<td>0.394</td>
|
|
|
-<td>76k</td>
|
|
|
+<td>72k</td>
|
|
|
<td>DLinear结构简单,效率高且易用的时序预测模型</td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
+<td>NLinear</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b2/NLinear_infer.tar">推理模型</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/NLinear_pretrained.pdparams">训练模型</a></td>
|
|
|
+<td>0.386</td>
|
|
|
+<td>0.392</td>
|
|
|
+<td>40k</td>
|
|
|
+<td>NLinear结构简单,效率高且易用的时序预测模型</td>
|
|
|
+</tr>
|
|
|
+<tr>
|
|
|
+<td>RLinear</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b2/RLinear_infer.tar">推理模型</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/RLinear_pretrained.pdparams">训练模型</a></td>
|
|
|
+<td>0.385</td>
|
|
|
+<td>0.392</td>
|
|
|
+<td>40k</td>
|
|
|
+<td>RLinear结构简单,效率高且易用的时序预测模型</td>
|
|
|
+</tr>
|
|
|
+<tr>
|
|
|
<td>Nonstationary</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b2/Nonstationary_infer.tar">推理模型</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/Nonstationary_pretrained.pdparams">训练模型</a></td>
|
|
|
<td>0.600</td>
|
|
|
<td>0.515</td>
|
|
|
@@ -37,27 +51,28 @@ comments: true
|
|
|
</tr>
|
|
|
<tr>
|
|
|
<td>PatchTST</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b2/PatchTST_infer.tar">推理模型</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/PatchTST_pretrained.pdparams">训练模型</a></td>
|
|
|
-<td>0.385</td>
|
|
|
-<td>0.397</td>
|
|
|
-<td>2.2M</td>
|
|
|
+<td>0.379</td>
|
|
|
+<td>0.391</td>
|
|
|
+<td>2.0M</td>
|
|
|
<td>PatchTST是兼顾局部模式和全局依赖关系的高精度长时序预测模型</td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
<td>TiDE</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b2/TiDE_infer.tar">推理模型</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/TiDE_pretrained.pdparams">训练模型</a></td>
|
|
|
-<td>0.405</td>
|
|
|
-<td>0.412</td>
|
|
|
-<td>34.9M</td>
|
|
|
+<td>0.407</td>
|
|
|
+<td>0.414</td>
|
|
|
+<td>31.7M</td>
|
|
|
<td>TiDE是适用于处理多变量、长期的时间序列预测问题的高精度模型</td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
<td>TimesNet</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b2/TimesNet_infer.tar">推理模型</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/TimesNet_pretrained.pdparams">训练模型</a></td>
|
|
|
-<td>0.417</td>
|
|
|
-<td>0.431</td>
|
|
|
-<td>5.2M</td>
|
|
|
+<td>0.416</td>
|
|
|
+<td>0.429</td>
|
|
|
+<td>4.9M</td>
|
|
|
<td>通过多周期分析,TimesNet是适应性强的高精度时间序列分析模型</td>
|
|
|
</tr>
|
|
|
</tbody>
|
|
|
</table>
|
|
|
+
|
|
|
<b>注:以上精度指标测量自</b>[ETTH1](https://paddle-model-ecology.bj.bcebos.com/paddlex/data/Etth1.tar)<b>测试数据集,输入序列长度为96,预测序列长度除 TiDE 外为96,TiDE为720 。</b>
|
|
|
|
|
|
|
|
|
@@ -68,12 +83,188 @@ comments: true
|
|
|
|
|
|
```bash
|
|
|
from paddlex import create_model
|
|
|
-model = create_model("DLinear")
|
|
|
+model = create_model(model_name="DLinear")
|
|
|
output = model.predict("ts_fc.csv", batch_size=1)
|
|
|
for res in output:
|
|
|
res.print(json_format=False)
|
|
|
- res.save_to_csv("./output/")
|
|
|
+ res.save_to_csv(save_path="./output/")
|
|
|
+ res.save_to_json(save_path="./output/res.json")
|
|
|
+```
|
|
|
+
|
|
|
+运行后,得到的结果为:
|
|
|
+```bash
|
|
|
+{'res': {'input_path': 'ts_fc.csv', 'forecast': OT
|
|
|
+date
|
|
|
+2018-06-26 20:00:00 9.586131
|
|
|
+2018-06-26 21:00:00 9.379762
|
|
|
+2018-06-26 22:00:00 9.252275
|
|
|
+2018-06-26 23:00:00 9.249993
|
|
|
+2018-06-27 00:00:00 9.164998
|
|
|
+... ...
|
|
|
+2018-06-30 15:00:00 8.830340
|
|
|
+2018-06-30 16:00:00 9.291553
|
|
|
+2018-06-30 17:00:00 9.097666
|
|
|
+2018-06-30 18:00:00 8.905430
|
|
|
+2018-06-30 19:00:00 8.993793
|
|
|
+
|
|
|
+[96 rows x 1 columns]}}
|
|
|
```
|
|
|
+
|
|
|
+运行结果参数含义如下:
|
|
|
+- `input_path`:表示输入待预测的时序文件路径
|
|
|
+- `forecast`:表示时序预测结果,可以通过`res.save_to_csv()`将预测结果保存为csv文件,通过`res.save_to_json()`将预测结果保存为json文件。
|
|
|
+
|
|
|
+相关方法、参数等说明如下:
|
|
|
+
|
|
|
+
|
|
|
+* `create_model`实例化时序预测模型(此处以`DLinear`为例),具体说明如下:
|
|
|
+<table>
|
|
|
+<thead>
|
|
|
+<tr>
|
|
|
+<th>参数</th>
|
|
|
+<th>参数说明</th>
|
|
|
+<th>参数类型</th>
|
|
|
+<th>可选项</th>
|
|
|
+<th>默认值</th>
|
|
|
+</tr>
|
|
|
+</thead>
|
|
|
+<tr>
|
|
|
+<td><code>model_name</code></td>
|
|
|
+<td>模型名称</td>
|
|
|
+<td><code>str</code></td>
|
|
|
+<td>所有PaddleX支持的模型名称</td>
|
|
|
+<td>无</td>
|
|
|
+</tr>
|
|
|
+<tr>
|
|
|
+<td><code>model_dir</code></td>
|
|
|
+<td>模型存储路径</td>
|
|
|
+<td><code>str</code></td>
|
|
|
+<td>无</td>
|
|
|
+<td>无</td>
|
|
|
+</tr>
|
|
|
+</table>
|
|
|
+
|
|
|
+* 其中,`model_name` 必须指定,指定 `model_name` 后,默认使用 PaddleX 内置的模型参数,在此基础上,指定 `model_dir` 时,使用用户自定义的模型。
|
|
|
+
|
|
|
+* 调用时序预测模型的 `predict()` 方法进行推理预测,`predict()` 方法参数有 `input` 和 `batch_size`,具体说明如下:
|
|
|
+
|
|
|
+<table>
|
|
|
+<thead>
|
|
|
+<tr>
|
|
|
+<th>参数</th>
|
|
|
+<th>参数说明</th>
|
|
|
+<th>参数类型</th>
|
|
|
+<th>可选项</th>
|
|
|
+<th>默认值</th>
|
|
|
+</tr>
|
|
|
+</thead>
|
|
|
+<tr>
|
|
|
+<td><code>input</code></td>
|
|
|
+<td>待预测数据,支持多种输入类型</td>
|
|
|
+<td><code>Python Var</code>/<code>str</code>/<code>list</code></td>
|
|
|
+<td>
|
|
|
+<ul>
|
|
|
+ <li><b>Python变量</b>,如<code>pandas.DataFrame</code>表示的时序数据</li>
|
|
|
+ <li><b>文件路径</b>,如时序文件的本地路径:<code>/root/data/ts.csv</code></li>
|
|
|
+ <li><b>URL链接</b>,如时序文件的网络URL:<a href = "https://paddle-model-ecology.bj.bcebos.com/paddlex/ts/demo_ts/ts_fc.csv">示例</a></li>
|
|
|
+ <li><b>本地目录</b>,该目录下需包含待预测数据文件,如本地路径:<code>/root/data/</code></li>
|
|
|
+ <li><b>列表</b>,列表元素需为上述类型数据,如<code>[pandas.DataFrame, pandas.DataFrame]</code>,<code>[\"/root/data/ts1.csv\", \"/root/data/ts2.csv\"]</code>,<code>[\"/root/data1\", \"/root/data2\"]</code>,<code>[{\"ts\": \"/root/data1\"}, {\"ts\": \"/root/data2/ts.csv\"}]</code></li>
|
|
|
+</ul>
|
|
|
+</td>
|
|
|
+<td>无</td>
|
|
|
+</tr>
|
|
|
+<tr>
|
|
|
+<td><code>batch_size</code></td>
|
|
|
+<td>批大小</td>
|
|
|
+<td><code>int</code></td>
|
|
|
+<td>大于0任意整数</td>
|
|
|
+<td>1</td>
|
|
|
+</tr>
|
|
|
+</table>
|
|
|
+
|
|
|
+* 对预测结果进行处理,每个样本的预测结果均为`dict`类型,且支持打印、保存为`csv`文件、保存为`json`文件的操作:
|
|
|
+
|
|
|
+<table>
|
|
|
+<thead>
|
|
|
+<tr>
|
|
|
+<th>方法</th>
|
|
|
+<th>方法说明</th>
|
|
|
+<th>参数</th>
|
|
|
+<th>参数类型</th>
|
|
|
+<th>参数说明</th>
|
|
|
+<th>默认值</th>
|
|
|
+</tr>
|
|
|
+</thead>
|
|
|
+<tr>
|
|
|
+<td rowspan = "3"><code>print()</code></td>
|
|
|
+<td rowspan = "3">打印结果到终端</td>
|
|
|
+<td><code>format_json</code></td>
|
|
|
+<td><code>bool</code></td>
|
|
|
+<td>是否对输出内容进行使用 <code>JSON</code> 缩进格式化</td>
|
|
|
+<td><code>True</code></td>
|
|
|
+</tr>
|
|
|
+<tr>
|
|
|
+<td><code>indent</code></td>
|
|
|
+<td><code>int</code></td>
|
|
|
+<td>指定缩进级别,以美化输出的 <code>JSON</code> 数据,使其更具可读性,仅当 <code>format_json</code> 为 <code>True</code> 时有效</td>
|
|
|
+<td>4</td>
|
|
|
+</tr>
|
|
|
+<tr>
|
|
|
+<td><code>ensure_ascii</code></td>
|
|
|
+<td><code>bool</code></td>
|
|
|
+<td>控制是否将非 <code>ASCII</code> 字符转义为 <code>Unicode</code>。设置为 <code>True</code> 时,所有非 <code>ASCII</code> 字符将被转义;<code>False</code> 则保留原始字符,仅当<code>format_json</code>为<code>True</code>时有效</td>
|
|
|
+<td><code>False</code></td>
|
|
|
+</tr>
|
|
|
+<tr>
|
|
|
+<td rowspan = "3"><code>save_to_json()</code></td>
|
|
|
+<td rowspan = "3">将结果保存为json格式的文件</td>
|
|
|
+<td><code>save_path</code></td>
|
|
|
+<td><code>str</code></td>
|
|
|
+<td>保存的文件路径,当为目录时,保存文件命名与输入文件类型命名一致</td>
|
|
|
+<td>无</td>
|
|
|
+</tr>
|
|
|
+<tr>
|
|
|
+<td><code>indent</code></td>
|
|
|
+<td><code>int</code></td>
|
|
|
+<td>指定缩进级别,以美化输出的 <code>JSON</code> 数据,使其更具可读性,仅当 <code>format_json</code> 为 <code>True</code> 时有效</td>
|
|
|
+<td>4</td>
|
|
|
+</tr>
|
|
|
+<tr>
|
|
|
+<td><code>ensure_ascii</code></td>
|
|
|
+<td><code>bool</code></td>
|
|
|
+<td>控制是否将非 <code>ASCII</code> 字符转义为 <code>Unicode</code>。设置为 <code>True</code> 时,所有非 <code>ASCII</code> 字符将被转义;<code>False</code> 则保留原始字符,仅当<code>format_json</code>为<code>True</code>时有效</td>
|
|
|
+<td><code>False</code></td>
|
|
|
+</tr>
|
|
|
+<tr>
|
|
|
+<td><code>save_to_csv()</code></td>
|
|
|
+<td>将结果保存为时序csv格式的文件</td>
|
|
|
+<td><code>save_path</code></td>
|
|
|
+<td><code>str</code></td>
|
|
|
+<td>保存的文件路径,当为目录时,保存文件命名与输入文件类型命名一致</td>
|
|
|
+<td>无</td>
|
|
|
+</tr>
|
|
|
+</table>
|
|
|
+
|
|
|
+* 此外,也支持通过属性获取带结果的可视化时序和预测结果,具体如下:
|
|
|
+
|
|
|
+<table>
|
|
|
+<thead>
|
|
|
+<tr>
|
|
|
+<th>属性</th>
|
|
|
+<th>属性说明</th>
|
|
|
+</tr>
|
|
|
+</thead>
|
|
|
+<tr>
|
|
|
+<td rowspan = "1"><code>json</code></td>
|
|
|
+<td rowspan = "1">获取预测的<code>json</code>格式的结果</td>
|
|
|
+</tr>
|
|
|
+<tr>
|
|
|
+<td rowspan = "1"><code>csv</code></td>
|
|
|
+<td rowspan = "1">获取格式为<code>csv</code>的时序预测预测结果</td>
|
|
|
+</tr>
|
|
|
+
|
|
|
+</table>
|
|
|
+
|
|
|
关于更多 PaddleX 的单模型推理的 API 的使用方法,可以参考[PaddleX单模型Python脚本使用说明](../../instructions/model_python_API.md)。
|
|
|
|
|
|
## 四、二次开发
|