メインコンテンツへスキップ
メインコンテンツへスキップ

simpleLinearRegression

simpleLinearRegression

導入: v20.1

単回帰(1次元の線形回帰)を実行します。

構文

simpleLinearRegression(x, y)

引数

  • x — 説明変数の値を含むカラム。Float64
  • y — 従属変数の値を含むカラム。Float64

返り値

結果となる直線 y = k*x + b の係数 (k, b) を返します。Tuple(Float64, Float64)

完全な線形当てはめ

SELECT arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [0, 1, 2, 3]);
┌─arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [0, 1, 2, 3])─┐
│ (1,0)                                                             │
└───────────────────────────────────────────────────────────────────┘

切片付き線形フィット

SELECT arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [3, 4, 5, 6]);
┌─arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [3, 4, 5, 6])─┐
│ (1,3)                                                             │
└───────────────────────────────────────────────────────────────────┘