Kernel in Linear Algebra / Inner Product Space / Hyperplane / SVM / Kernel Function / Normed vector space / Metric Space
Kernel in Linear Algebra: Part 1Permalink
在 Chapter 6, Digest of Essence of Linear Algebra 有讲:
The null space of matrix
is the set of all vectors such that
这里我们用函数的观点展开讲一讲。
Wikipedia: Kernel (linear algebra): The kernel (also known as null space or nullspace) of a linear map (i.e. linear transformation)
A linear map is essentially a function,so we can define:
is the image of in (注意有 )- The image of
is (所以 是 的子空间)
Two elements of
The image of
- In linear algebra, the quotient ([ˈkwəʊʃənt], 商) of a vector space
by a subspace is a vector space obtained by “collapsing” to zero. The space obtained is called a quotient space and is denoted (read mod or by ). - Morphism refers to a structure-preserving map from one mathematical structure to another.
- In universal algebra and in model theory, a structure consists of a set along with a collection of finitary operations (an operation that takes a finite number of input values) and relations that are defined on it.
- Structure 的大类有 groups (群), rings (环), fields (域,比如实数域) and vector spaces
- 比如 Vector space 的定义就是 vector 的集合以及定义在 vector 上的 add、multiply 的操作
- structure-preserving 的意思就是你的 mapping 不能跳出 structure 的范围
- Isomorphism is a morphism that can be reversed by an inverse morphism
This implies the rank–nullity theorem:
where, by rank we mean the dimension of
- vector space 的 demension 即 basis vector 的个数
举个例子:
- 相当于把
这个圆压扁到 x-axis
- 相当于把
,即 y-axis 上的所有 vector
Inner Product SpacePermalink
Given a vector space
- (Positivity or Positive Definiteness):
- (Linearity):
- (Conjugate Symmetry):
- conjugate 这个词的意义有很多,比如:
是 的 conjugate 是 的 conjugate 是 的 conjugate
- conjugate 这个词的意义有很多,比如:
很多地方把 inner product 这个 operation 写作
从 inner product 的定义来看,dot product 是 inner product 的一种,即 dot product 可以通过 inner product 定义:
我们知道 Vector space 的定义就是 vector 的集合以及定义在 vector 上的 add、multiply 的操作;如果我们在 vector space 的基础上再加上一个
Two vectors of an inner product space are orthogonal if and only if their inner product is zero.
If
Kernel in Linear Algebra: Part 2Permalink
Let
Proof:
注意:
- 如果有
,那么 就是个 的 linear transformation - 这里 inner product 其实就是 dot product 了
- 这个其实可以扩展到任意的 linear operator
,只是不用 而是 adjoint 来表示逆运算
If
That is
HyperplanePermalink
Let
注意
Hyperplane 的 normal vector 可以由 transformation 的 gradient 给出:
Normal vector 的性质是它垂直于 hyperplane。
对任意 vector
若 hyperplane 不经过原点,我们取 hyperplane 上的任意一点
注意这里有一个很重要的思想:当 hyperplane 过原点时,我们很容易错误地认为 hyperplane 是 hyperplane 上所有 vector 的集合;从 hyperplane 不经过原点的情况来看,正确的理解应该是:hyperplane 是所有从原点出发、落到 hyperplane 上的 vector 的终点的集合。扩展开来,所谓 “vector 张成的空间”,指的就是 “所有 vector 的终点所构成的空间”
造成这个误解的原因在于我混淆了 hyperplane 在几何学和集合论中的意义:
- 几何学中,hyperplane 是个平面(假设 3-D 情况下)
- 集合论中,hyperplane 是 vector 的集合(vector space)
- 我们说 vector
, where is a hyperplane,并不是说在几何学中,整个 vector 都在 这个平面之中,而是说 从原点出发,终点会落在 这个平面之中
基于这个思想,我们还应该认识到:
- (几何学)Hyperplane 平面上没有 vector,只有 vector 的终点;只是当 hyperplane 平面经过原点时,它恰巧包含 vector
- (几何学)从原点出发,终点落到 hyperplane 平面上的 vector
才满足 ,并不是 hyperplane 平面上的 vector 满足- (集合论)Hyperplane 这个 vector space 内的所有 vector
满足
- (集合论)Hyperplane 这个 vector space 内的所有 vector
- (几何学)Normal vector 垂直于 hyperplane 平面,并不是说 Normal vector 垂直于 hyperplane 平面上的所有 vector
- (集合论)Normal vector 也并不垂直于 hyperplane 这个 vector space 内的所有 vector(除非 hyperplane 经过原点)
- (几何学)我们可以把 原点 + hyperplane 平面 的整体结构想象成一个底面积无限大的圆锥:
- 顶点是原点
- 底是 hyperplane 平面
- 顶点到底面任意一点的连线都是 vector
- 顶点到底面几何中心的连线是一个 normal vector
- 这个 normal vector 的长度,即圆锥的高是
- 这个 normal vector 不一定是
,但一定与 共线- 换言之
不一定落在 hyperplane 平面上 - 再换言之
相当于是从原点出发的一个旋转臂,它的方向即圆锥高的方向
- 换言之
- 已知长度和方向,我们可以得知这个 normal vector
- 这个 normal vector 的长度,即圆锥的高是
- (集合论)所有顶点到底面的连线的集合构成 hyperplane 的 vector space
Affine transformation
- 以
为 x-axis,将空间内所有 压缩到一维,即压缩到 这个 x-axis 上 压缩后位于 位置- 将所有压缩后的
左移- 此时位于
位置的所有 反压缩后即是 hyperplane vector space - 此时原点位于
位置 - 这个长度为
的移动距离反压缩后即是圆锥的高
- 此时位于
SVMPermalink
回头看这个 SVM 的最简单的 hard-margin 就很好懂了
注意这个 margin 是设置成常数 1 还是符号
最终的 optimization problem:
“Minimize
这个图是 linear-separable (或者 precisely,hyperplane-separable) 的情况,如果是 non-linear-separable 的情况该怎么办呢?
用 kernel method
Kernel Method / Kernel FunctionPermalink
我们先看 Kernel Methods for Pattern Analysis 的定义:
Definition 2.8 [Kernel function] A kernel is a function
where
用到 SVM 里,基本思想就是:
- 你在 vector space
不是 hyperplane 不可分嘛,我把你 transform 到另外一个 vector space ,如果在 里 hyperplane 可分,problem solved - 我们需要用到 dot product,所以
需要是个 inner product vector space - 我们其实并不关心 transformation
是怎么个 transform 法,我们只关心 dot product
从定义可以看出:
- 这里 kernel 和 kernel function 是一个意思,而且和 Linear Algebra 里的 kernel 无关!(我宁愿你叫 inner-product method!)
- How to intuitively explain what a kernel is?: Kernel is a way of computing the dot product of two vectors in some (possibly very high dimensional) feature space, which is why kernel functions are sometimes called “generalized dot product”.
- 所以凡是涉及到 inner product 的 ML 算法,应该都可以用 kernel 处理
- 我能最快想到的场景就是 clustering,很多 metric 都可以用 inner product 表示
Normed vector space / Metric SpacePermalink
Norms and Metrics, Normed Vector Spaces and Metric Spaces: Let
A vector space together with a norm is called a normed vector space.
Wikipedia: Metric space: A metric space is an ordered pair
such that for any
- (non-negativity or separation axiom):
- (identity of indiscernibles):
- (symmetry):
- (subadditivity or triangle inequality):
Norms and Metrics, Normed Vector Spaces and Metric Spaces:
In other words, a normed vector space is automatically a metric space, by defining the metric in terms of the norm in the natural way. But a metric space may have no algebraic (vector) structure–i.e., it may not be a vector space–so the concept of a metric space is a generalization of the concept of a normed vector space.
所以,我们可以把 normed vector space 加上 inner product 操作,然后做成一个 inner product metric space。在这样一个 feature space 上的 clustering 应该都可以用 kernel method
更多 kernel clustering 内容参考 A Survey of Kernel Clustering Methods。
Comments