← Playground← 놀이터

PRISM · Machine Learning PlaygroundPRISM · 머신러닝 놀이터

The Kernel Trick커널 트릭
Bend the boundary by lifting data into a richer space — without ever going there데이터를 더 풍부한 공간으로 들어올려 경계를 휘게 한다 — 실제로 그 공간에 가지 않고

A linear model can only draw a straight boundary. Map each point through a feature map φ(x) into a higher-dimensional space and a plane there becomes a curve back here. The kernel k(x,z) = φ(x)·φ(z) computes that inner product directly — so you get the rich boundary while never building φ. This demo fits a real kernel model; watch the curve appear.선형 모델은 직선 경계만 그릴 수 있다. 각 점을 특징 사상 φ(x)로 더 높은 차원에 보내면 그곳의 평면이 여기서는 곡선이 된다. 커널 k(x,z) = φ(x)·φ(z)은 그 내적을 직접 계산한다 — 그래서 φ를 만들지 않고도 풍부한 경계를 얻는다. 이 데모는 실제 커널 모델을 적합한다; 곡선이 나타나는 것을 보라.

Input space · decision boundary입력 공간 · 결정 경계 f(x) = Σ αᵢ k(x, xᵢ)
class +1클래스 +1 class −1클래스 −1 boundary f = 0경계 f = 0
Score space f(x) — a single threshold at 0점수 공간 f(x) — 0에서의 단일 임계값 the kernel makes it linearly separable커널이 선형 분리를 가능케 한다
f < 0 → −1f < 0 → −1f = 0f > 0 → +1f > 0 → +1
Controls제어판

Dataset데이터셋

Kernel k(x, z)커널 k(x, z)

RBF width γRBF 폭 γ e−γ‖x−z‖² 4.0
Regularization λ정규화 λ ridge릿지 0.100
Rings + Linear kernel fails; switch to RBF and the boundary curves into a circle.동심원 + 선형 커널은 실패; RBF로 바꾸면 경계가 원으로 휜다.
Measurements측정값 Separated
train accuracy훈련 정확도
100.0%
kernel커널
RBF
feature dim특징 차원
points N점 개수 N
68
margin proxy마진 근사
0.784
misclassified오분류
0
Things to try해볼 것들
  1. Linear can't: pick Rings with the Linear kernel — accuracy stalls near 50%. A straight line can't enclose a circle.선형은 불가: 동심원선형 커널 — 정확도가 50% 근처에 머문다. 직선은 원을 감쌀 수 없다.
  2. RBF rescues it: switch to RBF — the boundary bends into a closed curve and accuracy jumps to 100%.RBF가 구제: RBF로 바꾸면 경계가 닫힌 곡선으로 휘고 정확도가 100%로 뛴다.
  3. Over-fitting: push γ very high — the model grows tiny islands around each point. Raise λ to smooth it back.과적합: γ를 아주 높이면 각 점 주위로 작은 섬이 생긴다. λ를 올려 다시 매끄럽게.
  4. Degree matters: for XOR, a Polynomial of degree 2 already separates — the feature x₁x₂ is enough.차수의 힘: XOR다항 차수 2면 이미 분리된다 — 특징 x₁x₂ 하나로 충분.

A dot product in disguise변장한 내적

A kernel is an inner product in some feature space: k(x,z) = φ(x)·φ(z). The polynomial kernel corresponds to an explicit finite φ (all monomials up to degree d); the RBF kernel corresponds to an infinite-dimensional φ. You never compute φ — only the N×N kernel matrix.커널은 어떤 특징 공간에서의 내적이다: k(x,z) = φ(x)·φ(z). 다항 커널은 명시적 유한 φ(차수 d까지의 모든 단항식)에, RBF 커널은 무한 차원 φ에 대응한다. φ는 절대 계산하지 않고 N×N 커널 행렬만 다룬다.

The representer theorem표현자 정리

The solution is always a weighted sum of kernels centered on the data: f(x) = Σ αᵢ k(x, xᵢ). Here we solve kernel ridge regression, α = (K + λI)⁻¹ y — one linear system in the N training points, no matter how large the feature space is.해는 언제나 데이터에 중심을 둔 커널들의 가중합이다: f(x) = Σ αᵢ k(x, xᵢ). 여기서는 커널 릿지 회귀 α = (K + λI)⁻¹ y를 푼다 — 특징 공간이 아무리 커도 훈련점 N개에 대한 선형계 하나다.

Power, and its price힘, 그리고 대가

Kernels give nonlinear power to any linear method — SVMs, ridge, PCA — and underpin brain-decoding and connectivity classifiers where samples are few but structure is rich. The cost is the N×N matrix: memory and compute scale with the number of points, so kernels shine on small-to-medium data.커널은 어떤 선형 기법(SVM·릿지·PCA)에도 비선형의 힘을 준다 — 표본은 적지만 구조가 풍부한 뇌 디코딩·연결성 분류에서 특히 유용하다. 대가는 N×N 행렬이다: 메모리·연산이 점 개수에 비례하므로, 커널은 중소 규모 데이터에서 빛난다.