⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fishdemo.m

📁 四种SVM工具箱的分类与回归算法别人的
💻 M
📖 第 1 页 / 共 2 页
字号:
function []=fishdemo(action,hfigure,varargin)% FISHDEMO demo on algorithms which learn Fisher's classifer.%% FISHDEMO demonstrates use of algorithms finding the Fisher's%  classifier. The task is to split the feature space to%  convex cones, each cone corresponds to one class. %  Formaly, the task is to find such vectors alphas(:,i), %  i=1,2,...K that inequalities%%    alphas(:,i)'*X(:,k) > alphas(:,j)'*X(:,k)  for any J(k)=i,i~=j.%%  hold. Underlying idea is to transform k-class problem to %  2-class (or binary) classification problem.% %  The algorithms are demonstrated in 2D space. The found linear %  decision boundaries are donoted as dashed lines. The direction %  of the vector corresponding to given class is denoted as solid %  line and its color distinguishes the class.%%  Following algorithms can be tested:%   fisherp   - Modifed Perceptron learning rule.%   fisherk   - Modified Kozinec's algorithm.%% Control:%  Algorithm  - select algorithm for testing.%  Iterations - number of iterations in one step.%%  FIG2EPS     - export screen to the PostScript file.%  Load data   - load input point sets from file.%  Create data - invoke program for creating point sets.%  Reset       - set the tested algorithm to the initial state.%  Play        - run the tested algorithm.%  Stop        - stop the running algorithm.%  Step        - perform only one step.%  Info        - invoke the info box.%  Close       - close the program.%% See also FISHERP, FISHERK.%% Statistical Pattern Recognition Toolbox, Vojtech Franc, Vaclav Hlavac% (c) Czech Technical University Prague, http://cmp.felk.cvut.cz% Written Vojtech Franc (diploma thesis) 23.12.1999, 27.02.2000% Modifications% 26-June-2001, V.Franc, comments changed.% 24. 6.00 V. Hlavac, comments polished.DATA_IDENT='Finite sets, Enumeration';    % file identifierBORDER=0.10;                        % minimal space between axis and any pointMAX_CLASS=10;% if number of the arguments is less then 1, it means first call of this function.% Every other calls set up at least one argument.if nargin < 1,   action = 'initialize';end% what action is called ?switch lower(action)case 'initialize'   % == Initialize user interface control and figure =======================   % == Figure =============================================================   left=0.1;   width=0.8;   bottom=0.1;   height=0.8;   hfigure=figure('Name','Fisher`s classifier', ...      'Visible','off',...      'NumberTitle','off', ...      'Units','normalized', ...      'Position',[left bottom width height],...      'tag','Fishdemo',...       'Units','normalized',...      'RendererMode','manual');   % == Axes - place for drawing ===========================================   left=0.1;   width=0.65;   bottom=0.35;   height=0.60;   haxes1=axes(...       'Units','normalized', ...      'DrawMode','fast',...      'Box','on', ...      'UserData',[],...      'Position',[left bottom width height]);   xlabel('feature x');   ylabel('feature y');   % == Comment window =====================================================   % Comment Window frame   bottom=0.05;   height=0.2;   uicontrol( ...        'Style','frame', ...        'Units','normalized', ...        'Position',[left bottom width height], ...        'BackgroundColor',[0.5 0.5 0.5]);   % Text label   uicontrol( ...        'Style','text', ...        'Units','normalized', ...        'Position',[left height-0.01 width 0.05], ...        'BackgroundColor',[0.5 0.5 0.5], ...        'ForegroundColor',[1 1 1], ...        'String','Comment Window');   % Edit window   border=0.01;   hconsole=uicontrol( ...        'Style','edit', ...        'HorizontalAlignment','left', ...        'Units','normalized', ...        'Max',10, ...        'BackgroundColor',[1 1 1], ...        'Position',[left+border bottom width-2*border height-0.05], ...        'Enable','inactive',...        'String','');    % == Buttons ===========================================================   % -- Export to EPS ---------   width=0.1;   left=0.75-width;   bottom=0.95;   height=0.04;   hbtclose = uicontrol(...    'Units','Normalized', ...      'Callback','fig2eps(gcf)',...        'ListboxTop',0, ...        'Position',[left bottom width height], ...      'String','FIG2EPS');   %----------------------------------   % Close button: close figure   left=0.8;   bottom=0.05;   height=0.05;   width=0.15;   hbtclose = uicontrol(...    'Units','Normalized', ...      'Callback','close(gcf)',...        'ListboxTop',0, ...        'Position',[left bottom width height], ...        'String','Close');   % Info button: call stanard info box   bottom=bottom+1.5*height;   hbtinfo = uicontrol(...    'Units','Normalized', ...      'Callback','fishdemo(''info'',gcf)',...        'ListboxTop',0, ...        'Position',[left bottom width height], ...        'String','Info');   % Step button: perform one step, compute new hyperplane   bottom=bottom+2.5*height;    hbtstep = uicontrol(...      'Units','Normalized', ...      'ListboxTop',0, ...        'Position',[left bottom width height], ...      'String','Step', ...      'Callback','fishdemo(''step'',gcf)');   % Stop button: stop performing adaptation of hyperplane   bottom=bottom+height;   hbtstop = uicontrol(...    'Units','Normalized', ...        'ListboxTop',0, ...        'Position',[left bottom width height], ...      'String','Stop', ...      'Callback','set(gcbo,''UserData'',1)',...      'Enable','off');   % Play button: start up adaptation, step by step   bottom=bottom+height;   hbtplay = uicontrol(...    'Units','Normalized', ...      'ListboxTop',0, ...        'Position',[left bottom width height], ...      'String','Play', ...      'Callback','fishdemo(''play'',gcf)');   % Reset button: set up initial setting, zero step of adaptation   bottom=bottom+height;    hbtreset = uicontrol(...      'Units','Normalized', ...      'ListboxTop',0, ...        'Position',[left bottom width height], ...      'String','Reset', ...      'Callback','fishdemo(''reset'',gcf)');   % Create data   bottom=bottom+1.5*height;    hbtcreat = uicontrol(...      'Units','Normalized', ...      'ListboxTop',0, ...        'Position',[left bottom width height], ...      'String','Create data', ...      'Callback','fishdemo(''creatdata'',gcf)');   % Load data   bottom=bottom+1*height;    hbtload = uicontrol(...      'Units','Normalized', ...      'ListboxTop',0, ...        'Position',[left bottom width height], ...      'String','Load data', ...      'Callback','fishdemo(''getfile'',gcf)');   % == Popup menus ==========================================================   % Popu up menu for selection among algorithms    % Title   bottom=0.95-height;   htxalgo=uicontrol( ...      'Style','text', ...      'Units','normalized', ...      'Position',[left bottom width height], ...      'String','Algorithm');   % Popup menu   bottom=bottom-height;   hpualgo=uicontrol( ...      'Style','popup', ...      'Units','normalized', ...      'Position',[left bottom width height], ...      'String',['Perceptron';'Kozinec   ']);   % == Edit line =========================================================   % # of iterations   bottom=bottom-2*height;   htxiter=uicontrol( ...      'Style','text', ...      'Units','normalized', ...      'Position',[left bottom width 0.9*height], ...      'String','Iterations');   bottom=bottom-1*height;   hediter = uicontrol(...    'Units','normalized', ...      'ListboxTop',0, ...        'Position',[left bottom width height], ...      'Style','edit',...      'CallBack','fishdemo(''iterhandler'',gcf)',...      'String','1');    % ==============================================================================   % Store handlers, note: first handler is reserved for separation line   handlers=struct(...      'lines',struct('handlers',[],'alphas',[],'t',0),...      'btstep',hbtstep,...      'btclose',hbtclose,...      'btstop',hbtstop,...      'btplay',hbtplay,...      'btreset',hbtreset,...      'btload',hbtload,...      'btcreat',hbtcreat,...      'editer',hediter,...      'pualgo',hpualgo,...      'btinfo',hbtinfo,...      'axes1',haxes1,...      'console',hconsole);   set(hfigure,'UserData',handlers)   % Reset adaptation, t=0   fishdemo('reset',hfigure);   % Put figure on desktop   set(hfigure,'Visible','on');   drawnow;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -