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

📄 dd_crossval.m

📁 数据挖掘的工具箱,最新版的,希望对做这方面研究的人有用
💻 M
字号:
function [y,z,I,Itr] = dd_crossval(x,I)%DD_CROSSVAL%%   [Y,Z,I] = DD_CROSSVAL(X,I/NRBAGS)% % Create cross-validation sets. When called for the first time:%   [Y,Z,I] = DD_CROSSVAL(X,NRBAGS)% Here I gives the number of bags and the permutated object indices.% Y and Z give the new training set (containing (NRBAGS-1) pieces) and% the new testing set (containing just 1 bag). All bags are of equal% size, and class sizes are not taken into account. After gettting Y% and Z the index variable I is updated. This is needed for the next% call to dd_crossval.%% A typical run looks therefore something like:% I = 5;% for i=1:5%   [Y,Z,I] = DD_CROSSVAL(X,I)%   % do something useful wil Y and Z...% end%% Note that you have to update the I each time, else you will get the% same training and test set.%% See also: dd_error, dd_auc% Copyright: D.M.J. Tax, davidt@ph.tn.tudelft.nl% Faculty of Applied Physics, Delft University of Technology% P.O. Box 5046, 2600 GA Delft, The Netherlands% Dxd, 4-7-99% Dxd, 11-07-2002 renewed% Dxd, 9-05-2003 for the new prtoolsif (nargin<2)	error('I or nrbags should be given!');endif length(I)==1	nrbags = I; I = [];end% Check if the coding vector I is already definedif ~isempty(I) % is already defined, go for the next bag.	if (I(5)~=170673)		error('Sorry, I has not the right format');  end  I(2) = I(2) + 1; % goto next bag  if (I(2)>I(1))	  warning('Maximal number of bags is extracted');  endelse % Create a vector I to code for the bags	nrx = size(x,1);	I = [zeros(5,1); (mod(0:nrx-1,nrbags)+1)'];	I(5) = 170673;	I(1) = nrbags;	I(2) = 1;      % number of active bagend% Extract the correct data given the I:J = I(6:end);Itr = find(J~=I(2));y = x(Itr,:);z = x((J==I(2)),:);% One security check:if nargout<3	warning('You probably want to use the I for the next time!');end% Useful for inspection purposes:if isdataset(y)	y = setname(y,[getname(y),' (Xval train)']);	z = setname(z,[getname(z),' (Xval test)']);endreturn

⌨️ 快捷键说明

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