|
@@ -66,7 +66,7 @@ paddlex --get_pipeline_config ts_fc
|
|
|
执行后,时序预测产线配置文件将被保存在当前路径。若您希望自定义保存位置,可执行如下命令(假设自定义保存位置为 `./my_path` ):
|
|
执行后,时序预测产线配置文件将被保存在当前路径。若您希望自定义保存位置,可执行如下命令(假设自定义保存位置为 `./my_path` ):
|
|
|
|
|
|
|
|
```
|
|
```
|
|
|
-paddlex --get_pipeline_config ts_fc --config_save_path ./my_path
|
|
|
|
|
|
|
+paddlex --get_pipeline_config ts_fc --save_path ./my_path
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
获取产线配置文件后,可将 `--pipeline` 替换为配置文件保存路径,即可使配置文件生效。例如,若配置文件保存路径为 `./ts_fc.yaml`,只需执行:
|
|
获取产线配置文件后,可将 `--pipeline` 替换为配置文件保存路径,即可使配置文件生效。例如,若配置文件保存路径为 `./ts_fc.yaml`,只需执行:
|
|
@@ -82,7 +82,7 @@ paddlex --pipeline ./ts_fc.yaml --input ts_fc.csv
|
|
|
|
|
|
|
|
```
|
|
```
|
|
|
{'ts_path': '/root/.paddlex/predict_input/ts_fc.csv', 'forecast': OT
|
|
{'ts_path': '/root/.paddlex/predict_input/ts_fc.csv', 'forecast': OT
|
|
|
-date
|
|
|
|
|
|
|
+date
|
|
|
2018-06-26 20:00:00 9.586131
|
|
2018-06-26 20:00:00 9.586131
|
|
|
2018-06-26 21:00:00 9.379762
|
|
2018-06-26 21:00:00 9.379762
|
|
|
2018-06-26 22:00:00 9.252275
|
|
2018-06-26 22:00:00 9.252275
|
|
@@ -169,9 +169,9 @@ for res in output:
|
|
|
|
|
|
|
|
下面是API参考和多语言服务调用示例:
|
|
下面是API参考和多语言服务调用示例:
|
|
|
|
|
|
|
|
-<details>
|
|
|
|
|
-<summary>API参考</summary>
|
|
|
|
|
-
|
|
|
|
|
|
|
+<details>
|
|
|
|
|
+<summary>API参考</summary>
|
|
|
|
|
+
|
|
|
对于服务提供的所有操作:
|
|
对于服务提供的所有操作:
|
|
|
|
|
|
|
|
- 响应体以及POST请求的请求体均为JSON数据(JSON对象)。
|
|
- 响应体以及POST请求的请求体均为JSON数据(JSON对象)。
|
|
@@ -222,11 +222,11 @@ for res in output:
|
|
|
</details>
|
|
</details>
|
|
|
|
|
|
|
|
<details>
|
|
<details>
|
|
|
-<summary>多语言调用服务示例</summary>
|
|
|
|
|
|
|
+<summary>多语言调用服务示例</summary>
|
|
|
|
|
+
|
|
|
|
|
+<details>
|
|
|
|
|
+<summary>Python</summary>
|
|
|
|
|
|
|
|
-<details>
|
|
|
|
|
-<summary>Python</summary>
|
|
|
|
|
-
|
|
|
|
|
```python
|
|
```python
|
|
|
import base64
|
|
import base64
|
|
|
import requests
|
|
import requests
|
|
@@ -252,12 +252,12 @@ with open(output_csv_path, "wb") as f:
|
|
|
f.write(base64.b64decode(result["csv"]))
|
|
f.write(base64.b64decode(result["csv"]))
|
|
|
print(f"Output time-series data saved at {output_csv_path}")
|
|
print(f"Output time-series data saved at {output_csv_path}")
|
|
|
```
|
|
```
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
</details>
|
|
</details>
|
|
|
|
|
|
|
|
-<details>
|
|
|
|
|
-<summary>C++</summary>
|
|
|
|
|
-
|
|
|
|
|
|
|
+<details>
|
|
|
|
|
+<summary>C++</summary>
|
|
|
|
|
+
|
|
|
```cpp
|
|
```cpp
|
|
|
#include <iostream>
|
|
#include <iostream>
|
|
|
#include "cpp-httplib/httplib.h" // https://github.com/Huiyicc/cpp-httplib
|
|
#include "cpp-httplib/httplib.h" // https://github.com/Huiyicc/cpp-httplib
|
|
@@ -318,12 +318,12 @@ int main() {
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
```
|
|
```
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
</details>
|
|
</details>
|
|
|
|
|
|
|
|
-<details>
|
|
|
|
|
-<summary>Java</summary>
|
|
|
|
|
-
|
|
|
|
|
|
|
+<details>
|
|
|
|
|
+<summary>Java</summary>
|
|
|
|
|
+
|
|
|
```java
|
|
```java
|
|
|
import okhttp3.*;
|
|
import okhttp3.*;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
@@ -380,97 +380,97 @@ public class Main {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
```
|
|
```
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
</details>
|
|
</details>
|
|
|
|
|
|
|
|
-<details>
|
|
|
|
|
-<summary>Go</summary>
|
|
|
|
|
-
|
|
|
|
|
|
|
+<details>
|
|
|
|
|
+<summary>Go</summary>
|
|
|
|
|
+
|
|
|
```go
|
|
```go
|
|
|
package main
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
- "bytes"
|
|
|
|
|
- "encoding/base64"
|
|
|
|
|
- "encoding/json"
|
|
|
|
|
- "fmt"
|
|
|
|
|
- "io/ioutil"
|
|
|
|
|
- "net/http"
|
|
|
|
|
|
|
+ "bytes"
|
|
|
|
|
+ "encoding/base64"
|
|
|
|
|
+ "encoding/json"
|
|
|
|
|
+ "fmt"
|
|
|
|
|
+ "io/ioutil"
|
|
|
|
|
+ "net/http"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
func main() {
|
|
|
- API_URL := "http://localhost:8080/time-series-forecasting"
|
|
|
|
|
- csvPath := "./test.csv";
|
|
|
|
|
- outputCsvPath := "./out.csv";
|
|
|
|
|
-
|
|
|
|
|
- // 读取csv文件并进行Base64编码
|
|
|
|
|
- csvBytes, err := ioutil.ReadFile(csvPath)
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- fmt.Println("Error reading csv file:", err)
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- csvData := base64.StdEncoding.EncodeToString(csvBytes)
|
|
|
|
|
-
|
|
|
|
|
- payload := map[string]string{"csv": csvData} // Base64编码的文件内容
|
|
|
|
|
- payloadBytes, err := json.Marshal(payload)
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- fmt.Println("Error marshaling payload:", err)
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 调用API
|
|
|
|
|
- client := &http.Client{}
|
|
|
|
|
- req, err := http.NewRequest("POST", API_URL, bytes.NewBuffer(payloadBytes))
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- fmt.Println("Error creating request:", err)
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- res, err := client.Do(req)
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- fmt.Println("Error sending request:", err)
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- defer res.Body.Close()
|
|
|
|
|
-
|
|
|
|
|
- // 处理返回数据
|
|
|
|
|
- body, err := ioutil.ReadAll(res.Body)
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- fmt.Println("Error reading response body:", err)
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- type Response struct {
|
|
|
|
|
- Result struct {
|
|
|
|
|
- Csv string `json:"csv"`
|
|
|
|
|
- } `json:"result"`
|
|
|
|
|
- }
|
|
|
|
|
- var respData Response
|
|
|
|
|
- err = json.Unmarshal([]byte(string(body)), &respData)
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- fmt.Println("Error unmarshaling response body:", err)
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 将Base64编码的csv数据解码并保存为文件
|
|
|
|
|
- outputCsvData, err := base64.StdEncoding.DecodeString(respData.Result.Csv)
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- fmt.Println("Error decoding base64 csv data:", err)
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- err = ioutil.WriteFile(outputCsvPath, outputCsvData, 0644)
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- fmt.Println("Error writing csv to file:", err)
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- fmt.Printf("Output time-series data saved at %s.csv", outputCsvPath)
|
|
|
|
|
|
|
+ API_URL := "http://localhost:8080/time-series-forecasting"
|
|
|
|
|
+ csvPath := "./test.csv";
|
|
|
|
|
+ outputCsvPath := "./out.csv";
|
|
|
|
|
+
|
|
|
|
|
+ // 读取csv文件并进行Base64编码
|
|
|
|
|
+ csvBytes, err := ioutil.ReadFile(csvPath)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ fmt.Println("Error reading csv file:", err)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ csvData := base64.StdEncoding.EncodeToString(csvBytes)
|
|
|
|
|
+
|
|
|
|
|
+ payload := map[string]string{"csv": csvData} // Base64编码的文件内容
|
|
|
|
|
+ payloadBytes, err := json.Marshal(payload)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ fmt.Println("Error marshaling payload:", err)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 调用API
|
|
|
|
|
+ client := &http.Client{}
|
|
|
|
|
+ req, err := http.NewRequest("POST", API_URL, bytes.NewBuffer(payloadBytes))
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ fmt.Println("Error creating request:", err)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ res, err := client.Do(req)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ fmt.Println("Error sending request:", err)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ defer res.Body.Close()
|
|
|
|
|
+
|
|
|
|
|
+ // 处理返回数据
|
|
|
|
|
+ body, err := ioutil.ReadAll(res.Body)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ fmt.Println("Error reading response body:", err)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ type Response struct {
|
|
|
|
|
+ Result struct {
|
|
|
|
|
+ Csv string `json:"csv"`
|
|
|
|
|
+ } `json:"result"`
|
|
|
|
|
+ }
|
|
|
|
|
+ var respData Response
|
|
|
|
|
+ err = json.Unmarshal([]byte(string(body)), &respData)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ fmt.Println("Error unmarshaling response body:", err)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 将Base64编码的csv数据解码并保存为文件
|
|
|
|
|
+ outputCsvData, err := base64.StdEncoding.DecodeString(respData.Result.Csv)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ fmt.Println("Error decoding base64 csv data:", err)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ err = ioutil.WriteFile(outputCsvPath, outputCsvData, 0644)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ fmt.Println("Error writing csv to file:", err)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ fmt.Printf("Output time-series data saved at %s.csv", outputCsvPath)
|
|
|
}
|
|
}
|
|
|
```
|
|
```
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
</details>
|
|
</details>
|
|
|
|
|
|
|
|
-<details>
|
|
|
|
|
-<summary>C#</summary>
|
|
|
|
|
-
|
|
|
|
|
|
|
+<details>
|
|
|
|
|
+<summary>C#</summary>
|
|
|
|
|
+
|
|
|
```csharp
|
|
```csharp
|
|
|
using System;
|
|
using System;
|
|
|
using System.IO;
|
|
using System.IO;
|
|
@@ -513,12 +513,12 @@ class Program
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
```
|
|
```
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
</details>
|
|
</details>
|
|
|
|
|
|
|
|
-<details>
|
|
|
|
|
-<summary>Node.js</summary>
|
|
|
|
|
-
|
|
|
|
|
|
|
+<details>
|
|
|
|
|
+<summary>Node.js</summary>
|
|
|
|
|
+
|
|
|
```js
|
|
```js
|
|
|
const axios = require('axios');
|
|
const axios = require('axios');
|
|
|
const fs = require('fs');
|
|
const fs = require('fs');
|
|
@@ -557,12 +557,12 @@ axios.request(config)
|
|
|
console.log(error);
|
|
console.log(error);
|
|
|
});
|
|
});
|
|
|
```
|
|
```
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
</details>
|
|
</details>
|
|
|
|
|
|
|
|
-<details>
|
|
|
|
|
-<summary>PHP</summary>
|
|
|
|
|
-
|
|
|
|
|
|
|
+<details>
|
|
|
|
|
+<summary>PHP</summary>
|
|
|
|
|
+
|
|
|
```php
|
|
```php
|
|
|
<?php
|
|
<?php
|
|
|
|
|
|
|
@@ -591,7 +591,7 @@ echo "Output time-series data saved at " . $output_csv_path . "\n";
|
|
|
?>
|
|
?>
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
</details>
|
|
</details>
|
|
|
</details>
|
|
</details>
|
|
|
<br/>
|
|
<br/>
|