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

📄 jknifeclass.m

📁 Stanford的SRB实验室Quantitative Seismic Interpretation的免费MATLAB程序
💻 M
字号:
%JKNIFECLASS Jacknife classification%function [confmat, srmat]=jknifeclass(trndat,grp)%%Leave-one-out jacknife classification to test training data classification%TRNDAT: Training data matrix with columns of attributes. %GRP: column of group (class) code (integers), with same number of rows%as training data.%CONFMAT: Classification confusion matrix giving the conditional%         probability Pr(true group | predicted group)%         Rows correspond to predicted group, columns to true group.%         E.g. confmat(2,3) is the probability that the true group =3%         when the predicted group =2.%SRMAT:   Classification success ratio matrix giving the conditional%         probability Pr(predicted group | true group).%         Rows correspond to true group, columns to predicted group.%         E.g. srmat(2,3) is the probability that the predicted group =3%         when the true group =2.%The diagonal diag(srmat)*100 gives the percent correct classification for each group.%Classification done by Mahalanobis distance.%Uses the statistical toolbox.%See also CLASSIFY%Written by T. Mukerjinclass=max(grp); ndat=size(trndat,1); pctcorr=zeros(1,nclass);ncorr=pctcorr; nmiss=ncorr; confmat=zeros(nclass,nclass); srmat=confmat;randdx=randperm(ndat); trndat=trndat(randdx,:); grp=grp(randdx);for kk=1:nclass, numclass(kk)=sum(grp==kk); numclass=numclass(:)'; end;for k=1:ndatdx=[1:ndat]~=k;samplek=trndat(k,:); trndatk=trndat(dx,:); grpk=grp(dx);clss(k)=classify(samplek,trndatk,grpk);end;clss=clss(:);for pred=1:nclass for tru=1:nclass   confmat(pred,tru) = sum((clss==pred) & (grp==tru))./sum(clss==pred);   srmat(tru,pred) = sum((grp==tru) & (clss==pred))./sum(grp==tru);end;end;if nargout==0bar(1:nclass,100*diag(srmat)); ylim([0 100]); ylabel('success %')confmatsrmatend;

⌨️ 快捷键说明

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