series_downsample_fl()
関数series_downsample_fl()
は、時系列を整数係数でダウンサンプリングするユーザー定義関数 (UDF) です。 この関数は、複数の時系列 (動的数値配列) を含むテーブルを取得し、各系列をダウンサンプリングします。 出力には、粗い系列とそれぞれの times 配列の両方が含まれます。 エイリアス化を回避するために、関数はサブサンプリングの前に各系列に単純なロー パス フィルターを適用します。
構文
T | invoke series_downsample_fl(
t_col,
y_col,
ds_t_col,
ds_y_col,
sampling_factor)
構文規則について詳しく知る。
パラメーター
名前 | 型 | 必須 | 説明 |
---|---|---|---|
t_col | string |
✔️ | ダウンサンプリングする系列の時間軸を含む列の名前。 |
y_col | string |
✔️ | ダウンサンプリングする系列を含む列の名前。 |
ds_t_col | string |
✔️ | 各系列のダウン サンプリングされた時間軸を格納する列の名前。 |
ds_y_col | string |
✔️ | ダウン サンプリングされた系列を格納する列の名前。 |
sampling_factor | int |
✔️ | 必要なダウン サンプリングを指定する整数。 |
関数の定義
関数を定義するには、次のように、コードをクエリ定義関数として埋め込むか、データベースに格納されている関数として作成します。
次の let ステートメントを使用して関数を定義します。 権限は必要ありません。
重要
let ステートメントは単独では実行できません。 その後に 表形式の式ステートメントを記述する必要があります。 の動作例を実行するには、「例series_downsample_fl()
」を参照してください。
let series_downsample_fl=(tbl:(*), t_col:string, y_col:string, ds_t_col:string, ds_y_col:string, sampling_factor:int)
{
tbl
| extend _t_ = column_ifexists(t_col, dynamic(0)), _y_ = column_ifexists(y_col, dynamic(0))
| extend _y_ = series_fir(_y_, repeat(1, sampling_factor), true, true) // apply a simple low pass filter before sub-sampling
| mv-apply _t_ to typeof(DateTime), _y_ to typeof(double) on
(extend rid=row_number()-1
| where rid % sampling_factor == ceiling(sampling_factor/2.0)-1 // sub-sampling
| summarize _t_ = make_list(_t_), _y_ = make_list(_y_))
| extend cols = bag_pack(ds_t_col, _t_, ds_y_col, _y_)
| project-away _t_, _y_
| evaluate bag_unpack(cols)
};
// Write your query to use the function here.
例
次の例では、 invoke 演算子 を使用して関数を実行します。
クエリ定義関数を使用するには、埋め込み関数定義の後にそれを呼び出します。
let series_downsample_fl=(tbl:(*), t_col:string, y_col:string, ds_t_col:string, ds_y_col:string, sampling_factor:int)
{
tbl
| extend _t_ = column_ifexists(t_col, dynamic(0)), _y_ = column_ifexists(y_col, dynamic(0))
| extend _y_ = series_fir(_y_, repeat(1, sampling_factor), true, true) // apply a simple low pass filter before sub-sampling
| mv-apply _t_ to typeof(DateTime), _y_ to typeof(double) on
(extend rid=row_number()-1
| where rid % sampling_factor == ceiling(sampling_factor/2.0)-1 // sub-sampling
| summarize _t_ = make_list(_t_), _y_ = make_list(_y_))
| extend cols = bag_pack(ds_t_col, _t_, ds_y_col, _y_)
| project-away _t_, _y_
| evaluate bag_unpack(cols)
};
demo_make_series1
| make-series num=count() on TimeStamp step 1h by OsVer
| invoke series_downsample_fl('TimeStamp', 'num', 'coarse_TimeStamp', 'coarse_num', 4)
| render timechart with(xcolumn=coarse_TimeStamp, ycolumns=coarse_num)
出力
4 でダウンサンプリングされた時系列:
参考までに、(ダウンサンプリングの前の) 元の時系列を次に示します。
demo_make_series1
| make-series num=count() on TimeStamp step 1h by OsVer
| render timechart with(xcolumn=TimeStamp, ycolumns=num)
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示