csvm.m
来自「用支持向量机进行分类」· M 代码 · 共 48 行
M
48 行
function [alpha,solution]=csvm(X)% CSVM separates point set from the origin by hyperplane.% [alpha,solution]=csvm(X)%% CSVM finds a normal vector of a hyperplane passing the % origin of coordinates and maximizing margin between given % point set (its convex hull) and the origin.%% In other words, the aim is to find such vector alpha lying % inside the convex hull of given set and having the smallest norm.%% Input:% X [D x M] matrix which contains M training points in D-dimensional% feature space. X=[x1,x2,..XM] where xi is i-th column% vectors.%% Output:% alpha [Dx1] normal vector of finding decision hyperplane.% solution [1x1] contains 1 if solution is found or 0 if solution% is not found.%% See also LINSVM, PERCEPTR, KOZINEC, EKOZINEC, EKOZINEC2.%% Statistical Pattern Recognition Toolbox, Vojtech Franc, Vaclav Hlavac% (c) Czech Technical University Prague, http://cmp.felk.cvut.cz% Written Vojtech Franc (diploma thesis) 29.10.1999% Modifications% 11-june-2001, V. Franc, new comments.% 24. 6.00 V. Hlavac, comments polished.N=size(X,1);K=size(X,2);H=eye(N);f=zeros(N,1);b=-ones(K,1);A=-X';% quadratic programming[alpha,lag,how]=qp(H,f,A,b,[],[],[],0,-1);if strcmp(lower(how),'ok'), solution=1;else solution=0;end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?