|

Non-Linear Data Modeling Basics

Non-Linear Data Modeling Basics

Version 15 | Created: 2026-09-23 | Updated: 2026-11-07 13:46 UTC

1. Purpose

  • Problem Statement: The linearity and the non-linearity of mathematical statistics and of a machine learning model, and the linear property and the non-linear property of the data, are not told apart, and the modeling strategy is confused as a result.
  • Goal: On the ground of linearity as mathematical statistics defines it, compare the modeling strategies that handle the non-linear data properties of machine learning, feature interaction included.
  • Non-Goal: The detail of each model is not covered.

2. Summary

The linearity of a model and the non-linear property of the data are two different things. Linearity is being first order in the weight $\beta$, and the non-linear property is the curvature of the relation between $x$ and $y$ together with the interaction between variables. A non-linear transform of the input therefore leaves the structure that is first order in $\beta$ in place, and least squares and the solutions of Ridge, Lasso and PLS are used as they are (section 4.2).

Who handles the non-linear property of the data splits the two modeling strategies.

  • Feature-Intensive Model: a linear model with non-linear features (the feature engineering approach). "Keep the model simple (linear) and make the data (feature) complex." A linear model fed with columns such as $x^2$ and $x_1 x_2$ that the analyst builds.
  • Algorithm-Intensive Model: a non-linear model with linear features (the algorithm approach). "Leave the data (feature) as it is (linear, original) and make the model complex (non-linear)." An approach where the original columns go in unchanged and a tree ensemble or a neural network learns the shape inside.

3. Taxonomy and its Hierarchy

Nonlinearity splits on three axes: the linearity of the model, the linearity of the feature, and the value you read out. The Feature-Intensive Model puts non-linear features into a linear model and reads the coefficient of each term, and the Algorithm-Intensive Model puts linear features into a non-linear model and reads variable importance. Fig 1 is those three axes and the methods on each side.

Nonlinearity in a model
|
+-- Feature-Intensive Model ........................ linear model + non-linear feature
|     +-- Power term: x^2, x^3 ..................... curvature of one variable
|     +-- Interaction term: x1 * x2 ................ joint effect of two variables
|     +-- Basis expansion: spline, RBF ............. local shape without a global degree
|
+-- Algorithm-Intensive Model ...................... non-linear model + linear feature
      +-- Tree ensemble ............................ split points cut the input space
      +-- Neural network ........................... activation function bends the response
      +-- Kernel method ............................ inner product in an implicit feature space

Fig 1. The composition of the two models and the methods on each side

The hierarchy of the two models descends by the strength of the assumption. The Feature-Intensive Model writes the shape of the nonlinearity down as terms in advance, and in return reads the coefficient of each term directly. The Algorithm-Intensive Model leaves the shape unwritten, and in return cannot read from a single coefficient which range of which variable moved the prediction.

3.1 Comparison

Table 1. Where each model sits on the three axes

Model Linearity Feature What you read out Breaks when
Feature-Intensive Model Linear Non-linear (transformed columns) Coefficient $\beta$ of each term The shape of the nonlinearity is unknown in advance
Algorithm-Intensive Model Non-linear Linear (original columns) Variable importance The extrapolation range and a small sample

The Feature-Intensive Model has the analyst decide which terms to build, so there has to be ground for guessing which curve and which interaction the data holds. The Algorithm-Intensive Model fits without that ground, but its accuracy drops in the extrapolation range and on a small sample (section 5.2).

4. Principle

4.1 Linear Model Mechanics and Limits

Models such as linear regression, Ridge, Lasso and PLS (Partial Least Squares) assume the relation between the input variable $X$ and the target variable $Y$ to be a linear combination.

$$y = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \dots + \beta_p x_p + \epsilon \hspace{19em} (1)$$
  • Advantage
    • The model is simple, so the risk of overfitting is small and the parameters converge very fast.
    • The coefficient $\beta_i$ tells directly how much each variable contributed to the change of the target.
  • Limit
    • When the data holds a non-linear relation or an interaction between variables, a decision boundary shaped as a first-order plane cannot fit that relation, and underfitting follows.

4.2 Nonlinear Features in a Linear Model

In a linear model, the mathematical definition of linearity is being first order in the weight parameter $\beta$, the target of the optimization, rather than first order in the input variable $x$.

An expansion of the input space by a non-linear transform therefore keeps the structure that is first order in $\beta$, and the closed-form solution of the linear model is used as it is.

With the original input data $x_1$ and $x_2$, non-linear power terms are added and the input is mapped onto a new basis.

$$\phi(x_1, x_2) = [1, x_1, x_2, x_1^2, x_2^2, x_1 x_2]^T \hspace{19em} (2)$$

The linear model is then fitted in this expanded space.

$$y = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \beta_3 x_1^2 + \beta_4 x_2^2 + \beta_5 (x_1 x_2) \hspace{14em} (3)$$
  • On the variable $x$: a non-linear model (a curve and an interaction surface are expressible)
  • On the weight $\beta$: a linear model (least squares, Ridge/Lasso regularization and the other existing algorithms apply unchanged)

The interaction term $x_1 x_2$ is non-linear in $x$. It is a product of two inputs, so it fails $f(a x + b z) = a f(x) + b f(z)$, and the response surface turns from a plane into a saddle.

The model of equation (3) carries the intercept $\beta_0$, so by the definition of linear algebra it is an affine transform, and the linearity used in engineering covers that affine case as well (Appendix C).

The coefficients of equation (3) are read the same way as the coefficients before the expansion. $\beta_3$ is the curvature of $x_1$ and $\beta_5$ is the contribution of the two variables moving together, and least squares fixes both.

4.3 Comparison of the Two Models

The two models differ in where the nonlinearity is held, in whether a coefficient can be read out, and in how the work grows with the variable count.

Table 2. The two models compared on three criteria

Criterion Feature-Intensive Model Algorithm-Intensive Model
Core mechanism Transform terms such as $x_1^2$ and $x_1 x_2$, added explicitly Automatic search by tree splits and activation functions
Explainability (XAI) Very high. Coefficient $\beta$ of each term, read directly Moderate to low. SHAP, variable importance and other added tools needed
Computational efficiency Good while the variables are few. Columns growing fast in high dimension Optimized for a large dataset

5. Application

5.1 Feature-Intensive Model

Ridge, Lasso and PLSRegression do the fitting, and the three methods of Fig 1 decide in front of them which columns go in.

  • Power term: the $x^2$ and $x^3$ columns of one variable. PolynomialFeatures(degree=3) builds every term up to the third degree, and the ones holding a single variable are the power terms.
  • Interaction term: the product column $x_1 x_2$ of two variables. When only the product is wanted, PolynomialFeatures(interaction_only=True) drops the power terms.
  • Basis expansion: a spline, which joins a polynomial per interval at the points that divide them, and RBF, which builds columns from the distance to a center. n_knots of SplineTransformer sets the interval count, and the curve of one interval changes without raising the degree.

The three methods share the conditions below.

  • Assumption: The shape of the nonlinearity to be held can be written as terms in advance.
  • Settings: The regularization strength alpha. The expanded columns differ in scale, so Ridge or Lasso bounds the coefficients.
  • Breaks when: The true relation lies outside the terms that were written down, and underfitting remains after the expansion. Raising the degree to catch it grows the column count fast, the overfitting risk rises sharply and the coefficients become unstable.
  • Where you meet it: A place where the data is small, physical ground, process variables for one, lets you guess the curvature and the interaction, and interpretation and root cause come before prediction accuracy.

5.2 Algorithm-Intensive Model

The original columns go in unchanged, and the three methods of Fig 1 build the nonlinearity inside the model.

  • Tree ensemble: it cuts the input space by splits and fits a constant per range. RandomForestRegressor, HistGradientBoostingRegressor, XGBoost and LightGBM belong here.
  • Neural network: the activation function bends the response at every layer and makes a continuous surface. MLPRegressor is the implementation.
  • Kernel method: instead of growing the columns it stands in for the expanded space through the inner product between samples. SVR(kernel='rbf') and KernelRidge are the implementations.

The three methods share the conditions below.

  • Assumption: The samples are many enough to fix the split positions and the weights. A tree ensemble fits a constant per range, so the sample count inside a range fixes the accuracy.
  • Settings: max_depth and the learning rate of the tree ensemble, the layer count and the activation function of the neural network, gamma and C of the kernel method.
  • Breaks when: For an input outside the train data a tree ensemble returns the constant of the last range and cannot extrapolate. A neural network overfits when the samples are few, a risk contained by hyperparameter tuning, and the work of a kernel method grows with the square of the sample count when they are many.
  • Where you meet it: A place where the data is sufficient, the variables are too many to write the terms one by one, and the prediction accuracy comes before reading the coefficients.

A run comparing the accuracy of the two models on the same data is in Appendix B.


Appendix A. Terminology

  • affine transform: A linear transform with a constant shift added. $y = ax + b$ with $b \neq 0$ belongs here.
  • basis expansion: A transform that turns the input variables into the values of predetermined functions and so grows the columns. Power terms, splines and RBF belong here.
  • closed-form solution: A solution obtained from one expression without iteration. The normal equation of least squares is an example.
  • interaction: A contribution that appears only when two variables move together. It is held by the product column $x_1 x_2$.
  • kernel method: A method that holds a non-linear relation through the inner product between two samples instead of transforming the input itself.
  • RBF: Radial basis function. A basis function whose value is fixed by the distance from a center.
  • SHAP: SHapley Additive exPlanations. An XAI method that splits the contribution of each variable to one prediction as a Shapley value.
  • spline: A function that joins low-degree polynomials at the points that divide the intervals.
  • tree ensemble: A model that collects the predictions of several decision trees. Random Forest and gradient boosting belong here.
  • underfitting: A state where the model lacks the capacity to express the relation and the error is large even on the training data.
  • XAI: Explainable AI. A method that makes the ground of a prediction readable by a person.

Appendix B. Python Implementation

The two models are applied to the same data and their accuracy compared.

import numpy as np
from sklearn.ensemble import HistGradientBoostingRegressor
from sklearn.linear_model import Ridge
from sklearn.metrics import r2_score
from sklearn.model_selection import train_test_split
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import PolynomialFeatures

# --- synthetic data with one curvature term and one interaction term ---
rng = np.random.default_rng(0)
n_samples = 400
x1 = rng.uniform(-3, 3, size=n_samples)
x2 = rng.uniform(-3, 3, size=n_samples)
y = 3 + 2 * x1 - x2 + 1.5 * x1 ** 2 + 0.8 * x1 * x2 + rng.normal(0, 1.0, size=n_samples)

X = np.column_stack([x1, x2])
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=0)

# the baseline: a linear model on the original columns
plain = Ridge(alpha=1.0).fit(X_train, y_train)

# the feature-intensive model: the analyst adds the power and interaction columns
feature_intensive = make_pipeline(
    PolynomialFeatures(degree=2, include_bias=False), Ridge(alpha=1.0)
).fit(X_train, y_train)

# the algorithm-intensive model: the algorithm splits the original columns on its own
algorithm_intensive = HistGradientBoostingRegressor(max_depth=3, random_state=0).fit(X_train, y_train)

for name, model in (("linear model, original columns", plain),
                    ("feature-intensive: Ridge on degree-2 columns", feature_intensive),
                    ("algorithm-intensive: HistGradientBoostingRegressor", algorithm_intensive)):
    print(f"{name:50s} R2 = {r2_score(y_test, model.predict(X_test)):.4f}")

# the coefficients the feature-intensive model reads out, one per term of equation (3)
term_names = feature_intensive[0].get_feature_names_out(["x1", "x2"])
print("feature-intensive coefficients:",
      dict(zip(term_names, np.round(feature_intensive[1].coef_, 3))))

The first three lines are the held-out $R^2$ of the three models, and the last line is the coefficient of each term that the Feature-Intensive Model reads out.

linear model, original columns                     R2 = 0.4735
feature-intensive: Ridge on degree-2 columns       R2 = 0.9782
algorithm-intensive: HistGradientBoostingRegressor R2 = 0.9689
feature-intensive coefficients: {'x1': np.float64(1.963), 'x2': np.float64(-1.015), 'x1^2': np.float64(1.516), 'x1 x2': np.float64(0.76), 'x2^2': np.float64(0.005)}

Four coefficients recovered 2, -1, 1.5 and 0.8, the coefficients of the expression that made the data, and the coefficient of $x_2^2$, which that expression does not carry, stayed at 0.005.

Appendix C. Two Views of Linearity

  • Linearity in linear algebra: additivity ($f(x+y)=f(x)+f(y)$) and homogeneity ($f(cx)=cf(x)$) have to hold, and the map has to pass through the origin ($y=ax+b$ with $b \neq 0$ is an affine transform).
  • Linearity in a domain or in engineering: a straight-line and proportional relation, used in a wider sense than the strict definition of linear algebra.

Non-Linear Data Modeling Basics

Version 20 | Created: 2026-09-23 | Updated: 2026-11-07 13:46 UTC

1. Purpose

  • Problem Statement: 수리통계와 machine learning model 의 선형성 (linearity) 과 비선형성 (non-linearity), 그리고 data 의 선형 특성 (linear property) 과 비선형 특성 (non-linear property) 의 차이에 대한 이해가 부족하여 modeling 전략이 혼란하다.
  • Goal: 수리통계학적 선형성 (linearity) 을 바탕으로, machine learning 에서 변수 사이의 상호작용 (feature interaction) 을 포함하는 비선형 data 특성을 다루는 modeling 전략을 비교 분석한다.
  • Non-Goal: Model 상세는 다루지 않는다.

2. Summary

Model 의 선형성과 data 의 비선형 특성은 서로 다른 대상입니다. 선형성은 가중치 $\beta$ 에 대한 1차성이고, 비선형 특성은 $x$ 와 $y$ 사이 관계의 곡률과 변수 사이의 interaction 입니다. 그래서 입력을 비선형으로 변환해도 $\beta$ 에 대한 1차 구조는 남고, 최소제곱법과 Ridge, Lasso, PLS 의 해법을 그대로 사용합니다 (4.2 절).

비선형 data 특성을 누가 담당하는지가 두 modeling 전략을 가릅니다.

  • Feature-Intensive Model: 선형 모델 + 비선형 Feature (특성 공학 접근법). "모델은 단순 (선형) 하게 두고, 데이터 (Feature) 를 복잡하게 만든다." 분석가가 $x^2$, $x_1 x_2$ 같은 열을 만들어 넣는 선형 모델입니다.
  • Algorithm-Intensive Model: 비선형 모델 + 선형 Feature (알고리즘 접근법). "데이터 (Feature) 는 있는 그대로 (선형/원본) 두고, 모델을 복잡 (비선형) 하게 만든다." 원본 열을 그대로 넣고 tree ensemble 이나 neural network 가 내부에서 학습하는 접근입니다.

3. Taxonomy and its Hierarchy

비선형성은 model 의 선형성, feature 의 선형성, 읽어 내는 값의 세 축으로 갈립니다. Feature-Intensive Model 은 선형 model 에 비선형 feature 를 넣어 항마다의 계수를 읽고, Algorithm-Intensive Model 은 비선형 model 에 선형 feature 를 넣어 변수 중요도를 읽습니다. Fig 1 이 그 세 축과 각 model 에 속한 방법입니다.

Nonlinearity in a model
|
+-- Feature-Intensive Model ........................ linear model + non-linear feature
|     +-- Power term: x^2, x^3 ..................... curvature of one variable
|     +-- Interaction term: x1 * x2 ................ joint effect of two variables
|     +-- Basis expansion: spline, RBF ............. local shape without a global degree
|
+-- Algorithm-Intensive Model ...................... non-linear model + linear feature
      +-- Tree ensemble ............................ split points cut the input space
      +-- Neural network ........................... activation function bends the response
      +-- Kernel method ............................ inner product in an implicit feature space

Fig 1. The composition of the two models and the methods on each side

두 model 의 계층은 가정의 강도로 내려갑니다. Feature-Intensive Model 은 비선형의 형태를 항으로 미리 적어 두는 대신 그 항의 계수를 그대로 읽습니다. Algorithm-Intensive Model 은 형태를 적지 않아도 되는 대신, 어느 변수의 어느 구간이 예측을 움직였는지를 계수 하나로 읽지 못합니다.

3.1 Comparison

Table 1. Where each model sits on the three axes

Model Linearity Feature What you read out Breaks when
Feature-Intensive Model 선형 비선형 (변환된 열) 항마다의 계수 $\beta$ 비선형의 형태를 미리 알 수 없을 때
Algorithm-Intensive Model 비선형 선형 (원본 열) 변수 중요도 외삽 구간과 적은 표본에서

Feature-Intensive Model 은 어떤 항을 만들지를 분석가가 정하므로, 자료에 어떤 곡선과 어떤 interaction 이 있는지 짐작할 근거가 있어야 합니다. Algorithm-Intensive Model 은 그 근거 없이도 적합하지만, 외삽 구간과 적은 표본에서 정확도가 떨어집니다 (5.2 절).

4. Principle

4.1 Linear Model Mechanics and Limits

선형 회귀, Ridge, Lasso, PLS (Partial Least Squares) 등의 모델은 입력 변수 $X$ 와 target 변수 $Y$ 의 관계를 선형 결합 (Linear Combination) 으로 가정합니다.

$$y = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \dots + \beta_p x_p + \epsilon \hspace{19em} (1)$$
  • 장점
    • 모델이 단순하여 과적합 (Overfitting) 위험이 적고, parameter 수렴 속도가 매우 빠릅니다.
    • 계수 $\beta_i$ 를 통해 어떤 변수가 target 변화에 얼마큼 기여했는지 직관적으로 해석 가능합니다.
  • 한계
    • 데이터에 곡선 관계가 존재하거나 변수 사이에 interaction 이 있으면, 1 차 평면 형태의 예측 경계 (Decision Boundary) 로는 그 관계를 적합할 수 없어 underfitting 이 발생합니다.

4.2 Nonlinear Features in a Linear Model

선형 모델에서 '선형 (Linearity)' 의 수학적 정의는 입력 변수 $x$ 에 대한 1차식이 아니라, 최적화 대상인 가중치 $\beta$ 에 대해 1차식임을 의미합니다.

따라서 입력 공간을 비선형 변환하여 확장하더라도, $\beta$ 에 대한 1차 구조는 유지되므로 선형 모델의 해법 (Closed-form solution) 을 그대로 사용할 수 있습니다.

원래 입력 데이터가 $x_1$, $x_2$ 일 때, 비선형 차수 항을 추가하여 새로운 기저 (Basis) 로 옮깁니다.

$$\phi(x_1, x_2) = [1, x_1, x_2, x_1^2, x_2^2, x_1 x_2]^T \hspace{19em} (2)$$

이후 이 확장된 공간에서 선형 모델을 적합합니다.

$$y = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \beta_3 x_1^2 + \beta_4 x_2^2 + \beta_5 (x_1 x_2) \hspace{14em} (3)$$
  • 변수 $x$ 기준: 비선형 모델 (곡선 및 상호작용 곡면 표현 가능)
  • 가중치 $\beta$ 기준: 선형 모델 (최소제곱법, Ridge/Lasso 규제 등 기존 알고리즘 그대로 적용)

상호작용 항 $x_1 x_2$ 는 $x$ 에 대해 비선형입니다. 두 입력의 곱이므로 $f(a x + b z) = a f(x) + b f(z)$ 를 만족하지 않고, 반응면이 평면에서 안장 모양의 곡면으로 바뀝니다.

식 (3) 의 model 은 절편 $\beta_0$ 를 가지므로 선형대수의 정의로는 affine transform 이고, 공학에서 쓰는 선형은 그 affine transform 까지 포함합니다 (Appendix C).

식 (3) 의 계수는 확장 전의 계수와 같은 방식으로 읽습니다. $\beta_3$ 은 $x_1$ 의 곡률이고 $\beta_5$ 는 두 변수가 함께 움직일 때의 기여이며, 둘 다 최소제곱법이 정합니다.

4.3 Comparison of the Two Models

두 model 은 비선형을 담는 자리, 계수를 읽어 낼 수 있는지, 변수 수에 따른 연산량에서 갈립니다.

Table 2. The two models compared on three criteria

Criterion Feature-Intensive Model Algorithm-Intensive Model
핵심 메커니즘 $x_1^2$, $x_1 x_2$ 등 변환 항을 명시적으로 추가 Tree 분기와 활성화 함수로 자동 탐색
설명 가능성 (XAI) 매우 높음. 항마다의 계수 $\beta$ 를 직접 확인 보통에서 낮음. SHAP, 변수 중요도 등 부가 도구 필요
연산 효율성 변수 수가 적을 때 우수. 고차원에서 열 수가 급증 대용량 dataset 처리에 최적화

5. Application

5.1 Feature-Intensive Model

적합은 Ridge, Lasso, PLSRegression 이 맡고, Fig 1 의 세 방법이 그 앞에서 넣을 열을 정합니다.

  • Power term: 한 변수의 $x^2$, $x^3$ 열. PolynomialFeatures(degree=3) 이 3 차까지의 항을 모두 만들며, 그 가운데 변수 하나만 든 항이 power term 입니다.
  • Interaction term: 두 변수의 곱 $x_1 x_2$ 열. 곱만 필요하면 PolynomialFeatures(interaction_only=True) 가 제곱 항을 뺍니다.
  • Basis expansion: 구간을 나누는 점마다 다항식을 잇는 spline 과, 중심에서의 거리로 열을 만드는 RBF. SplineTransformer 의 n_knots 가 구간 수를 정하며, degree 를 올리지 않고 한 구간의 곡선만 바꿉니다.

세 방법에 공통인 조건입니다.

  • 가정: 담을 비선형의 형태를 항으로 미리 적을 수 있습니다.
  • 설정값: Regularization 강도 alpha. 확장한 열은 규모가 달라지므로 Ridge 나 Lasso 로 계수를 제한합니다.
  • 깨지는 조건: 참된 관계가 적어 둔 항 밖에 있으면 확장 후에도 underfitting 이 남습니다. Degree 를 높여 맞추면 열 수가 급히 늘어 과적합 위험이 급격히 커지고 계수가 흔들립니다.
  • 만나는 자리: 데이터 양이 적고, 공정 변수처럼 물리적 근거로 곡률과 interaction 을 짐작할 수 있으며, 해석과 원인 규명이 예측 정확도보다 앞서는 자리입니다.

5.2 Algorithm-Intensive Model

원본 열을 그대로 받고, Fig 1 의 세 방법이 model 안에서 비선형을 만듭니다.

  • Tree ensemble: 입력 공간을 분기로 잘라 구간마다 상수를 적합합니다. RandomForestRegressor, HistGradientBoostingRegressor, XGBoost, LightGBM 이 여기에 속합니다.
  • Neural network: 활성화 함수가 층마다 응답을 굽혀 연속한 곡면을 만듭니다. MLPRegressor 가 그 구현입니다.
  • Kernel method: 열을 늘리는 대신 표본 사이의 내적으로 확장한 공간을 대신합니다. SVR(kernel='rbf') 와 KernelRidge 가 그 구현입니다.

세 방법에 공통인 조건입니다.

  • 가정: 표본이 분기 위치와 가중치를 정할 만큼 많습니다. Tree ensemble 은 구간마다 상수를 적합하므로 구간 안의 표본 수가 정확도를 정합니다.
  • 설정값: Tree ensemble 의 max_depth 와 learning rate, neural network 의 층 수와 활성화 함수, kernel method 의 gamma 와 C.
  • 깨지는 조건: Train data 밖의 입력에서 tree ensemble 은 마지막 구간의 상수를 그대로 내놓아 외삽하지 못합니다. 표본이 적으면 neural network 가 과적합하며, 그 위험은 hyperparameter 조절로 완화합니다. 표본이 많으면 kernel method 의 계산량이 표본 수의 제곱으로 늘어납니다.
  • 만나는 자리: 데이터 양이 충분하고, 변수 수가 많아 항을 일일이 적기 어려우며, 예측 정확도가 계수 해석보다 앞서는 자리입니다.

두 model 의 정확도를 같은 data 에서 비교한 실행이 Appendix B 에 있습니다.


Appendix A. Terminology

  • affine transform: 선형 변환에 상수 이동을 더한 변환. $y = ax + b$ 에서 $b \neq 0$ 이면 여기에 속한다.
  • basis expansion: 입력 변수를 미리 정한 함수의 값으로 바꾸어 열을 늘리는 변환. Power term, spline, RBF 가 여기에 속한다.
  • closed-form solution: 반복 없이 식 하나로 얻는 해. 최소제곱법의 정규방정식이 그 예이다.
  • interaction: 두 변수가 함께 움직일 때만 나타나는 기여. 곱한 열 $x_1 x_2$ 로 담는다.
  • kernel method: 입력을 직접 변환하지 않고 두 표본 사이의 내적으로 비선형 관계를 담는 방법.
  • RBF: Radial basis function. 중심에서의 거리로 값이 정해지는 기저 함수.
  • SHAP: SHapley Additive exPlanations. 각 변수가 한 예측에 기여한 몫을 Shapley value 로 나누어 내놓는 XAI 방법.
  • spline: 구간을 나누는 점마다 낮은 차수의 다항식을 이어 붙인 함수.
  • tree ensemble: 여러 결정 tree 의 예측을 모아 쓰는 model. Random Forest 와 gradient boosting 이 여기에 속한다.
  • underfitting: Model 의 표현력이 모자라 training data 에서도 오차가 큰 상태.
  • XAI: Explainable AI. Model 이 내놓은 예측의 근거를 사람이 읽을 수 있게 하는 방법.

Appendix B. Python Implementation

두 model 을 같은 data 에 적용해 정확도를 비교합니다.

import numpy as np
from sklearn.ensemble import HistGradientBoostingRegressor
from sklearn.linear_model import Ridge
from sklearn.metrics import r2_score
from sklearn.model_selection import train_test_split
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import PolynomialFeatures

# --- synthetic data with one curvature term and one interaction term ---
rng = np.random.default_rng(0)
n_samples = 400
x1 = rng.uniform(-3, 3, size=n_samples)
x2 = rng.uniform(-3, 3, size=n_samples)
y = 3 + 2 * x1 - x2 + 1.5 * x1 ** 2 + 0.8 * x1 * x2 + rng.normal(0, 1.0, size=n_samples)

X = np.column_stack([x1, x2])
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=0)

# the baseline: a linear model on the original columns
plain = Ridge(alpha=1.0).fit(X_train, y_train)

# the feature-intensive model: the analyst adds the power and interaction columns
feature_intensive = make_pipeline(
    PolynomialFeatures(degree=2, include_bias=False), Ridge(alpha=1.0)
).fit(X_train, y_train)

# the algorithm-intensive model: the algorithm splits the original columns on its own
algorithm_intensive = HistGradientBoostingRegressor(max_depth=3, random_state=0).fit(X_train, y_train)

for name, model in (("linear model, original columns", plain),
                    ("feature-intensive: Ridge on degree-2 columns", feature_intensive),
                    ("algorithm-intensive: HistGradientBoostingRegressor", algorithm_intensive)):
    print(f"{name:50s} R2 = {r2_score(y_test, model.predict(X_test)):.4f}")

# the coefficients the feature-intensive model reads out, one per term of equation (3)
term_names = feature_intensive[0].get_feature_names_out(["x1", "x2"])
print("feature-intensive coefficients:",
      dict(zip(term_names, np.round(feature_intensive[1].coef_, 3))))

첫 세 줄이 세 model 의 held-out $R^2$ 이고, 마지막 줄이 Feature-Intensive Model 이 읽어 내는 항마다의 계수입니다.

linear model, original columns                     R2 = 0.4735
feature-intensive: Ridge on degree-2 columns       R2 = 0.9782
algorithm-intensive: HistGradientBoostingRegressor R2 = 0.9689
feature-intensive coefficients: {'x1': np.float64(1.963), 'x2': np.float64(-1.015), 'x1^2': np.float64(1.516), 'x1 x2': np.float64(0.76), 'x2^2': np.float64(0.005)}

계수 네 개는 data 를 만든 식의 계수 2, -1, 1.5, 0.8 을 되찾았고, 식에 없던 $x_2^2$ 의 계수는 0.005 로 남았습니다.

Appendix C. Two Views of Linearity

  • 선형대수학의 선형성: 가산성 ($f(x+y)=f(x)+f(y)$) 과 동차성 ($f(cx)=cf(x)$) 을 만족해야 하며, 반드시 원점을 지나야 함 ($y=ax+b$ 에서 $b \neq 0$ 이면 affine transform).
  • 도메인/공학에서의 선형성: 직선 및 비례 관계를 의미하며, 선형대수의 엄밀한 정의보다 확장된 의미로 사용됨.

Our Score
Click to rate this post!
[Total: 1 Average: 2]
Visited 19 times, 1 visit(s) today

2 Comments

  1. I truly enjoyed reading this thoughtful article. The information is accurate, relevant, and presented with excellent organization. Thank you for continuously providing readers with dependable educational resources.

Leave a Comment

Your email address will not be published. Required fields are marked *