📄 demo_anderson.html
字号:
<html><head> <meta HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=ISO-8859-1"> <title>demo_anderson.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_anderson</span>(<span class=defun_in>action,hfigure,varargin</span>)<br><span class=h1>% DEMO_ANDERSON Demo on Generalized Anderson's task.</span><br><span class=help>%</span><br><span class=help>% <span class=help_field>Synopsis:</span></span><br><span class=help>% demo_anderson</span><br><span class=help>%</span><br><span class=help>% <span class=help_field>Description:</span></span><br><span class=help>% This demo demonstrates the algorithms which solve </span><br><span class=help>% the Generalized Anderson`s Task (GAT) [SH10]. The GAT is an </span><br><span class=help>% instance of the non-Bayesian task of decision under </span><br><span class=help>% non-random intervention. </span><br><span class=help>% </span><br><span class=help>% The goal of is to find a binary linear classification</span><br><span class=help>% rule (g(x)=sgn(W'*x+b) (line in 2D) with minimal probability of</span><br><span class=help>% misclassification. The conditional probabilities are known to</span><br><span class=help>% be Gaussians their paramaters belong to a given set of </span><br><span class=help>% parameters. The true parameters are not known. The linear rule </span><br><span class=help>% which guarantes the minimimal classification error for the worst</span><br><span class=help>% possible case (the worst configuration of Gaussains) is</span><br><span class=help>% sought for.</span><br><span class=help>% </span><br><span class=help>% The found solution (hyperplane, line in 2D) is vizualized </span><br><span class=help>% as well as the input Gaussians which describe input classes.</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>% Eps-solution - Finds epsilon-solution of the GAT in finite number</span><br><span class=help>% of iterations if such solution exist. The epsilon means</span><br><span class=help>% desired classification error.</span><br><span class=help>% Original - Original Anderson-Bahadur's algorithm defined for </span><br><span class=help>% two Gaussians only (each class one Gaussian).</span><br><span class=help>% Optimal - Implementation of general algorithm propsed by Schlesinger.</span><br><span class=help>% It finds the optimal solution.</span><br><span class=help>% Gradient - Fast and simple implementation which uses the generalized</span><br><span class=help>% gradient descent optimization.</span><br><span class=help>%</span><br><span class=help>% <span class=help_field>Control:</span></span><br><span class=help>% Algorithm - select algorithm for testing.</span><br><span class=help>% Parameter - parameters for the selected algorithm.</span><br><span class=help>% Iterations - number of iterations in one step.</span><br><span class=help>% Animation - enable/dissable animation.</span><br><span class=help>%</span><br><span class=help>% FIG2EPS - export screen to the PostScript file.</span><br><span class=help>% Load data - load input point sets from file.</span><br><span class=help>% Create data - call interactive program for creating sets of Gaussians.</span><br><span class=help>% Reset - set the tested algorithm to the initial state.</span><br><span class=help>% Play - run the tested algorithm.</span><br><span class=help>% Stop - stop the running algorithm.</span><br><span class=help>% Step - perform only one step.</span><br><span class=help>% Info - display 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>% EANDERS, ANDRORIG, GGRADANDR, GANDERS.</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>% 17-sep-2003, VF</span><br><span class=help1>% 11-June-2001, V.Franc, comments added.</span><br><span class=help1>% 24. 6.00 V. Hlavac, comments polished.</span><br><br><hr><span class=comment>% constants</span><br>ALGONAMES=[<span class=quotes>'Eps-solution '</span>;...<br> <span class=quotes>'Original '</span>;...<br> <span class=quotes>'Gradient '</span>;...<br> <span class=quotes>'Optimal '</span>];<br>PREC_TITLE=[<span class=quotes>'Max error (0-50) [%]'</span>;... <span class=comment>% e-Optimal solution</span><br> <span class=quotes>'d(lambda,ni) (0,inf)'</span>;... <span class=comment>% Original Anderson`s solution</span><br> <span class=quotes>'d( min r ) (0,inf) '</span>;... <span class=comment>% Gradient method</span><br> <span class=quotes>'d( min r ) (0,inf) '</span>]; <span class=comment>% General solution </span><br>DEF_PRECISION=[10,1e-3,1e-3,1e-3]; <span class=comment>% default values of the precision of algo. 1,2,...</span><br>BORDER=0.5;<br>DATA_IDENT=<span class=quotes>'Infinite sets, Normal distributions'</span>; <span class=comment>% M-file identifier</span><br>PLOT_FCE=<span class=quotes>'pandr2d'</span>; <span class=comment>% outlined ellipsoids</span><br><span class=comment>%PLOT_FCE='pandr2df'; % outlined ellipsoids</span><br><br><span class=comment>% if number of arguments is less then 1, that means first call of this function. Every</span><br><span class=comment>% 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 window ================</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>'Anderson`s task'</span>, ...<br> <span class=quotes>'Visible'</span>,<span class=quotes>'off'</span>,...<br> <span class=quotes>'Units'</span>,<span class=quotes>'normalized'</span>, ...<br> <span class=quotes>'NumberTitle'</span>,<span class=quotes>'off'</span>, ...<br> <span class=quotes>'Position'</span>,[left bottom width height],...<br> <span class=quotes>'tag'</span>,<span class=quotes>'Demo_Anderson'</span>,...<br> <span class=quotes>'Units'</span>,<span class=quotes>'normalized'</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><br> <span class=comment>% axes for showing sets</span><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>'NextPlot'</span>,<span class=quotes>'add'</span>,...<br> <span class=quotes>'Layer'</span>,<span class=quotes>'top'</span>,...<br> <span class=quotes>'UserData'</span>,[],...<br> <span class=quotes>'Position'</span>,[left bottom width height]);<br> xlabel(<span class=quotes>'feature x'</span>);<br> ylabel(<span class=quotes>'feature y'</span>);<br><br> <span class=comment>% == Comment window =====================================================</span><br><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>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -