You need to enable JavaScript to run this app.
Torch Log Service

Torch Log Service

Copy page
Download PDF
Machine learning function
Time series clustering functions
Copy page
Download PDF
Time series clustering functions
This topic introduces the syntax of time series clustering functions supported by TLS and provides usage examples for common scenarios.​
Notice​
Currently, machine learning functions are in public beta.​
Function list​
​
Function​
Description​
Use the density clustering method to cluster multiple time series curves.​
Cluster multiple time series curves using hierarchical clustering methods.​
Search time series curve that is similar to the specified time series curve.​
​
ts_density_cluster​
The ts_density_cluster function uses density-based clustering method to cluster multiple time series curves.​
Function syntax​
  • Syntax format​
  • ​
    ts_density_cluster(x, y, z) ​
    ​
  • Parameters description​
  • ​
    Parameters​
    Data type​
    Description​
    x​
    String​
    Column name of the time column. The format is a Unixtime timestamp; measured in seconds.​
    y​
    String​
    Column name of the value column. Each value represents the corresponding data at a specific time.​
    z​
    String​
    Name of the curve that corresponds to the data at a specific time.​
    ​
  • Return values​
  • If the input value is NULL, the function returns NULL.​
Function examples​
  • Query statements​
  • ​
    * | select ts_density_cluster(stamp, value,CAST( (stamp-stamp % 7200) as varchar) ) from (select stamp, value limit 1000)​
    ​
  • Query and analysis results​
  • ​​​
ts_hierarchical_cluster​
The ts_hierarchical_cluster function clusters multiple time series curves using hierarchical clustering.​
Function syntax​
  • Syntax format​
  • ​
    ts_hierarchical_cluster(x, y, z) ​
    ​
  • Parameters description​
  • ​
    Parameters​
    Data type​
    Description​
    x​
    String​
    Column name of the time column. The format is a Unixtime timestamp; measured in seconds.​
    y​
    String​
    Column name of the value column. Each value represents the corresponding data at a specific time.​
    z​
    String​
    Name of the curve that corresponds to the data at a specific time.​
    ​
  • Return values​
  • If the input value is NULL, the function returns NULL.​
Function examples​
  • Query statements​
  • ​
    * | select ts_hierarchical_cluster(stamp, value,CAST( (stamp-stamp % 6000) as varchar) ) from (select stamp, value limit 1000)​
    ​
  • Query and analysis results​
  • ​​​
ts_similar_instance​
The ts_similar_instance function queries time-series curves that is similar to the specified time-series curve.​
Function syntax​
  • Syntax format​
  • ​
    ts_similar_instance(x, y, z,instance_name,topK,metricType) ​
    ​
  • Parameters description​
  • ​
    Parameters​
    Data type​
    Description​
    x​
    String​
    The column name of the time column. The format is Unixtime timestamp; measured in seconds.​
    y​
    String​
    Column name of the value column. Each value represents the corresponding data at a specific time.​
    z​
    String​
    Name of the curve that corresponds to the data at a specific time.​
    instance_name​
    String​
    Specify name of the curve that needs to be searched. The curve must already exist.​
    topK​
    Long​
    The maximum number of curves returned that are similar to the given curve is K.​
    metricType​
    String​
    A metric for measuring the similarity between time series curves.​
    ​
  • Return values​
  • If the input value is NULL, the function returns NULL.​
Function examples​
  • Query and analysis statements​
  • ​
    * | select ts_similar_instance(stamp, value,CAST( (stamp-stamp % 6000) as varchar),CAST( (stamp-stamp % 6000) as varchar) ) from (select stamp, value limit 1000)​
    ​
  • Query and analysis results​
  • ​​​
​
​
Last updated: 2026.05.07 18:22:26