没有合适的资源?快使用搜索试试~ 我知道了~
首页线性SVM在Matlab里的实现(含程序)
线性SVM在Matlab里的实现(含程序)
需积分: 17 31 下载量 201 浏览量
更新于2023-03-16
评论 3
收藏 168KB PDF 举报
线性支持向量机在Matlab里的实现+范例程序,运用quadprog求极值
资源详情
资源评论
资源推荐
MATLAB Workshop 2
An introduction to Support Vector Machine
implementations in MATLAB
CS392 MATLAB Workshop 2 – SVM’s 08/10/2003
© David Lindsay 2003 www.david-lindsay.co.uk Page 2 of 17
SESSION PLAN 3
OVERVIEW: 3
LEARNING OUTCOMES 3
L MATRICES, VECTORS AND CONSTANTS ........................................................................................ 4
COPY DATA SETS AND PROGRAMS INTO LOCAL DIRECTORY...................................................... 4
³ CLASSES REPRESENTED AS ±1 FOR SVM’S..................................................................................4
³ RETURN OF THE HYPER-PLANE..................................................................................................... 4
³ WHY ARE OPTIMAL SEPARATING HYPER-PLANE SO GOOD?....................................................... 5
³ THE SVM OPTIMISATION PROBLEM (PRIMARY SEPARABLE CASE) ........................................... 5
L INTUITION OF THE MAIN TERM OF SVM OPTIMISATION ............................................................ 5
L INTUITION OF MAIN TERM AND SIDE CONSTRAINTS.................................................................... 6
³ THE QUADPROG FUNCTION............................................................................................................... 6
³ ENCODING SVM OPTIMISATION PROBLEMS AS MATRICES AND VECTORS................................ 6
L CONCATENATION OF MATRICES ................................................................................................... 7
L CREATING DIAGONAL MATRICES ................................................................................................. 8
L CREATING IDENTITY MATRICES ................................................................................................... 8
³ USING QUADPROG TO SOLVE SVM OPTIMISATION PROBLEMS ..................................................... 8
ADD THE CODE TO FIND THE SVM OPTIMAL SEPARATING HYPERPLANE ................................. 9
PLOT THE OPTIMAL SEPARATING HYPERPLANE AND MARGINS............................................... 10
PLOTTING NEW TEST DATA POINTS FOR CLASSIFICATION ....................................................... 11
THE FINISHED GRAPH PLOT 13
ADDITIONAL TASKS 14
L WEBSITES..................................................................................................................................... 15
L BOOKS .......................................................................................................................................... 15
MATLAB SOLUTION CODE 16
CS392 MATLAB Workshop 2 – SVM’s 08/10/2003
© David Lindsay 2003 www.david-lindsay.co.uk Page 3 of 17
Session Plan
This work shop is designed to revise the theory and practice of Support Vector Machines
(SVM) as well as introduce important functionality in MATLAB. The text will be broken
down into sections clearly marked using the symbols given below. Read through the exercise
and try to answer the questions the best you can amongst yourselves. We have left space at
the bottom of each question to write notes/answers.
³ This is a key concept that must be understood, if you don’t then you must ask!
V This indicates a question or exercise that needs to be completed.
This indicates a task that you need to do as instructed in the exercise.
L This is a helpful tip or piece of useful information.
Overview:
Today we will continue our analysis of the tennisweather data set that we analysed in the
previous MATLAB workshop. We will implement an SVM on the data and will demonstrate
practically how to classify new examples. I will build upon the MATLAB programming
techniques introduced in the previous session and introduce more advanced functionality
where needed. This session is designed as an informal practical, you can work in groups and
chat amongst yourselves whilst working through the exercises provided. I encourage you to
work through the questions whilst you can so that I may help you with any problems. I have
tried to make this session light hearted and highlight the key concepts with a ³ symbol. If
you need help at any time, please either refer to your notes, the MATLAB help guide or ask
me or Tony! I will hand out the solution code to this exercise at the end of this session.
Learning outcomes
1. Review some of the basic concepts of SVM’s
2. Look at how SVM’s are applied to real life data
3. Learn more advanced manipulations and creation of matrices in MATLAB such as
concatenation, creating diagonal and identity matrices.
4. How to classify new test data using SVM’s
5. How to formulate the SVM primal separable problem as a quadratic optimisation
problem.
6. How to implement SVM’s in MATLAB using the quadprog function
CS392 MATLAB Workshop 2 – SVM’s 08/10/2003
© David Lindsay 2003 www.david-lindsay.co.uk Page 4 of 17
L Matrices, vectors and constants
I will try to use consistent notation to distinguish between matrices, vectors and constants
throughout this document. I will usually use capital bold notation for matrices (e.g.
,
Α, Β,
C
K ), lower case bold for vectors (e.g.
,
,,
abc
K ) and italicised for constants (e.g.
,
a
bc,, K ). It is very important that you can distinguish between these mathematical objects!
Copy data sets and programs into local directory
As stated in the previous workshop we have created for you a shared directory of resources
under the /CS/courses/CS392/ directory
Copy the files that you need for this session into your local directory
cp /CS/courses/CS392/ex2SVM/* .
You should find the files firstsvm1.m, tennisweather2AttSVMTrain.txt and
tennisweather2AttSVMTest.txt in your home directory. The file firstsvm1.m is
a slightly modified version of the program that you developed in workshop 1. Open this file
for editing by typing emacs firstsvm1.m &
³ Classes represented as ±1 for SVM’s
The two dataset files that you have copied is the same data as you worked with in the previous
workshop on assessing good ‘tennis playing’ days. Look at the data, you will notice that I
have changed the classes to ±1 so that it can be analysed by an SVM directly. It will become
clearer later why it is useful to encode the classes in this manner. We have also separated the
last example from the original data to make a separate training and test file.
³ Return of the hyper-plane
One of the most important concepts to get your head around is that of a hyper-plane in n
dimensional space [see Class 2 Slide 8]! We consider our attribute vectors
1
,
,
i
i
n
x
x=
i
x K as
the n dimensionals vectors for the ith example in the data set. We have a a training set of l
examples (information pairs attribute vector + label) as
()()
{
}
1
,,,
l
y
y
11
xxK where the labels
{}
1,1−∈
i
y . The equation of a hyperplane H is
00 11
(
)
0
nn
Hwxwx wxb b=++++=⋅+=wxL
using the dot product notation. The hyperplane is defined by the “weights” which are
contained in the n dimensional vector w and the constant b.
剩余16页未读,继续阅读
jh01231230
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- RTL8188FU-Linux-v5.7.4.2-36687.20200602.tar(20765).gz
- c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf
- 建筑供配电系统相关课件.pptx
- 企业管理规章制度及管理模式.doc
- vb打开摄像头.doc
- 云计算-可信计算中认证协议改进方案.pdf
- [详细完整版]单片机编程4.ppt
- c语言常用算法.pdf
- c++经典程序代码大全.pdf
- 单片机数字时钟资料.doc
- 11项目管理前沿1.0.pptx
- 基于ssm的“魅力”繁峙宣传网站的设计与实现论文.doc
- 智慧交通综合解决方案.pptx
- 建筑防潮设计-PowerPointPresentati.pptx
- SPC统计过程控制程序.pptx
- SPC统计方法基础知识.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0