r语言 支持向量机实现_支持向量机解密:R中的实现

本文详细介绍了如何在R语言中实现支持向量机,通过实例解析支持向量机的工作原理,帮助读者理解这一机器学习算法。
摘要由CSDN通过智能技术生成

r语言 支持向量机实现

Support Vector Machine, popularly abbreviated as SVM is a supervised learning algorithm used for both regression and classification but more commonly used for classification. SVMs have been shown to outperform well in a variety of setting and are often considered as one of the best “out of box” classifiers.

支持向量机(Support Vector Machine),通常缩写为SVM,是一种用于回归和分类的监督学习算法,但更常用于分类。 SVM在各种设置下均表现出色,通常被认为是最好的“开箱即用”分类器。

In this article we will discuss SVMs for a 2-class classification setting. The approach used in Support Vector Machines is based on finding a separting hyperplane.

在本文中,我们将讨论用于2类分类设置的SVM。 支持向量机中使用的方法是基于找到分离的超平面

Let us start by defining a hyperplane.

让我们首先定义一个超平面。

什么是超平面? (What is a hyperplane?)

In a p dimensional space, a hyperplane(H) is a flat affine subspace of dimension p-1. In other words, if V is a p-dimensional vector space than H is a (p-1) dimensional subspace. Examples of hyperplanes in 2 dimensions are any straight line through the origin. In 3 dimensions, any plane containing the origin.

在ap维空间中,超平面(H)是维p-1的平仿射子空间。 换句话说,如果V是p维向量空间,则H是(p-1)维子空间。 二维超平面的示例是通过原点的任何直线。 在3维中,包含原点的任何平面。

Image for post
a point X
点X

The hyperplane mentioned above divides the p-dimensional space into two halves. Depending on whether the equation is >0 or <0 , the point X lies on either sides of the hyperplane.

上述超平面将p维空间分为两半。 根据等式是> 0还是<0,点X位于超平面的两侧。

Image for post
Figure 1
图1

使用分离的超平面进行分类 (Classification Using a Separating Hyperplane)

Now that we have understood what a hyperplane is, let us take another step forward towards building a classifier based on a separating hyperplane. If such a hyperplane exists which can separate our training observations into two classes namely y_i=1 and y_i=-1 then the hyperplane has the following properties;

既然我们已经了解了什么是超平面,那么让我们朝着基于分离的超平面构建分类器又迈出一步。 如果存在这样的超平面,可以将我们的训练观察结果分为两类,即y_i = 1和y_i = -1,则该超平面具有以下属性;

Image for post

De facto, this can be written in one single equation as;

实际上,这可以写成一个方程:

Image for post
for all i=1,2,…,n
对于所有i = 1,2,…,n

There could be infinite number of such hyperplanes. The figure below shows three such hyperplanes;

这样的超平面可能是无限的。 下图显示了三个这样的超平面;

Image for post
Figure 2 : solid lines represent 3 separating hyperplanes which separate the training observations into two classes; blue and purple.
图2:实线表示3个分离的超平面,它们将训练观察结果分为两类; 蓝色和紫色。

If a separating hyperplane exists, we can use it to construct a very trivial classifier : a test observation(x) is assigned a class depending on which side of the hyperplane it is located(by looking at the sign of the above equation) . We can also make use of the magnitude of the equation of the hyperplane. If it is large, x lies far away from the hyperplane so we can be more confident about our class assignment for x.

如果存在分离的超平面,我们可以使用它构造一个非常简单的分类器:根据测试观测值(x)所在的超平面的哪一侧为其分配一个类(通过查看上述方程式的符号)。 我们还可以利用超平面方程的大小。 如果它很大,则x远离超平面,因此我们可以更

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值