时序模型变量Time Series Model variables

本文介绍了时序见解变量,这些变量指定事件的公式和计算规则。This article describes the Time Series Model variables that specify formula and computation rules on events.

每个变量可以是以下三个种类之一:数字、分类和聚合。 Each variable can be one of three kinds: numeric, categorical, and aggregate.

  • “数字”种类适用于连续数值。Numeric kinds work with continuous numeric values.
  • “分类”种类适用于一组定义的离散值。Categorical kinds work with a defined set of discrete values.
  • “聚合”种类组合单个种类(要么全为数字,要么全为分类)的多个变量。Aggregate kinds combine multiple variables of a single kind (either all numeric or all categorical).

下表显示了每个变量种类的相关属性。The following table displays which properties are relevant for each variable kind.

时序模型变量表Time Series Model variable table

数字变量Numeric variables

变量属性Variable property 说明Description
变量筛选器Variable filter 筛选器是可选的条件子句,用于限制可在计算中考虑的行数。Filters are optional conditional clauses to restrict the number of rows being considered for computation.
变量值Variable value 来自设备或传感器的,或使用时序表达式进行转换的用于计算的遥测值。Telemetry values used for computation coming from the device or sensors or transformed by using Time Series Expressions. 数字种类变量的类型必须为 DoubleNumeric kind variables must be of the type Double.
变量内插Variable interpolation 内插指定如何使用现有数据重构信号。Interpolation specifies how to reconstruct a signal by using existing data. StepLinear 内插选项适用于数字变量。Step and Linear interpolation options are available for numeric variables.
变量聚合Variable aggregation 通过“数字”变量种类支持的聚合函数执行计算。Perform computations through the supported aggregation functions for Numeric variable kinds.

变量符合以下 JSON 示例:Variables conform to the following JSON example:

"Interpolated Speed": {
  "kind": "numeric",
  "value": {
    "tsx": "$event['Speed-Sensor'].Double"
  },
  "filter": null,
  "interpolation": {
    "kind": "step",
    "boundary": {
      "span": "P1D"
    }
  },
  "aggregation": {
    "tsx": "right($value)"
  }
}

分类变量Categorical variables

变量属性Variable property 说明Description
变量筛选器Variable filter 筛选器是可选的条件子句,用于限制可在计算中考虑的行数。Filters are optional conditional clauses to restrict the number of rows being considered for computation.
变量值Variable value 来自设备或传感器的用于计算的遥测值。Telemetry values used for computation coming from the device or sensors. 分类种类变量的类型必须是 LongStringCategorical kind variables must be either Long or String.
变量内插Variable interpolation 内插指定如何使用现有数据重构信号。Interpolation specifies how to reconstruct a signal by using existing data. Step 内插选项适用于分类变量。The Step interpolation option is available for categorical variables.
变量类别Variable categories 类别在来自设备或传感器的值与某个标签之间创建映射。Categories create a mapping between the values coming from the device or sensors to a label.
变量的默认类别Variable default category 默认类别适用于“categories”属性中未映射的所有值。The default category is for all values that aren't being mapped in the "categories" property.

变量符合以下 JSON 示例:Variables conform to the following JSON example:

"Status": {
  "kind": "categorical",
  "value": {
     "tsx": "$event.Status.Long"
},
  "interpolation": {
    "kind": "step",
    "boundary": {
      "span" : "PT1M"
    }
  },
  "categories": [
    {
      "values": [0, 1, 2, 3],
      "label": "Good"
    },
    {
      "values": [4],
      "label": "Bad"
    }
  ],
  "defaultCategory": {
    "label": "Not Applicable"
  }
}

聚合变量Aggregate variables

变量属性Variable property 说明Description
变量筛选器Variable filter 筛选器是可选的条件子句,用于限制可在计算中考虑的行数。Filters are optional conditional clauses to restrict the number of rows being considered for computation.
变量聚合Variable aggregation 通过“聚合”变量种类支持的聚合函数执行计算。Perform computations through the supported aggregation functions for Aggregate variable kinds.

变量符合以下 JSON 示例:Variables conform to the following JSON example:

"Speed Range": {
  "kind": "aggregate",
  "filter": null,
  "aggregation": {
    "tsx": "max($event.Speed.Double) - min($event.Speed.Double)"
  }
}

变量存储在时序模型的类型定义中,可以通过 API以内联方式提供,以重写或补充已存储的定义。Variables are stored in the type definition of a time series model and can be provided inline via APIs to override or complement the stored definition.

后续步骤Next steps