时序数据库 TDengine + 高级分析软件 Seeq,助力企业挖掘时序数据潜力

作为一款制造业和工业互联网(IIOT)高级分析软件,Seeq 支持在工艺制造组织中使用机器学习创新的新功能。这些功能使组织能够将自己或第三方机器学习算法部署到前线流程工程师和主题专家使用的高级分析应用程序,从而使单个数据科学家的努力扩展到许多前线员工。通过 TDengine Java connector,Seeq 可以轻松支持查询 TDengine 提供的时序数据,并提供数据展现、分析、预测等功能。本文将对此进行介绍。

如何配置 Seeq 访问 TDengine

  1. 查看 data 存储位置

    sudo seeq config get Folders/Data

  2. maven.org 下载 TDengine Java connector 包,目前最新版本为 3.2.7 (Maven Central: com.taosdata.jdbc:taos-jdbcdriver)。并拷贝至 data 存储位置的 plugins\lib中。

  3. 重新启动 seeq server

    sudo seeq restart

  4. 输入 License

使用浏览器访问 ip:34216 并按照说明输入 license。

使用 Seeq 分析 TDengine 时序数据

下文将为大家演示如何使用 Seeq 软件配合 TDengine 进行时序数据分析。

场景介绍

示例场景为一个电力系统,用户每天从电站仪表收集用电量数据,并将其存储在 TDengine 集群中。现在用户想要预测电力消耗将会如何发展,并购买更多设备来支持它。用户电力消耗随着每月订单变化而不同,另外考虑到季节变化,电力消耗量会有所不同。这个城市位于北半球,所以在夏天会使用更多的电力。我们模拟数据来反映这些假定。

数据 Schema

复制代码
CREATE STABLE meters (ts TIMESTAMP, num INT, temperature FLOAT, goods INT) TAGS (device NCHAR(20));
create table goods (ts1 timestamp, ts2 timestamp, goods float);

构造数据方法

复制代码
python mockdata.py

taos -s "insert into power.goods select _wstart, _wstart + 10d, avg(goods) from power.meters interval(10d);"

源代码托管在 https://github.com/sangshuduo/td-forecasting

使用 Seeq 进行数据分析

配置数据源(Data Source)

使用 Seeq 管理员角色的帐号登录,并新建数据源。

  • Power

    {
    "QueryDefinitions": [
    {
    "Name": "PowerNum",
    "Type": "SIGNAL",
    "Sql": "SELECT ts, num FROM meters",
    "Enabled": true,
    "TestMode": false,
    "TestQueriesDuringSync": true,
    "InProgressCapsulesEnabled": false,
    "Variables": null,
    "Properties": [
    {
    "Name": "Name",
    "Value": "Num",
    "Sql": null,
    "Uom": "string"
    },
    {
    "Name": "Interpolation Method",
    "Value": "linear",
    "Sql": null,
    "Uom": "string"
    },
    {
    "Name": "Maximum Interpolation",
    "Value": "2day",
    "Sql": null,
    "Uom": "string"
    }
    ],
    "CapsuleProperties": null
    }
    ],
    "Type": "GENERIC",
    "Hostname": null,
    "Port": 0,
    "DatabaseName": null,
    "Username": "root",
    "Password": "taosdata",
    "InitialSql": null,
    "TimeZone": null,
    "PrintRows": false,
    "UseWindowsAuth": false,
    "SqlFetchBatchSize": 100000,
    "UseSSL": false,
    "JdbcProperties": null,
    "GenericDatabaseConfig": {
    "DatabaseJdbcUrl": "jdbc:TAOS-RS://127.0.0.1:6041/power?user=root&password=taosdata",
    "SqlDriverClassName": "com.taosdata.jdbc.rs.RestfulDriver",
    "ResolutionInNanoseconds": 1000,
    "ZonedColumnTypes": []
    }
    }

  • Goods

    {
    "QueryDefinitions": [
    {
    "Name": "PowerGoods",
    "Type": "CONDITION",
    "Sql": "SELECT ts1, ts2, goods FROM power.goods",
    "Enabled": true,
    "TestMode": false,
    "TestQueriesDuringSync": true,
    "InProgressCapsulesEnabled": false,
    "Variables": null,
    "Properties": [
    {
    "Name": "Name",
    "Value": "Goods",
    "Sql": null,
    "Uom": "string"
    },
    {
    "Name": "Maximum Duration",
    "Value": "10days",
    "Sql": null,
    "Uom": "string"
    }
    ],
    "CapsuleProperties": [
    {
    "Name": "goods",
    "Value": "${columnResult}",
    "Column": "goods",
    "Uom": "string"
    }
    ]
    }
    ],
    "Type": "GENERIC",
    "Hostname": null,
    "Port": 0,
    "DatabaseName": null,
    "Username": "root",
    "Password": "taosdata",
    "InitialSql": null,
    "TimeZone": null,
    "PrintRows": false,
    "UseWindowsAuth": false,
    "SqlFetchBatchSize": 100000,
    "UseSSL": false,
    "JdbcProperties": null,
    "GenericDatabaseConfig": {
    "DatabaseJdbcUrl": "jdbc:TAOS-RS://127.0.0.1:6041/power?user=root&password=taosdata",
    "SqlDriverClassName": "com.taosdata.jdbc.rs.RestfulDriver",
    "ResolutionInNanoseconds": 1000,
    "ZonedColumnTypes": []
    }
    }

  • Temperature

    {
    "QueryDefinitions": [
    {
    "Name": "PowerNum",
    "Type": "SIGNAL",
    "Sql": "SELECT ts, temperature FROM meters",
    "Enabled": true,
    "TestMode": false,
    "TestQueriesDuringSync": true,
    "InProgressCapsulesEnabled": false,
    "Variables": null,
    "Properties": [
    {
    "Name": "Name",
    "Value": "Temperature",
    "Sql": null,
    "Uom": "string"
    },
    {
    "Name": "Interpolation Method",
    "Value": "linear",
    "Sql": null,
    "Uom": "string"
    },
    {
    "Name": "Maximum Interpolation",
    "Value": "2day",
    "Sql": null,
    "Uom": "string"
    }
    ],
    "CapsuleProperties": null
    }
    ],
    "Type": "GENERIC",
    "Hostname": null,
    "Port": 0,
    "DatabaseName": null,
    "Username": "root",
    "Password": "taosdata",
    "InitialSql": null,
    "TimeZone": null,
    "PrintRows": false,
    "UseWindowsAuth": false,
    "SqlFetchBatchSize": 100000,
    "UseSSL": false,
    "JdbcProperties": null,
    "GenericDatabaseConfig": {
    "DatabaseJdbcUrl": "jdbc:TAOS-RS://127.0.0.1:6041/power?user=root&password=taosdata",
    "SqlDriverClassName": "com.taosdata.jdbc.rs.RestfulDriver",
    "ResolutionInNanoseconds": 1000,
    "ZonedColumnTypes": []
    }
    }

使用 Seeq Workbench

登录 Seeq 服务页面并新建 Seeq Workbench,通过选择数据源搜索结果和根据需要选择不同的工具,可以进行数据展现或预测,详细使用方法参见官方知识库:Seeq Workbench

使用 Seeq Data Lab Server 进行进一步的数据分析

登录 Seeq 服务页面并新建 Seeq Data Lab,可以进一步使用 Python 编程或其他机器学习工具进行更复杂的数据挖掘功能。

复制代码
from seeq import spy
spy.options.compatibility = 189
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
import mlforecast
import lightgbm as lgb
from mlforecast.target_transforms import Differences
from sklearn.linear_model import LinearRegression

ds = spy.search({'ID': "8C91A9C7-B6C2-4E18-AAAF-XXXXXXXXX"})
print(ds)

sig = ds.loc[ds['Name'].isin(['Num'])]
print(sig)

data = spy.pull(sig, start='2015-01-01', end='2022-12-31', grid=None)
print("data.info()")
data.info()
print(data)
#data.plot()

print("data[Num].info()")
data['Num'].info()
da = data['Num'].index.tolist()
#print(da)

li = data['Num'].tolist()
#print(li)

data2 = pd.DataFrame()
data2['ds'] = da
print('1st data2 ds info()')
data2['ds'].info()

#data2['ds'] = pd.to_datetime(data2['ds']).to_timestamp()
data2['ds'] = pd.to_datetime(data2['ds']).astype('int64')
data2['y'] = li
print('2nd data2 ds info()')
data2['ds'].info()
print(data2)

data2.insert(0, column = "unique_id", value="unique_id")

print("Forecasting ...")

forecast = mlforecast.MLForecast(
    models = lgb.LGBMRegressor(),
    freq = 1,
    lags=[365],
    target_transforms=[Differences([365])],
)

forecast.fit(data2)
predicts = forecast.predict(365)

pd.concat([data2, predicts]).set_index("ds").plot(title = "current data with forecast")
plt.show()

运行程序输出结果:

写在最后

通过集成 Seeq 和 TDengine,用户能够充分利用到 TDengine 高性能的时序数据存储和检索,确保数据的高效处理;同时也将受益于 Seeq 提供的强大数据可视化和分析功能,如数据可视化、异常检测、相关性分析和预测建模,方便用户获得有价值的数据洞察并基于此进行决策。

未来 Seeq 和 TDengine 将共同为制造业、工业物联网和电力系统等各行各业的时序数据分析提供综合解决方案,将高效数据存储和先进数据分析相结合,赋予企业深入挖掘时序数据潜力的能力,推动业务发展与改进。如果你想要了解 Seeq 的更全面设置、Seeq 与全托管的云服务平台 TDengine Cloud 的具体连接详情,请移步官方文档 Seeq | TDengine 文档 | 涛思数据 进行查阅。


了解更多 TDengine Database的具体细节,可在GitHub上查看相关源代码。

相关推荐
小云数据库服务专线13 分钟前
GaussDB数据库架构师修炼(十六) 如何选择磁盘
数据库·数据库架构·gaussdb
码出财富1 小时前
SQL语法大全指南
数据库·mysql·oracle
异世界贤狼转生码农3 小时前
MongoDB Windows 系统实战手册:从配置到数据处理入门
数据库·mongodb
wei_shuo3 小时前
时序数据库 Apache IoTDB:从边缘到云端Apache IoTDB 全链路数据管理能力、部署流程与安全特性解读
物联网·apache·时序数据库·iotdb
QuZhengRong3 小时前
【数据库】Navicat 导入 Excel 数据乱码问题的解决方法
android·数据库·excel
码农阿豪3 小时前
Windows从零到一安装KingbaseES数据库及使用ksql工具连接全指南
数据库·windows
时序数据说9 小时前
时序数据库市场前景分析
大数据·数据库·物联网·开源·时序数据库
听雪楼主.12 小时前
Oracle Undo Tablespace 使用率暴涨案例分析
数据库·oracle·架构
我科绝伦(Huanhuan Zhou)12 小时前
KINGBASE集群日常维护管理命令总结
数据库·database
妖灵翎幺12 小时前
Java应届生求职八股(2)---Mysql篇
数据库·mysql