亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? svmmatlab.m

?? 支持向量機的matlab代碼.很有參考價值的源代碼
?? M
字號:

>>edit svmtrain 
>>edit svmclassify 
>>edit svmpredict 

function [svm_struct, svIndex] = svmtrain(training, groupnames, varargin) 
%SVMTRAIN trains a support vector machine classifier 
% 
% SVMStruct = SVMTRAIN(TRAINING,GROUP) trains a support vector machine 
% classifier using data TRAINING taken from two groups given by GROUP. 
% SVMStruct contains information about the trained classifier that is 
% used by SVMCLASSIFY for classification. GROUP is a column vector of 
% values of the same length as TRAINING that defines two groups. Each 
% element of GROUP specifies the group the corresponding row of TRAINING 
% belongs to. GROUP can be a numeric vector, a string array, or a cell 
% array of strings. SVMTRAIN treats NaNs or empty strings in GROUP as 
% missing values and ignores the corresponding rows of TRAINING. 
% 
% SVMTRAIN(...,'KERNEL_FUNCTION',KFUN) allows you to specify the kernel 
% function KFUN used to map the training data into kernel space. The 
% default kernel function is the dot product. KFUN can be one of the 
% following strings or a function handle: 
% 
% 'linear' Linear kernel or dot product 
% 'quadratic' Quadratic kernel 
% 'polynomial' Polynomial kernel (default order 3) 
% 'rbf' Gaussian Radial Basis Function kernel 
% 'mlp' Multilayer Perceptron kernel (default scale 1) 
% function A kernel function specified using @, 
% for example @KFUN, or an anonymous function 
% 
% A kernel function must be of the form 
% 
% function K = KFUN(U, V) 
% 
% The returned value, K, is a matrix of size M-by-N, where U and V have M 
% and N rows respectively. If KFUN is parameterized, you can use 
% anonymous functions to capture the problem-dependent parameters. For 
% example, suppose that your kernel function is 
% 
% function k = kfun(u,v,p1,p2) 
% k = tanh(p1*(u*v')+p2); 
% 
% You can set values for p1 and p2 and then use an anonymous function: 
% @(u,v) kfun(u,v,p1,p2). 
% 
% SVMTRAIN(...,'POLYORDER',ORDER) allows you to specify the order of a 
% polynomial kernel. The default order is 3. 
% 
% SVMTRAIN(...,'MLP_PARAMS',[P1 P2]) allows you to specify the 
% parameters of the Multilayer Perceptron (mlp) kernel. The mlp kernel 
% requires two parameters, P1 and P2, where K = tanh(P1*U*V' + P2) and P1 
% > 0 and P2 < 0. Default values are P1 = 1 and P2 = -1. 
% 
% SVMTRAIN(...,'METHOD',METHOD) allows you to specify the method used 
% to find the separating hyperplane. Options are 
% 
% 'QP' Use quadratic programming (requires the Optimization Toolbox) 
% 'LS' Use least-squares method 
% 
% If you have the Optimization Toolbox, then the QP method is the default 
% method. If not, the only available method is LS. 
% 
% SVMTRAIN(...,'QUADPROG_OPTS',OPTIONS) allows you to pass an OPTIONS 
% structure created using OPTIMSET to the QUADPROG function when using 
% the 'QP' method. See help optimset for more details. 
% 
% SVMTRAIN(...,'SHOWPLOT',true), when used with two-dimensional data, 
% creates a plot of the grouped data and plots the separating line for 
% the classifier. 
% 
% Example: 
% % Load the data and select features for classification 
% load fisheriris 
% data = [meas(:,1), meas(:,2)]; 
% % Extract the Setosa class 
% groups = ismember(species,'setosa'); 
% % Randomly select training and test sets 
% [train, test] = crossvalind('holdOut',groups); 
% cp = classperf(groups); 
% % Use a linear support vector machine classifier 
% svmStruct = svmtrain(data(train,:),groups(train),'showplot',true); 
% classes = svmclassify(svmStruct,data(test,:),'showplot',true); 
% % See how well the classifier performed 
% classperf(cp,classes,test); 
% cp.CorrectRate 
% 
% See also CLASSIFY, KNNCLASSIFY, QUADPROG, SVMCLASSIFY. 

% Copyright 2004 The MathWorks, Inc. 
% $Revision: 1.1.12.1 $ $Date: 2004/12/24 20:43:35 $ 

% References: 
% [1] Kecman, V, Learning and Soft Computing, 
% MIT Press, Cambridge, MA. 2001. 
% [2] Suykens, J.A.K., Van Gestel, T., De Brabanter, J., De Moor, B., 
% Vandewalle, J., Least Squares Support Vector Machines, 
% World Scientific, Singapore, 2002. 
% [3] Scholkopf, B., Smola, A.J., Learning with Kernels, 
% MIT Press, Cambridge, MA. 2002. 

% 
% SVMTRAIN(...,'KFUNARGS',ARGS) allows you to pass additional 
% arguments to kernel functions. 

% set defaults 


plotflag = false; 
qp_opts = []; 
kfunargs = {}; 
setPoly = false; usePoly = false; 
setMLP = false; useMLP = false; 
if ~isempty(which('quadprog')) 
useQuadprog = true; 
else 
useQuadprog = false; 
end 
% set default kernel function 
kfun = @linear_kernel; 

% check inputs 
if nargin < 2 
error(nargchk(2,Inf,nargin)) 
end 

numoptargs = nargin -2; 
optargs = varargin; 

% grp2idx sorts a numeric grouping var ascending, and a string grouping 
% var by order of first occurrence 

[g,groupString] = grp2idx(groupnames); 

% check group is a vector -- though char input is special... 
if ~isvector(groupnames) && ~ischar(groupnames) 
error('Bioinfo:svmtrain:GroupNotVector',... 
'Group must be a vector.'); 
end 

% make sure that the data is correctly oriented. 
if size(groupnames,1) == 1 
groupnames = groupnames'; 
end 
% make sure data is the right size 
n = length(groupnames); 
if size(training,1) ~= n 
if size(training,2) == n 
training = training'; 
else 
error('Bioinfo:svmtrain:DataGroupSizeMismatch',... 
'GROUP and TRAINING must have the same number of rows.') 
end 
end 

% NaNs are treated as unknown classes and are removed from the training 
% data 
nans = find(isnan(g)); 
if length(nans) > 0 
training(nans,:) = []; 
g(nans) = []; 
end 
ngroups = length(groupString); 

if ngroups > 2 
error('Bioinfo:svmtrain:TooManyGroups',... 
'SVMTRAIN only supports classification into two groups.\nGROUP contains %d different groups.',ngroups) 
end 
% convert to 1, -1. 
g = 1 - (2* (g-1)); 

% handle optional arguments 

if numoptargs >= 1 
if rem(numoptargs,2)== 1 
error('Bioinfo:svmtrain:IncorrectNumberOfArguments',... 
'Incorrect number of arguments to %s.',mfilename); 
end 
okargs = {'kernel_function','method','showplot','kfunargs','quadprog_opts','polyorder','mlp_params'}; 
for j=1:2:numoptargs 
pname = optargs{j}; 
pval = optargs{j+1}; 
k = strmatch(lower(pname), okargs);%#ok 
if isempty(k) 
error('Bioinfo:svmtrain:UnknownParameterName',... 
'Unknown parameter name: %s.',pname); 
elseif length(k)>1 
error('Bioinfo:svmtrain:AmbiguousParameterName',... 
'Ambiguous parameter name: %s.',pname); 
else 
switch(k) 
case 1 % kernel_function 
if ischar(pval) 
okfuns = {'linear','quadratic',... 
'radial','rbf','polynomial','mlp'}; 
funNum = strmatch(lower(pval), okfuns);%#ok 
if isempty(funNum) 
funNum = 0; 
end 
switch funNum %maybe make this less strict in the future 
case 1 
kfun = @linear_kernel; 
case 2 
kfun = @quadratic_kernel; 
case {3,4} 
kfun = @rbf_kernel; 
case 5 
kfun = @poly_kernel; 
usePoly = true; 
case 6 
kfun = @mlp_kernel; 
useMLP = true; 
otherwise 
error('Bioinfo:svmtrain:UnknownKernelFunction',... 
'Unknown Kernel Function %s.',kfun); 
end 
elseif isa (pval, 'function_handle') 
kfun = pval; 
else 
error('Bioinfo:svmtrain:BadKernelFunction',... 
'The kernel function input does not appear to be a function handle\nor valid function name.') 
end 
case 2 % method 
if strncmpi(pval,'qp',2) 
useQuadprog = true; 
if isempty(which('quadprog')) 
warning('Bioinfo:svmtrain:NoOptim',... 
'The Optimization Toolbox is required to use the quadratic programming method.') 
useQuadprog = false; 
end 
elseif strncmpi(pval,'ls',2) 
useQuadprog = false; 
else 
error('Bioinfo:svmtrain:UnknownMethod',... 
'Unknown method option %s. Valid methods are ''QP'' and ''LS''',pval); 

end 
case 3 % display 
if pval ~= 0 
if size(training,2) == 2 
plotflag = true; 
else 
warning('Bioinfo:svmtrain:OnlyPlot2D',... 
'The display option can only plot 2D training data.') 
end 

end 
case 4 % kfunargs 
if iscell(pval) 
kfunargs = pval; 
else 
kfunargs = {pval}; 
end 
case 5 % quadprog_opts 
if isstruct(pval) 
qp_opts = pval; 
elseif iscell(pval) 
qp_opts = optimset(pval{:}); 
else 
error('Bioinfo:svmtrain:BadQuadprogOpts',... 
'QUADPROG_OPTS must be an opts structure.'); 
end 
case 6 % polyorder 
if ~isscalar(pval) || ~isnumeric(pval) 
error('Bioinfo:svmtrain:BadPolyOrder',... 
'POLYORDER must be a scalar value.'); 
end 
if pval ~=floor(pval) || pval < 1 
error('Bioinfo:svmtrain:PolyOrderNotInt',... 
'The order of the polynomial kernel must be a positive integer.') 
end 
kfunargs = {pval}; 
setPoly = true; 

case 7 % mlpparams 
if numel(pval)~=2 
error('Bioinfo:svmtrain:BadMLPParams',... 
'MLP_PARAMS must be a two element array.'); 
end 
if ~isscalar(pval(1)) || ~isscalar(pval(2)) 
error('Bioinfo:svmtrain:MLPParamsNotScalar',... 
'The parameters of the multi-layer perceptron kernel must be scalar.'); 
end 
kfunargs = {pval(1),pval(2)}; 
setMLP = true; 
end 
end 
end 
end 
if setPoly && ~usePoly 
warning('Bioinfo:svmtrain:PolyOrderNotPolyKernel',... 
'You specified a polynomial order but not a polynomial kernel'); 
end 
if setMLP && ~useMLP 
warning('Bioinfo:svmtrain:MLPParamNotMLPKernel',... 
'You specified MLP parameters but not an MLP kernel'); 
end 
% plot the data if requested 
if plotflag 
[hAxis,hLines] = svmplotdata(training,g); 
legend(hLines,cellstr(groupString)); 
end 

% calculate kernel function 
try 
kx = feval(kfun,training,training,kfunargs{:}); 
% ensure function is symmetric 
kx = (kx+kx')/2; 
catch 
error('Bioinfo:svmtrain:UnknownKernelFunction',... 
'Error calculating the kernel function:\n%s\n', lasterr); 
end 
% create Hessian 
% add small constant eye to force stability 
H =((g*g').*kx) + sqrt(eps(class(training)))*eye(n); 

if useQuadprog 
% The large scale solver cannot handle this type of problem, so turn it 
% off. 
qp_opts = optimset(qp_opts,'LargeScale','Off'); 
% X=QUADPROG(H,f,A,b,Aeq,beq,LB,UB,X0,opts) 
alpha = quadprog(H,-ones(n,1),[],[],... 
g',0,zeros(n,1),inf *ones(n,1),zeros(n,1),qp_opts); 

% The support vectors are the non-zeros of alpha 
svIndex = find(alpha > sqrt(eps)); 
sv = training(svIndex,:); 

% calculate the parameters of the separating line from the support 
% vectors. 
alphaHat = g(svIndex).*alpha(svIndex); 

% Calculate the bias by applying the indicator function to the support 
% vector with largest alpha. 
[maxAlpha,maxPos] = max(alpha); %#ok 
bias = g(maxPos) - sum(alphaHat.*kx(svIndex,maxPos)); 
% an alternative method is to average the values over all support vectors 
% bias = mean(g(sv)' - sum(alphaHat(:,ones(1,numSVs)).*kx(sv,sv))); 

% An alternative way to calculate support vectors is to look for zeros of 
% the Lagrangians (fifth output from QUADPROG). 
% 
% [alpha,fval,output,exitflag,t] = quadprog(H,-ones(n,1),[],[],... 
% g',0,zeros(n,1),inf *ones(n,1),zeros(n,1),opts); 
% 
% sv = t.lower < sqrt(eps) & t.upper < sqrt(eps); 
else % Least-Squares 
% now build up compound matrix for solver 

A = [0 g';g,H]; 
b = [0;ones(size(g))]; 
x = A\b; 

% calculate the parameters of the separating line from the support 
% vectors. 
sv = training; 
bias = x(1); 
alphaHat = g.*x(2:end); 
end 

svm_struct.SupportVectors = sv; 
svm_struct.Alpha = alphaHat; 
svm_struct.Bias = bias; 
svm_struct.KernelFunction = kfun; 
svm_struct.KernelFunctionArgs = kfunargs; 
svm_struct.GroupNames = groupnames; 
svm_struct.FigureHandles = []; 
if plotflag 
hSV = svmplotsvs(hAxis,svm_struct); 
svm_struct.FigureHandles = {hAxis,hLines,hSV}; 
end

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美成人一区二区三区片免费| 五月婷婷色综合| 国产激情视频一区二区在线观看| 日韩精品一区二区三区在线| 久久99国产精品免费| 欧美mv日韩mv亚洲| 国产精品一区二区三区四区| 国产视频911| 99久久99久久久精品齐齐| 亚洲视频狠狠干| 精品视频在线免费观看| 日本少妇一区二区| 日本一区二区成人在线| 色香蕉成人二区免费| 午夜亚洲国产au精品一区二区 | 国产福利一区二区三区视频| 久久久91精品国产一区二区精品| 成人av网站在线观看免费| 一区二区免费看| 日韩午夜三级在线| 成人久久久精品乱码一区二区三区| 亚洲免费观看高清完整版在线观看熊| 欧美日韩二区三区| 国产乱色国产精品免费视频| 亚洲三级电影网站| 欧美肥妇毛茸茸| 成人精品小蝌蚪| 午夜精品一区在线观看| 久久精品一区四区| 日本精品视频一区二区三区| 裸体一区二区三区| 最近日韩中文字幕| 精品国产电影一区二区| 色综合久久久久| 久久66热re国产| 亚洲一区二区在线观看视频 | 不卡一二三区首页| 麻豆精品在线播放| 亚洲欧洲中文日韩久久av乱码| 欧美挠脚心视频网站| 国产成人自拍高清视频在线免费播放| 亚洲精品第1页| 国产精品美女www爽爽爽| 欧美一区二区日韩| 日本久久精品电影| 成人av网址在线| 国产一区欧美一区| 日韩电影一区二区三区四区| 亚洲欧洲日韩综合一区二区| 欧美大白屁股肥臀xxxxxx| 91麻豆国产自产在线观看| 国产精品一级片| 日韩中文字幕不卡| 亚洲综合色视频| 中文字幕日韩精品一区| 久久久三级国产网站| 3751色影院一区二区三区| 日本高清不卡视频| jlzzjlzz亚洲女人18| 国模娜娜一区二区三区| 日本 国产 欧美色综合| 亚洲国产精品一区二区www| 国产精品电影一区二区| 国产日韩欧美精品在线| 久久免费美女视频| 2021久久国产精品不只是精品| 7777精品伊人久久久大香线蕉完整版 | 亚洲免费观看高清| 中文字幕乱码亚洲精品一区| 欧美精品一区二区高清在线观看| 91麻豆精品国产91久久久久久久久| 日本韩国欧美在线| 91精品1区2区| 日本电影亚洲天堂一区| 色综合婷婷久久| 色综合久久久网| 91天堂素人约啪| 色域天天综合网| 欧美视频一区二区三区四区| 日本道色综合久久| 欧美系列亚洲系列| 欧美色视频在线观看| 在线视频你懂得一区二区三区| 99久久精品一区| 一本大道久久a久久精品综合| 94色蜜桃网一区二区三区| 91麻豆精品一区二区三区| 在线视频欧美区| 欧美一区二区三区在线| 欧美一级理论性理论a| 精品久久国产老人久久综合| 久久色视频免费观看| 国产精品久久影院| 亚洲精品乱码久久久久久黑人| 一区二区高清视频在线观看| 亚洲国产精品久久不卡毛片| 天天射综合影视| 激情久久久久久久久久久久久久久久 | 2017欧美狠狠色| 国产精品网站导航| 亚洲欧美视频在线观看视频| 一区二区三区电影在线播| 亚洲mv在线观看| 国产专区欧美精品| av中文字幕不卡| 欧美日韩三级一区二区| 日韩欧美国产综合| 国产欧美日韩激情| 亚洲国产精品影院| 狠狠色狠狠色综合日日91app| 成人av在线一区二区三区| 欧美综合视频在线观看| 精品日韩av一区二区| 亚洲视频在线一区二区| 视频一区视频二区中文字幕| 国产一区二区伦理片| 91福利精品第一导航| 亚洲精品一区二区三区影院| 中文字幕字幕中文在线中不卡视频| 亚洲福利一区二区三区| 国产成人av网站| 91精品国产高清一区二区三区蜜臀 | 91精品国产综合久久婷婷香蕉| 久久嫩草精品久久久精品| 亚洲午夜av在线| 国产99久久久久久免费看农村| 欧洲av一区二区嗯嗯嗯啊| 国产日韩欧美精品综合| 日韩黄色小视频| 91浏览器入口在线观看| 精品捆绑美女sm三区| 亚洲永久免费av| 成人美女视频在线观看| 精品国产一区二区精华| 亚洲18色成人| 91免费观看国产| 国产视频一区在线播放| 麻豆中文一区二区| 欧美色视频在线观看| 亚洲色图视频免费播放| 国产福利一区二区三区在线视频| 91精品国产麻豆| 亚洲电影在线播放| 99久久国产综合精品色伊| 国产人成亚洲第一网站在线播放 | 一区二区三区在线免费| 国产成人三级在线观看| 精品久久久久久久久久久久久久久久久| 亚洲午夜精品17c| 91久久久免费一区二区| 国产精品午夜久久| 国产一区欧美日韩| 精品国产乱码久久久久久浪潮| 性做久久久久久免费观看欧美| 91网站在线观看视频| 日韩一区在线免费观看| 国产精品小仙女| 久久婷婷国产综合精品青草| 精品一区二区三区香蕉蜜桃| 91麻豆精品国产91久久久使用方法 | 日韩精品综合一本久道在线视频| 亚洲狠狠爱一区二区三区| 91视频一区二区| 自拍偷拍国产精品| av中文字幕在线不卡| ㊣最新国产の精品bt伙计久久| 懂色av中文一区二区三区| 国产日韩欧美一区二区三区综合 | 国产精品成人网| 成人永久免费视频| 国产精品免费观看视频| 成人中文字幕合集| 亚洲天堂久久久久久久| 91麻豆免费看片| 午夜免费欧美电影| 日韩免费高清电影| 国产一区二区三区最好精华液| 久久综合一区二区| 成人免费视频一区| 亚洲色图一区二区三区| 91视频在线观看| 五月天欧美精品| 精品黑人一区二区三区久久| 国产在线精品一区二区夜色| 国产视频一区二区三区在线观看| 99久久99久久精品免费观看| 一区二区三区自拍| 5月丁香婷婷综合| 国产精品一二三四| 综合网在线视频| 欧美日韩视频在线观看一区二区三区 | 一区二区欧美在线观看| 在线电影一区二区三区| 精品中文字幕一区二区| 国产精品免费av| 欧美日韩在线播| 国内成人精品2018免费看| 亚洲欧美在线观看| 日韩午夜在线影院| 99久久精品99国产精品 |