📄 d2cmatlab.m
字号:
function varargout = D2CMatlab(varargin)% D2CMATLAB Application M-file for D2CMatlab.fig% FIG = D2CMATLAB launch D2CMatlab GUI.% D2CMATLAB('callback_name', ...) invoke the named callback.% Last Modified by GUIDE v2.0 16-Sep-2006 11:46:45if nargin == 0 % LAUNCH GUI fig = openfig(mfilename,'reuse'); % Generate a structure of handles to pass to callbacks, and store it. handles = guihandles(fig); guidata(fig, handles); D2CReset(fig, handles); if nargout > 0 varargout{1} = fig; endelseif ischar(varargin{1}) % INVOKE NAMED SUBFUNCTION OR CALLBACK try if (nargout) [varargout{1:nargout}] = feval(varargin{:}); % FEVAL switchyard else feval(varargin{:}); % FEVAL switchyard end catch disp(lasterr); endend%| ABOUT CALLBACKS:%| GUIDE automatically appends subfunction prototypes to this file, and %| sets objects' callback properties to call them through the FEVAL %| switchyard above. This comment describes that mechanism.%|%| Each callback subfunction declaration has the following form:%| <SUBFUNCTION_NAME>(H, EVENTDATA, HANDLES, VARARGIN)%|%| The subfunction name is composed using the object's Tag and the %| callback type separated by '_', e.g. 'slider2_Callback',%| 'figure1_CloseRequestFcn', 'axis1_ButtondownFcn'.%|%| H is the callback object's handle (obtained using GCBO).%|%| EVENTDATA is empty, but reserved for future use.%|%| HANDLES is a structure containing handles of components in GUI using%| tags as fieldnames, e.g. handles.figure1, handles.slider2. This%| structure is created at GUI startup using GUIHANDLES and stored in%| the figure's application data using GUIDATA. A copy of the structure%| is passed to each callback. You can store additional information in%| this structure at GUI startup, and you can change the structure%| during callbacks. Call guidata(h, handles) after changing your%| copy to replace the stored original so that subsequent callbacks see%| the updates. Type "help guihandles" and "help guidata" for more%| information.%|%| VARARGIN contains any extra arguments you have passed to the%| callback. Specify the extra arguments by editing the callback%| property in the inspector. By default, GUIDE sets the property to:%| <MFILENAME>('<SUBFUNCTION_NAME>', gcbo, [], guidata(gcbo))%| Add any extra arguments after the last argument, before the final%| closing parenthesis.%D2CMatlab Utility Functionsfunction EnableHandle(handletype) set(handletype,'Enable','On'); set(handletype,'BackgroundColor',[1 1 1]); function DisableHandle(handletype) set(handletype,'Enable','Off'); set(handletype,'BackgroundColor',[0.9 0.9 0.9]); function D2CReset(fig, handles) % Initialize Default Values of User Data and Simulation Initial State handles.C=0.1; handles.tol=0.001; handles.NoFolds=20; handles.sigma=0.5; handles.p=1; handles.q=1; handles.d=3; handles.ktype=0; handles.trainfile='gs_6fP.txt'; handles.testfile='Test.txt'; handles.CStep=10; handles.Cstepflag=0; handles.SVMPP=[0]; handles.ROCData=[0 0]; handles.simRun=0; handles.numplots=0; handles.plotID=[0]; % Label the graph number to plot handles.ROCArea=0; handles.plotctr=0; handles.crrplot=0; % Set Model File Names handles.SVMposfile='SVMposprob.txt'; handles.SVMSurfaceModelfile='D2CModel.txt'; handles.SVMdecisionfile='fdecision.txt'; handles.SVMaccuracyfile='D2CSVMres.txt'; % Set Simulation Initial States handletype=[handles.checkbox1, handles.checkbox2, handles.checkbox3, handles.checkbox4, handles.checkbox5, handles.checkbox6, handles.checkbox7]; EnableHandle(handletype); set(handles.checkbox1,'Value',0); set(handles.checkbox2,'Value',0); set(handles.checkbox3,'Value',1); set(handles.checkbox4,'Value',0); set(handles.checkbox5,'Value',0); set(handles.checkbox6,'Value',0); set(handles.checkbox7,'Value',0); set(handles.checkbox8,'Value',1); %Check Kernel type set(handles.radiobutton1,'Value',0); set(handles.radiobutton2,'Value',1); set(handles.radiobutton3,'Value',0); set(handles.edit2,'String',handles.trainfile); set(handles.edit3,'String',num2str(handles.C)); set(handles.edit4,'String',num2str(handles.tol)); set(handles.edit6,'String',num2str(handles.sigma)); set(handles.edit7,'String',num2str(handles.p)); set(handles.edit8,'String',num2str(handles.q)); set(handles.edit9,'String',num2str(handles.d)); set(handles.edit10,'String',num2str(handles.NoFolds)); set(handles.edit12,'String','NA'); set(handles.edit13,'String',num2str(handles.CStep)); set(handles.pushbutton5,'String','Plot Graph'); set(handles.popupmenu3,'Value',3); handletype=[handles.pushbutton2, handles.pushbutton5, handles.edit7, handles.edit8, handles.edit9, handles.edit10, handles.edit12]; DisableHandle(handletype); set(handles.edit11,'String','Ready'); set(handles.edit11,'BackgroundColor',[0 1 0]); set(handles.edit12,'BackgroundColor',[1 0 0]); guidata(fig, handles); % --------------------------------------------------------------------%% Activates the Simulation and Runs it%% --------------------------------------------------------------------function varargout = pushbutton1_Callback(h, eventdata, handles, varargin)handles.simRun=1;% Disable Relevant GUI controlshandletype=[handles.checkbox1, handles.checkbox2, handles.checkbox3, handles.checkbox4, handles.checkbox5, handles.checkbox6, handles.checkbox7];DisableHandle(handletype); set(handles.edit12,'String','NA');set(handles.edit12,'BackgroundColor',[1 0 0]);% Parse the SVM options% Get SVM Working Set Method, C and Simulation Tolerancetempline=['D2C.exe -w ' num2str(get(handles.popupmenu3,'Value')-1) ' -c ' num2str(handles.C) ' -t ' num2str(handles.tol)];% Get SVM kernel typeswitch handles.ktypecase 0 templine=[templine ' -k ' num2str(handles.ktype)];case 1 templine=[templine ' -k ' num2str(handles.ktype) ' -p ' num2str(handles.p) ' -r ' num2str(handles.q) ' -d ' num2str(handles.d) ]; case 2 templine=[templine ' -k ' num2str(handles.ktype) ' -s ' num2str(handles.sigma)];end%Determine D2C SVM mode to run by checking the Analysis Options modeltype=0; %Check ROC areaif(get(handles.checkbox1,'Value')==1) handles.numplots=handles.numplots+1; handles.plotID(handles.numplots,1)=1; modeltype=3; cmdline=templine; end%Check Best Feature Selectionif(get(handles.checkbox2,'Value')==1) handles.numplots=handles.numplots+1; handles.plotID(handles.numplots,1)=2; modeltype=3; cmdline=templine; %Insert Best Feature Function Hereend%Check 2D Surfaceif(get(handles.checkbox6,'Value')==1) handles.numplots=handles.numplots+1; handles.plotID(handles.numplots,1)=3; modeltype=3; cmdline=templine; end%Check 3D Surfaceif(get(handles.checkbox7,'Value')==1) handles.numplots=handles.numplots+1; handles.plotID(handles.numplots,1)=4; modeltype=3; cmdline=templine; end%Check Posterior Probabilityif(get(handles.checkbox4,'Value')==1) handles.numplots=handles.numplots+1; handles.plotID(handles.numplots,1)=5; modeltype=3; cmdline=templine; end %Check Leave One Out checkboxif(get(handles.checkbox3,'Value')==1) modeltype=3; cmdline=templine; end%Check Cross Validation checkboxif(get(handles.checkbox5,'Value')==1) modeltype=2; cmdline=[templine ' -n ' num2str(handles.NoFolds) ];end%Set Simulation for continous C Stepping Simulationif((get(handles.checkbox8,'Value')==1) & handles.Cstepflag==0) handles.CStep=str2double(get(handles.edit13,'String')); handles.Cstepflag=1;end if((get(handles.checkbox8,'Value')==1) & handles.Cstepflag==1) handles.C=handles.C*handles.CStep; set(handles.edit3,'String',num2str(handles.C));end%Save Selections guidata(h,handles);%Final Command Line Assembly cmdline=[cmdline ' -m ' num2str(modeltype) ' ' handles.trainfile ' D2CMatlab.mod']; %Run Simulation D2CRun(cmdline,handles);%Run Analysis depending on Selected Options D2CAnalysis(h, handles); % --------------------------------------------------------------------function varargout = edit2_Callback(h, eventdata, handles, varargin)%Check which string to store tostate=get(handles.popupmenu1, 'Value');if(state==1) handles.trainfile=get(handles.edit2, 'String');endif(state==2) handles.testfile=get(handles.edit2, 'String');endguidata(h, handles);% --------------------------------------------------------------------function varargout = popupmenu1_Callback(h, eventdata, handles, varargin) set(handles.edit2,'String',' ');% --------------------------------------------------------------------function varargout = checkbox1_Callback(h, eventdata, handles, varargin)% --------------------------------------------------------------------% Tag for C parameter%function varargout = edit3_Callback(h, eventdata, handles, varargin)handles.C=str2double(get(handles.edit3,'string'));guidata(h, handles);% --------------------------------------------------------------------function varargout = togglebutton4_Callback(h, eventdata, handles, varargin)handles.C=str2double(get(handles.edit3,'string'));handles.C=handles.C+1;set(handles.edit3,'string',num2str(handles.C));guidata(h, handles);% --------------------------------------------------------------------function varargout = togglebutton5_Callback(h, eventdata, handles, varargin)handles.C=str2double(get(handles.edit3,'string'));if(handles.C>0) handles.C=handles.C-1; set(handles.edit3,'string',num2str(handles.C)); guidata(h, handles);end% --------------------------------------------------------------------% Tag for Tolerance parameter%function varargout = edit4_Callback(h, eventdata, handles, varargin)handles.tol=str2double(get(handles.edit4,'string'));guidata(h, handles);% --------------------------------------------------------------------function varargout = checkbox2_Callback(h, eventdata, handles, varargin) if(get(handles.checkbox2,'Value')==1) handletype=[handles.checkbox1, handles.checkbox4, handles.checkbox6, handles.checkbox7]; set(handletype,'Value',0); DisableHandle(handletype); guidata(h,handles);else handletype=[handles.checkbox1, handles.checkbox4, handles.checkbox6, handles.checkbox7]; EnableHandle(handletype); guidata(h,handles);end% --------------------------------------------------------------------function varargout = checkbox3_Callback(h, eventdata, handles, varargin)if(get(handles.checkbox3,'Value')==1) DisableHandle(handles.checkbox5);else EnableHandle(handles.checkbox5);end% --------------------------------------------------------------------function varargout = checkbox4_Callback(h, eventdata, handles, varargin)if(get(handles.checkbox4,'Value')==1) set(handles.checkbox3,'Value',1);else set(handles.checkbox3,'Value',0); end% --------------------------------------------------------------------% Linear Kernel Choice%function varargout = radiobutton1_Callback(h, eventdata, handles, varargin)off=[handles.radiobutton2, handles.radiobutton3];set(off,'Value',0);handletype=[handles.edit6,handles.edit7, handles.edit8, handles.edit9];DisableHandle(handletype);handles.ktype=0;guidata(h, handles);% --------------------------------------------------------------------% Gaussian Kernel Choice%
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -