📄 demo_linclass.html
字号:
<html><head> <meta HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=ISO-8859-1"> <title>demo_linclass.m</title><link rel="stylesheet" type="text/css" href="../../m-syntax.css"></head><body><code><span class=defun_kw>function</span> <span class=defun_out>result </span>= <span class=defun_name>demo_linclass</span>(<span class=defun_in>action,hfigure,varargin</span>)<br><span class=h1>% DEMO_LINCLASS Demo on the algorithms learning linear classifiers.</span><br><span class=help>%</span><br><span class=help>% <span class=help_field>Synopsis:</span></span><br><span class=help>% demo_linclass</span><br><span class=help>%</span><br><span class=help>% <span class=help_field>Description:</span></span><br><span class=help>% DEMO_LINCLASS demonstrates use of the algorithms which find </span><br><span class=help>% linear decision hyperplane between two (dichotomy)</span><br><span class=help>% vector sets. The demo requires 2D input training data.</span><br><span class=help>%</span><br><span class=help>% The program vizualizes found hyperplane in the current </span><br><span class=help>% algorithm step. The missclassified vector used by the</span><br><span class=help>% demonstrated iterative algorithms for update is vizualized</span><br><span class=help>% as well. Text description of the found solution is</span><br><span class=help>% printed at the bottom part of window.</span><br><span class=help>%</span><br><span class=help>% Following algorithms can be tested:</span><br><span class=help>%</span><br><span class=help>% Perceptron - Perceptron learning rule (see 'help perceptron').</span><br><span class=help>% Kozinec - Kozinec's algorithm (see 'help ekozinec', eps=-1). </span><br><span class=help>% e-Kozinec - Kozinec's algorithm finding eps-optimal hyperplane</span><br><span class=help>% (see 'help ekozinec', eps > 0).</span><br><span class=help>% Linear SVM - Linear Supprot Vector Machines for separable data</span><br><span class=help>% (see 'help smo', C=inf, ker='linear').</span><br><span class=help>%</span><br><span class=help>% <span class=help_field>Control:</span></span><br><span class=help>% Algorithm - Dselects algorithm for testing.</span><br><span class=help>% Epsilon - Input parameter of 'ekozinec' algorithm </span><br><span class=help>% (see 'help ekozinec').</span><br><span class=help>% Iterations - Number of iterations in one step.</span><br><span class=help>% Animation - Enables/dissables animation - smooth changeover </span><br><span class=help>% between two algorithm states.</span><br><span class=help>%</span><br><span class=help>% FIG2EPS - Exports screen to the PostScript file.</span><br><span class=help>% Load data - Loads input training data from file.</span><br><span class=help>% Create data - Invokes program for creating training data.</span><br><span class=help>% Reset - Sets the algorithm to the initial state.</span><br><span class=help>% Play - Runs the algorithm.</span><br><span class=help>% Stop - Stops the running algorithm.</span><br><span class=help>% Step - Perform one step of the algorithm.</span><br><span class=help>% Info - Invoke the info box.</span><br><span class=help>% Close - Close the program.</span><br><span class=help>%</span><br><span class=help>% See also </span><br><span class=help>% PERCEPTRON, EKOZINEC, SVM.</span><br><span class=help>%</span><br><hr><span class=help1>% <span class=help1_field>About:</span> Statistical Pattern Recognition Toolbox</span><br><span class=help1>% (C) 1999-2003, Written by Vojtech Franc and Vaclav Hlavac</span><br><span class=help1>% <a href="http://www.cvut.cz">Czech Technical University Prague</a></span><br><span class=help1>% <a href="http://www.feld.cvut.cz">Faculty of Electrical Engineering</a></span><br><span class=help1>% <a href="http://cmp.felk.cvut.cz">Center for Machine Perception</a></span><br><br><span class=help1>% <span class=help1_field>Modifications:</span></span><br><span class=help1>% 19-sep-2003, VF</span><br><span class=help1>% 17-Feb-2003, VF</span><br><span class=help1>% 24. 6.00 V. Hlavac, comments polished.</span><br><span class=help1>% 11-dec-2000 V. Franc, a little increasing of code readibility</span><br><span class=help1>% 15-dec-2000</span><br><br><hr>LINE_WIDTH=1; <span class=comment>% width of separation line</span><br>ANIM_STEPS=10; <span class=comment>% number of steps during the line animation</span><br>BORDER=0.2; <span class=comment>% minimal space between axis and points</span><br><span class=comment>%DATA_IDENT='Finite sets, Enumeration'; % file identifier</span><br>ALGOS=[<span class=quotes>'Perceptron'</span>;<span class=quotes>'Kozinec '</span>;<span class=quotes>'e-Kozinec '</span>; <span class=quotes>'LinearSVM '</span>];<br>WRONGPOINT_SIZE = 13;<br><br><span class=comment>% if number of arguments is less then 1, that means first call of this</span><br><span class=comment>% function. Every other calls set up at least argument action</span><br><span class=keyword>if</span> <span class=stack>nargin</span> < 1,<br> action = <span class=quotes>'initialize'</span>;<br><span class=keyword>end</span><br><br><span class=comment>% what action is required ?</span><br><span class=keyword>switch</span> lower(action)<br><br><span class=label>case</span> <span class=quotes>'initialize'</span><br> <span class=comment>% == Initialize user interface control and figure =======</span><br><br> <span class=comment>% == Figure =============================================</span><br> left=0.1;<br> width=0.8;<br> bottom=0.1;<br> height=0.8;<br> hfigure=<span class=graph>figure</span>(<span class=quotes>'Name'</span>,<span class=quotes>'Linear discriminant function'</span>, ...<br> <span class=quotes>'Visible'</span>,<span class=quotes>'off'</span>,...<br> <span class=quotes>'NumberTitle'</span>,<span class=quotes>'off'</span>, ...<br> <span class=quotes>'Units'</span>,<span class=quotes>'normalized'</span>, ...<br> <span class=quotes>'Position'</span>,[left bottom width height],...<br> <span class=quotes>'Units'</span>,<span class=quotes>'normalized'</span>, ...<br> <span class=quotes>'tag'</span>,<span class=quotes>'Demo_Linclass'</span>,...<br> <span class=quotes>'RendererMode'</span>,<span class=quotes>'manual'</span>);<br><br> <span class=comment>% == Axes =========================================</span><br> left=0.1;<br> width=0.65;<br> bottom=0.35;<br> height=0.60;<br> haxes1=<span class=graph>axes</span>(...<br> <span class=quotes>'Units'</span>,<span class=quotes>'normalized'</span>, ...<br> <span class=quotes>'Box'</span>,<span class=quotes>'on'</span>, ...<br> <span class=quotes>'DrawMode'</span>,<span class=quotes>'fast'</span>,...<br> <span class=quotes>'UserData'</span>,[],...<br> <span class=quotes>'Position'</span>,[left bottom width height]);<br> xlabel(<span class=quotes>'feature x_1'</span>);<br> ylabel(<span class=quotes>'feature x_2'</span>);<br><br> <span class=comment>% == Comment window =================================</span><br> <span class=comment>% Comment Window frame</span><br> bottom=0.05;<br> height=0.2;<br> <span class=graph>uicontrol</span>( ...<br> <span class=quotes>'Style'</span>,<span class=quotes>'frame'</span>, ...<br> <span class=quotes>'Units'</span>,<span class=quotes>'normalized'</span>, ...<br> <span class=quotes>'Position'</span>,[left bottom width height], ...<br> <span class=quotes>'BackgroundColor'</span>,[0.5 0.5 0.5]);<br><br> <span class=comment>% Text label</span><br> <span class=graph>uicontrol</span>( ...<br> <span class=quotes>'Style'</span>,<span class=quotes>'text'</span>, ...<br> <span class=quotes>'Units'</span>,<span class=quotes>'normalized'</span>, ...<br> <span class=quotes>'Position'</span>,[left height-0.01 width 0.05], ...<br> <span class=quotes>'BackgroundColor'</span>,[0.5 0.5 0.5], ...<br> <span class=quotes>'ForegroundColor'</span>,[1 1 1], ...<br> <span class=quotes>'String'</span>,<span class=quotes>'Comment Window'</span>);<br><br> <span class=comment>% Edit window</span><br> border=0.01;<br> hconsole=<span class=graph>uicontrol</span>( ...<br> <span class=quotes>'Style'</span>,<span class=quotes>'edit'</span>, ...<br> <span class=quotes>'HorizontalAlignment'</span>,<span class=quotes>'left'</span>, ...<br> <span class=quotes>'Units'</span>,<span class=quotes>'normalized'</span>, ...<br> <span class=quotes>'Max'</span>,10, ...<br> <span class=quotes>'BackgroundColor'</span>,[1 1 1], ...<br> <span class=quotes>'Position'</span>,[left+border bottom width-2*border height-0.05], ...<br> <span class=quotes>'Enable'</span>,<span class=quotes>'inactive'</span>,...<br> <span class=quotes>'String'</span>,<span class=quotes>''</span>);<br><br><br> <span class=comment>% == Buttons ===========================================</span><br> <span class=comment>% -- Export to EPS ---------</span><br> width=0.1;<br> left=0.75-width;<br> bottom=0.95;<br> height=0.04;<br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -