?? vibrate23.m
字號:
clear all
close all
load vibrate23;
Sample=a;
[row column]=size(Sample);
value0=Sample(:,column);
standdata=Sample;
rate=[];
x=[];
m=0;
noise=randn(20,8);
%load noise9;
for n=-20:0.1:20
m=m+1;
standdata=[Sample;(Sample(:,1:column-1)+n*noise),value0];
%排序
[value,order]=sort(standdata(:,column));
for i=1:column-1
datai=standdata(:,i);
orderi=datai(order);
standdata(:,i)=orderi;
end
catenu=max(value);
classnu=[];
trainnu=[];
beginloc=[1];
overnu=0;
overnut=0;
overloc=[];
overloct=[];
Samples1=[];
Labels=[];
testS1=[];
testL=[];
for i=1:catenu
number=length(find(value==i));
classnu=[classnu,number];
trainnu=[trainnu,round(number*2/3)];
overnut=overnut+number;
beginloc=[beginloc,overnut+1];
overnu=beginloc(i)+round(number*2/3)-1;
overloc=[overloc,overnu];
overloct=[overloct,overnut];
Samples1=[Samples1;standdata(beginloc(i):overloc(i),1:column-1)];
Labels=[Labels;value(beginloc(i):overloc(i))];
testS1=[testS1;standdata(overloc(i)+1:overloct(i),1:column-1)];
testL=[testL;value(overloc(i)+1:overloct(i))];
end
%catenu
%pause
%tic
[AlphaY1, SVs1, Bias1, Parameters1, nSV1, nLabel1] =LinearSVC(Samples1', Labels');
%toc
%nSV1
[ClassRate1, DecisionValue1, Ns1, ConfMatrix1, PreLabels1]= SVMTest(testS1',testL', AlphaY1, SVs1, Bias1,Parameters1, nSV1, nLabel1);
%ClassRate1
rate(m)=ClassRate1;
x(m)=n;
%ConfMatrix1
end
figure(1)
xx=DecisionValue1;
mfparams = [log(.25) 0];
mftype = 'sigmf';
y=evalmf(xx,mfparams,mftype);
plot(xx,y,'* r',xx,PreLabels1,'o b')
grid on
hold on
%xx=DecisionValue1;
mfparams = [-log(.25) 0];
%mftype = 'sigmf';
yy=evalmf(xx,mfparams,mftype);
plot(xx,yy,'o r')
figure(2)
stairs(x,rate,'o')
%figure(1)
%[Labels, DecisionValue]= SVMClass(Samples1', AlphaY1, SVs1, Bias1, Parameters1, nSV1, nLabel1);
%plot(Labels,DecisionValue,'.')
%%hold on
%[Labels, DecisionValue]= SVMClass(testS1', AlphaY1, SVs1, Bias1, Parameters1, nSV1, nLabel1);
%plot(Labels,DecisionValue,'o')
%[Labels, DecisionValue]= SVMClass(SVs1, AlphaY1, SVs1, Bias1, Parameters1, nSV1, nLabel1);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -