Keyboard shortcuts

Press ← or → to navigate between chapters

Press ? to show this help

Press Esc to hide this help

polynomial_regression: 다항 곡선 적합

foundryts.functions.polynomial_regression(
    max_degree=0, time_unit='ns', start=None, end=None
)

숫자형 시계열 하나에 y = a0 + a1*x + a2*x^2 + ... + an*x^n 형태의 다항식을 적합하는 함수를 반환합니다. 선형보다 복잡한 경향을 표현하며 입력은 FunctionNode, 결과는 SummarizerNode입니다.

인수

인수형식기본값과 의미
max_degreeint0. 적합할 다항식의 최대 차수. 예를 들어 2는 이차 다항식
time_unitstrns. 계수의 시간 단위로 s, ms, us, ns 중 선택
startstr, int 또는 datetime.datetimeNone. 시작 시각 포함
endstr, int 또는 datetime.datetimeNone. 종료 시각 제외

범주형 시계열에는 적용하지 않습니다.

결과 필드

계수 배열은 DataFrame에서 차수별 행으로 펼쳐집니다.

열형식의미
min_bounds.first_valuefloat회귀 대상 x좌표의 최솟값
max_bounds.first_valuefloat회귀 대상 x좌표의 최댓값
min_bounds.second_valuefloat회귀 대상 y값의 최솟값
max_bounds.second_valuefloat회귀 대상 y값의 최댓값
regression_fit_function.polynomial_regression_fit.coefficients.coefficientfloat계수 값
regression_fit_function.polynomial_regression_fit.coefficients.degreeint해당 계수의 차수

bounds는 관측 좌표의 범위이며 다항 계수의 최댓값이나 최솟값이 아닙니다.

가상 관측에 3차식 적합

import foundryts.functions as F

series = F.points(
    (10, 6.0),
    (20, 12.0),
    (30, 24.0),
    (40, 48.0),
    (50, 96.0),
    name="series",
)
regression = F.polynomial_regression(max_degree=3)(series)
regression_df = regression.to_pandas()

정수 시각은 나노초입니다. 가상 결과의 계수는 다음과 같습니다.

degreecoefficient
0-4.800000
11.585714
2-0.066429
30.001500

각 행에는 같은 좌표 범위가 함께 들어갑니다.

필드값
min_bounds.first_value10.0
max_bounds.first_value50.0
min_bounds.second_value6.0
max_bounds.second_value96.0

직선은 linear_regression, 지수 곡선은 exponential_regression으로 적합할 수 있습니다.