Skip to content

Predict PVs

Time series prediction function: select ts_regression_predict(x, y, nPred, algotype,processType). The x parameter specifies the time sequence. Points in time are sorted in ascending order. Each point in time is a UNIX timestamp. Unit: seconds. The y parameter specifies the sequence of numeric data at a specific point in time. The nPred parameter specifies the number of points for prediction. The value is of the long type. Valid values: 1 to 500. The algotype parameter specifies the type of the prediction algorithm. Valid values: origin: uses the Gradient Boosted Regression Tree (GBRT) algorithm for prediction. forest: uses the GBRT algorithm for prediction based on the trend component decomposed by Seasonal and Trend decomposition using Loess (STL), and then uses the additive model to sum up the decomposed components and obtain the predicted data. linear: uses the Linear Regression algorithm for prediction based on the trend components decomposed by STL, and then uses the additive model to sum up the decomposed components and obtain the predicted data. The processType parameter specifies the preprocessing process for the data. Valid values: 0: requires no additional data preprocessing. 1: removes abnormal data before prediction.

SQL
*
and table: nginx_access |
select
  ts_regression_predict(stamp, value, 100, 'auto', 1, 'avg')
from
  (
    select
      stamp - stamp % 2400 as stamp,
      avg(value) as value
    from
      log
    GROUP by
      stamp
    order by
      stamp
    limit
      10000
  )

SQLSample query result:

样例图片